-
Notifications
You must be signed in to change notification settings - Fork 1
/
HUD.gd
33 lines (21 loc) · 849 Bytes
/
HUD.gd
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
28
29
30
31
32
33
extends MarginContainer
onready var tween = $Tween
onready var bar = $Bars/LightBar/TextureProgress
var animated_light = 0
func _ready():
var lantern_power_max = $"../../.".lantern_power_max
bar.max_value = lantern_power_max
update_light(lantern_power_max)
func _on_Level_lanternPowerChanged(lantern_power):
update_light(lantern_power)
func update_light(new_value):
tween.interpolate_property(self, "animated_light", animated_light, new_value, 0.1, Tween.EASE_IN, Tween.EASE_IN)
if not tween.is_active():
tween.start()
func _process(delta):
var round_value = round(animated_light)
bar.value = round_value
func _on_Player_died():
var start_color = Color(1.0, 1.0, 1.0, 1.0)
var end_color = Color(1.0, 1.0, 1.0, 0.0)
tween.interpolate_property(self, "modulate", start_color, end_color, 1.0, Tween.TRANS_LINEAR, Tween.EASE_IN)