55 lines
1.6 KiB
GDScript
55 lines
1.6 KiB
GDScript
extends Control
|
|
class_name GameGui
|
|
|
|
signal pause_asked
|
|
|
|
func _ready():
|
|
Pointer.connect("inspected_entity_changed", _on_inspected_entity_changed)
|
|
|
|
func _on_player_updated(player:Player):
|
|
%EnergyCount.text = str(player.energy) + "/" + str(player.max_energy)
|
|
%EnergyInfo.modulate = Color.WHITE if player.energy > 0 else Color.RED
|
|
|
|
update_no_energy_left_info(player.energy)
|
|
|
|
func _on_planet_updated(planet:Planet):
|
|
%DayCount.text = "Day " + str(planet.day) + "/" + str(planet.day_limit)
|
|
|
|
var quota_progression_percent : float = (planet.decontamination_surface - planet.surface_on_last_quota) / (planet.next_quota - planet.surface_on_last_quota) * 100
|
|
%QuotaProgressText.text = str(roundi(quota_progression_percent)) + " %"
|
|
get_tree().create_tween().tween_property(
|
|
%QuotaProgressBar,
|
|
"value",
|
|
quota_progression_percent,
|
|
0.5,
|
|
)
|
|
|
|
func _on_player_action_tried_without_energy():
|
|
$AnimationPlayer.play("no_energy_left")
|
|
|
|
func _on_pause_pressed():
|
|
pause_asked.emit()
|
|
|
|
|
|
func _on_player_upgraded():
|
|
$EffectAnimation.play("upgrade")
|
|
|
|
func _on_planet_pass_day_started(planet):
|
|
$PassDayAnimation.speed_scale = 1/(planet.PASS_DAY_ANIMATION_TIME)
|
|
$PassDayAnimation.play("pass_day")
|
|
await $PassDayAnimation.animation_finished
|
|
$PassDayAnimation.speed_scale = 1
|
|
|
|
func _on_inspected_entity_changed(e : InspectableEntity):
|
|
var info : Inspector.Info = null
|
|
if e:
|
|
info = e.inspector_info()
|
|
%Inspector.info = info
|
|
|
|
func update_no_energy_left_info(energy):
|
|
if energy == 0 and not %NoEnergyLeft.visible:
|
|
%NoEnergyLeft.visible = true
|
|
$NoEnergyLeftAnimation.play("no_energy_left_appear")
|
|
elif energy != 0 and %NoEnergyLeft.visible:
|
|
%NoEnergyLeft.visible = false
|