gros dev pre proto
* Changement de l'UI, ajouts de l'inspecteur par carte et changement de police * Ajout d'un semblant d'exploration * Ajout de la sauvegarde des entités * Restructuration mineure de l'arborescence * Fix divers et réécriture des textes
This commit is contained in:
@@ -4,22 +4,43 @@ class_name GameGui
|
||||
signal pause_asked
|
||||
|
||||
func _ready():
|
||||
Pointer.connect("inspected_changed", _on_inspected_changed)
|
||||
GameInfo.game_data.current_planet_data.updated.connect(_on_planet_updated)
|
||||
GameInfo.game_data.current_planet_data.new_quota_started.connect(_on_planet_new_quota_started)
|
||||
GameInfo.game_data.player_data.updated.connect(_on_player_updated)
|
||||
GameInfo.game_data.player_data.inventory.updated.connect(_on_inventory_updated)
|
||||
|
||||
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
|
||||
if not GameInfo.game_data.current_planet_data.is_quota_announced:
|
||||
announce_quota(GameInfo.game_data.current_planet_data)
|
||||
GameInfo.game_data.current_planet_data.is_quota_announced = true
|
||||
planet_update(GameInfo.game_data.current_planet_data)
|
||||
player_update(GameInfo.game_data.player_data)
|
||||
inventory_update(GameInfo.game_data.player_data.inventory)
|
||||
|
||||
%Inventory.update(player.inventory)
|
||||
|
||||
update_no_energy_left_info(player.energy)
|
||||
func _on_player_updated(player_data : PlayerData):
|
||||
player_update(player_data)
|
||||
|
||||
func _on_planet_updated(planet:Planet):
|
||||
%DayCount.text = str(planet.get_quota_remaining_days()) + " days left"
|
||||
func player_update(player_data : PlayerData):
|
||||
%EnergyCount.text = "%d/%d" % [player_data.energy, player_data.max_energy]
|
||||
%EnergyInfo.modulate = Color.WHITE if player_data.energy > 0 else Color.RED
|
||||
|
||||
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))
|
||||
update_no_energy_left_info(player_data.energy)
|
||||
|
||||
func _on_inventory_updated(inventory : Inventory):
|
||||
inventory_update(inventory)
|
||||
|
||||
func inventory_update(inventory : Inventory):
|
||||
%Inventory.update(inventory)
|
||||
|
||||
func _on_planet_updated(planet_data : PlanetData):
|
||||
planet_update(planet_data)
|
||||
|
||||
func planet_update(planet_data : PlanetData):
|
||||
if planet_data:
|
||||
%DayCount.text = "%d days left" % (planet_data.quota_days)
|
||||
|
||||
var quota_progression_percent : float = (float(planet_data.garden_score) / float(planet_data.get_quota_score())) * 100
|
||||
%QuotaProgressText.text = "%d/%d" % [planet_data.garden_score, planet_data.get_quota_score()]
|
||||
get_tree().create_tween().tween_property(
|
||||
%QuotaProgressBar,
|
||||
"value",
|
||||
@@ -31,7 +52,7 @@ func _on_player_action_tried_without_energy():
|
||||
$AnimationPlayer.play("no_energy_left")
|
||||
|
||||
func _on_pause_pressed():
|
||||
pause_asked.emit()
|
||||
Pause.pause = true
|
||||
|
||||
|
||||
func _on_player_upgraded():
|
||||
@@ -43,9 +64,6 @@ func _on_planet_pass_day_started(planet):
|
||||
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
|
||||
@@ -54,23 +72,22 @@ func update_no_energy_left_info(energy):
|
||||
%NoEnergyLeft.visible = false
|
||||
|
||||
|
||||
func _on_planet_new_quota_started(planet:Planet):
|
||||
func _on_planet_new_quota_started(planet_data : PlanetData):
|
||||
announce_quota(planet_data)
|
||||
planet_update(planet_data)
|
||||
planet_data.is_quota_announced = true
|
||||
|
||||
|
||||
func announce_quota(planet_data : PlanetData):
|
||||
%Announce.announce(
|
||||
"New Quota",
|
||||
"Reach " + str(roundi(planet.next_quota)) + " garden score before " + str(Planet.DEFAULT_DAY_LIMIT) + " days"
|
||||
"Reach %d garden score before %d days" % [planet_data.get_quota_score(), planet_data.get_quota_duration()]
|
||||
)
|
||||
|
||||
func _on_planet_pass_day_ended(planet:Planet):
|
||||
var remaining_days = planet.get_quota_remaining_days()
|
||||
if remaining_days == 1:
|
||||
if planet.data.quota_days == 1:
|
||||
%Announce.announce(
|
||||
"Last day for reaching quota",
|
||||
str(roundi(planet.next_quota - planet.garden_score)) + " garden score left",
|
||||
str(roundi(planet.data.get_quota_score() - planet.garden.get_score())) + " garden score left",
|
||||
Announce.RED_COLOR
|
||||
)
|
||||
if remaining_days == 2:
|
||||
%Announce.announce(
|
||||
"2 days left before quota's ending",
|
||||
str(roundi(planet.next_quota - planet.garden_score)) + " garden score left",
|
||||
Announce.YELLOW_COLOR
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user