From 218748f67a6a6b35efc4a732ad11426d0f528709 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 12 Feb 2025 20:05:59 +0100 Subject: next commit --- stage/player_unit.gd | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 stage/player_unit.gd (limited to 'stage/player_unit.gd') diff --git a/stage/player_unit.gd b/stage/player_unit.gd new file mode 100644 index 0000000..ca3565a --- /dev/null +++ b/stage/player_unit.gd @@ -0,0 +1,40 @@ +class_name PlayerUnit +extends Node2D + + +@export var direction: Corner = CORNER_BOTTOM_RIGHT +@export var max_hp := 0 +@export var current_team: String + +var current_hp := 0: + set(value): + current_hp = value + $Label.text = str(value) + + +func _ready() -> void: + current_hp = max_hp + $Label.visible = false + + var grid_selector := get_tree().get_first_node_in_group("grid_selector") as GridSelector + grid_selector.hover_enter.connect(func(node: Node2D): + $Label.visible = node == self + ) + grid_selector.hover_exit.connect(func(): + $Label.visible = false + ) + + +func _process(_delta: float) -> void: + if direction == CORNER_TOP_LEFT: + $AnimatedSprite2D.play("top_left") + $AnimatedSprite2D.flip_h = false + elif direction == CORNER_TOP_RIGHT: + $AnimatedSprite2D.play("top_left") + $AnimatedSprite2D.flip_h = true + elif direction == CORNER_BOTTOM_LEFT: + $AnimatedSprite2D.play("bottom_right") + $AnimatedSprite2D.flip_h = true + elif direction == CORNER_TOP_LEFT: + $AnimatedSprite2D.play("bottom_right") + $AnimatedSprite2D.flip_h = false -- cgit v1.2.3