* ajout des mutations #86 * changement de l'objectif #85 * refonte de l'inspecteur #71 * changement léger de la plantation * les plantes ne donnent que des graines de leurs espèces * refonte partielle du code, refacto
77 lines
2.3 KiB
GDScript
77 lines
2.3 KiB
GDScript
extends Control
|
|
class_name GameGui
|
|
|
|
signal pause_asked
|
|
|
|
func _ready():
|
|
Pointer.connect("inspected_changed", _on_inspected_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
|
|
|
|
%Inventory.update(player.inventory)
|
|
|
|
update_no_energy_left_info(player.energy)
|
|
|
|
func _on_planet_updated(planet:Planet):
|
|
%DayCount.text = str(planet.get_quota_remaining_days()) + " days left"
|
|
|
|
if planet.next_quota:
|
|
var quota_progression_percent : float = (planet.garden_score - planet.last_quota) / (planet.next_quota - planet.last_quota) * 100
|
|
%QuotaProgressText.text = str(roundi(planet.garden_score)) + "/" + str(roundi(planet.next_quota))
|
|
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_changed(info : 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
|
|
|
|
|
|
func _on_planet_new_quota_started(planet:Planet):
|
|
%Announce.announce(
|
|
"New Quota",
|
|
"Reach " + str(roundi(planet.next_quota)) + " units before " + str(Planet.DEFAULT_DAY_LIMIT) + " days"
|
|
)
|
|
|
|
func _on_planet_pass_day_ended(planet:Planet):
|
|
var remaining_days = planet.get_quota_remaining_days()
|
|
if remaining_days == 1:
|
|
%Announce.announce(
|
|
"Last day for reaching quota",
|
|
str(roundi(planet.next_quota - planet.decontamination_surface)) + " units left to decontaminate",
|
|
Announce.RED_COLOR
|
|
)
|
|
if remaining_days == 2:
|
|
%Announce.announce(
|
|
"2 days left before quota's ending",
|
|
str(roundi(planet.next_quota - planet.decontamination_surface)) + " units left to decontaminate",
|
|
Announce.YELLOW_COLOR
|
|
)
|