-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStats.gd
More file actions
27 lines (21 loc) · 566 Bytes
/
Stats.gd
File metadata and controls
27 lines (21 loc) · 566 Bytes
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
extends Node
# Export
## Health
export(int) var max_health = 1 setget set_max_health
# Variables
var health = max_health setget set_health
# Signals
signal no_health # Creates a signal for 0 health
signal health_changed(value)
signal max_health_changed(value)
func _ready():
self.health = max_health
func set_health(value):
health = value
emit_signal("health_changed", health)
if health <= 0:
emit_signal("no_health")
func set_max_health(value):
max_health = value
self.health = min(health, max_health)
emit_signal("max_health_changed", max_health)