the-crypt/ui/PlayerStats.gd

31 lines
754 B
GDScript3
Raw Normal View History

2020-07-17 19:18:59 -05:00
extends CanvasLayer
2020-07-18 00:07:44 -05:00
onready var Hearts: TextureProgress = $"Player UI Frame 2/Hearts"
onready var Energybar: TextureProgress = $"Player UI Frame 2/Energy"
2020-07-17 19:18:59 -05:00
onready var Regen: Timer = $Regen
var health = 3 setget set_health, get_health
2020-07-18 00:07:44 -05:00
var energy = 5 setget set_energy, get_energy
2020-07-17 19:18:59 -05:00
func _on_Regen_timeout():
set_energy(get_energy() + 1)
func _process(delta):
if get_energy() < Energybar.max_value and Regen.is_stopped():
Regen.start()
func set_health(value):
Hearts.value = clamp(value, Hearts.min_value, Hearts.max_value)
func get_health():
return Hearts.value
func set_energy(value):
Energybar.value = clamp(value, Energybar.min_value, Energybar.max_value)
func get_energy():
return Energybar.value
func interrupt_regen():
Regen.start()