summaryrefslogtreecommitdiff
path: root/stage/player_unit.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2025-02-12 20:05:59 +0100
committerDaniel Weipert <git@mail.dweipert.de>2025-02-12 20:05:59 +0100
commit218748f67a6a6b35efc4a732ad11426d0f528709 (patch)
treee58504dd758ce6525844872007221cda2a8b6926 /stage/player_unit.gd
parentf6c81b065cf4d7f1302a50f2f72cfab32204a1ec (diff)
next commitHEADmain
Diffstat (limited to 'stage/player_unit.gd')
-rw-r--r--stage/player_unit.gd40
1 files changed, 40 insertions, 0 deletions
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