seeding-planets/gui/scripts/root_gui.gd

40 lines
1.4 KiB
GDScript

extends Control
class_name RootGui
signal game_click
signal day_pass_pressed
signal day_pass_proceed
signal day_pass_finished
func _on_player_updated(player:Player):
$MarginContainer/PlayerInfo.player_update(player)
%AvailableActions/GetItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() == 0
%AvailableActions/SwapItem.visible = player.closest_interactable is ItemObject and player.inventory.lenght() > 0
%AvailableActions/DropItem.visible = player.inventory.lenght() > 0
%AvailableActions/UseItem.visible = player.inventory.lenght() > 0 and player.can_use_item and not player.inventory.get_item() is SeedItem
%AvailableActions/Plant.visible = player.inventory.lenght() > 0 and player.can_use_item and player.inventory.get_item() is SeedItem
%ItemInfo.visible = player.inventory.lenght() > 0
if player.inventory.lenght() > 0:
var item : Item = player.inventory.get_item()
%ItemIcon.texture = item.icon
%ItemName.text = item.name
%ItemDesc.text = item.description
func _on_planet_planet_stats_updated(day:int):
$MarginContainer/DayCount.text = "Day " + str(day)
func _on_day_pass_pressed():
day_pass_pressed.emit()
$AnimationPlayer.play("recharge_fade_in")
await $AnimationPlayer.animation_finished
day_pass_proceed.emit()
$AnimationPlayer.play("recharge_fade_out")
await $AnimationPlayer.animation_finished
day_pass_finished.emit()
func _on_game_action_button_down():
game_click.emit()