2024-03-29 02:51:06 +01:00
|
|
|
extends Control
|
|
|
|
|
|
|
|
|
|
@onready var move_button = $PanelContainer/MarginContainer/VBoxContainer/MoveButton
|
|
|
|
|
@onready var action_button = $PanelContainer/MarginContainer/VBoxContainer/ActionButton
|
|
|
|
|
|
|
|
|
|
var current_tile: InsectTile = null
|
|
|
|
|
var tween: Tween = null
|
|
|
|
|
|
|
|
|
|
func show_panel() -> void:
|
|
|
|
|
scale = Vector2.ZERO
|
|
|
|
|
|
|
|
|
|
visible = true
|
|
|
|
|
if tween != null:
|
|
|
|
|
tween.kill()
|
|
|
|
|
|
|
|
|
|
tween = get_tree().create_tween()
|
|
|
|
|
tween.tween_property(self, "scale", Vector2(1.0, 1.0), 0.35).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_SPRING)
|
|
|
|
|
|
|
|
|
|
func hide_panel() -> void:
|
|
|
|
|
current_tile = null
|
|
|
|
|
|
|
|
|
|
if tween != null:
|
|
|
|
|
tween.kill()
|
|
|
|
|
|
|
|
|
|
tween = get_tree().create_tween()
|
|
|
|
|
tween.tween_property(self, "scale", Vector2(0.0, 0.0), 0.35).set_ease(Tween.EASE_OUT).set_trans(Tween.TRANS_EXPO)
|
|
|
|
|
|
|
|
|
|
tween.finished.connect(_on_panel_hidden)
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
func _on_panel_hidden() -> void:
|
|
|
|
|
visible = false
|
|
|
|
|
|
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
|
|
|
func _ready():
|
|
|
|
|
GameEvents.choose_action_or_move.connect(_on_choose_action_or_move)
|
|
|
|
|
GameEvents.insect_tile_deselected.connect(_on_tile_deselected)
|
|
|
|
|
|
|
|
|
|
func _on_tile_deselected(tile: InsectTile) -> void:
|
|
|
|
|
hide_panel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_choose_action_or_move(tile: InsectTile, has_action_targets: bool, can_move: bool) -> void:
|
|
|
|
|
current_tile = tile
|
2024-03-30 01:43:38 +01:00
|
|
|
move_button.text = "Move as %s" % tile.get_resource().tile_name
|
2024-03-29 02:51:06 +01:00
|
|
|
move_button.disabled = !can_move
|
|
|
|
|
|
2024-03-30 01:43:38 +01:00
|
|
|
action_button.text = "Use action of %s" % tile.get_resource().tile_name
|
2024-03-29 02:51:06 +01:00
|
|
|
action_button.disabled = !has_action_targets
|
|
|
|
|
show_panel()
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
|
|
|
|
func _process(delta):
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_action_button_pressed():
|
|
|
|
|
GameEvents.insect_tile_action_started.emit(current_tile)
|
|
|
|
|
hide_panel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_move_button_pressed():
|
|
|
|
|
GameEvents.insect_tile_move_started.emit(current_tile)
|
|
|
|
|
hide_panel()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _on_cancel_button_pressed():
|
|
|
|
|
GameEvents.insect_tile_deselected.emit(current_tile)
|
|
|
|
|
pass # Replace with function body.
|