summaryrefslogtreecommitdiff
path: root/unit/unit.gd
blob: 066aee6dcb53d027bb800dc7c1e74ca368193aa7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class_name Unit
extends Node2D


@export var unit_data: UnitData

@export var current_team: String
@export var current_player: Player

var current_hp := 0:
	set(value):
		current_hp = value
		$Label.text = str(value)


func _ready() -> void:
	current_hp = unit_data.health
	
	$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
	)