first
This commit is contained in:
54
Maps/Spaceship/RoomScripts/controll.gd
Normal file
54
Maps/Spaceship/RoomScripts/controll.gd
Normal file
@@ -0,0 +1,54 @@
|
||||
extends BasicRoom
|
||||
class_name ControlRoom
|
||||
@onready var steeringMinigame = $Monitor/SubViewport/SteeringMinigame
|
||||
|
||||
@onready var lightswitch = $LightSwitch/ButtonLogicToggleLightswitch
|
||||
@onready var switchPivot = $LightSwitch/SwitchPivot
|
||||
@onready var light = $OmniLight3D
|
||||
|
||||
@export var controllStick: Node3D
|
||||
@export var shipConditionDisplayNumber: int = 100
|
||||
@onready var shipConditionNumberLabel = $Monitor_001/SubViewport2/Control/ShipConditionNumber
|
||||
@onready var shipConditionNumberLabelSettings = shipConditionNumberLabel.label_settings
|
||||
|
||||
func _ready() -> void:
|
||||
if controllStick:
|
||||
controllStick.get_child(0).onPressed.connect(controllLeverPressed)
|
||||
steeringMinigame.collision.connect(onAstroidCollision)
|
||||
steeringMinigame.controllStick = controllStick
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if shipConditionNumberLabel.label_settings:
|
||||
if shipConditionDisplayNumber >70:
|
||||
shipConditionNumberLabelSettings.font_color = Color.GREEN
|
||||
elif shipConditionDisplayNumber <=30:
|
||||
shipConditionNumberLabelSettings.font_color = Color.RED
|
||||
else:
|
||||
shipConditionNumberLabelSettings.font_color = Color.YELLOW
|
||||
|
||||
if lightswitch.state:
|
||||
switchPivot.rotation.x = deg_to_rad(0)
|
||||
else:
|
||||
switchPivot.rotation.x = deg_to_rad(17)
|
||||
|
||||
if SpaceshipLogicRef:
|
||||
if SpaceshipLogicRef.power:
|
||||
light.visible = lightswitch.state
|
||||
else:
|
||||
light.visible = SpaceshipLogicRef.power
|
||||
else:
|
||||
return
|
||||
|
||||
if !SpaceshipLogicRef.shipFuel:
|
||||
steeringMinigame.active = false
|
||||
|
||||
shipConditionNumberLabel.text = str(shipConditionDisplayNumber) + "%"
|
||||
|
||||
|
||||
|
||||
func controllLeverPressed():
|
||||
steeringMinigame.activate()
|
||||
|
||||
func onAstroidCollision():
|
||||
if SpaceshipLogicRef:
|
||||
SpaceshipLogicRef.collisionWithAstroid()
|
||||
Reference in New Issue
Block a user