-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDescriptionManager.gd
61 lines (51 loc) · 1.28 KB
/
DescriptionManager.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
class_name DescriptionManager extends Node
@export var interaction : InteractionManager
@export var uiArray : Array[Label]
@export var dur : float
var elapsed
var moving = false
var current_opacity = 0.0
var next_opacity = 1.0
var started = false
func _ready():
HideText()
func _process(delta):
LerpText()
CheckInteraction()
func HideText():
for i in range(uiArray.size()):
uiArray[i].modulate.a = 0
pass
func CheckInteraction():
if (interaction.activeParent != null):
var childArray = interaction.activeParent.get_children()
var found = false
for i in range(childArray.size()):
if (childArray[i] is PickupIndicator):
found = true
return
if (!found && started):
EndLerp()
started = false
func BeginLerp():
started = true
current_opacity = uiArray[0].modulate.a
next_opacity = 1.0
elapsed = 0.0
moving = true
pass
func EndLerp():
current_opacity = uiArray[0].modulate.a
next_opacity = 0.0
elapsed = 0.0
moving = true
pass
func LerpText():
if (moving):
elapsed += get_process_delta_time()
var c = clampf(elapsed / dur, 0.0, 1.0)
var opacity = lerp(current_opacity, next_opacity, c)
for i in range(uiArray.size()):
var color = Color(uiArray[i].modulate.r, uiArray[i].modulate.g, uiArray[i].modulate.b, opacity)
uiArray[i].modulate = color
pass