summaryrefslogtreecommitdiff
path: root/stage/player_unit.gd
diff options
context:
space:
mode:
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