-
Notifications
You must be signed in to change notification settings - Fork 1
/
ThoughtBubble.gd
138 lines (121 loc) · 3.33 KB
/
ThoughtBubble.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
extends Sprite
class_name ThoughtBubble
var frame_timer = 0;
var frame_timer_max = 0.4;
enum State { In, Out, Nominal, Hide };
var state = State.Hide;
var rising = true;
var ticks = 10000;
# REFACTOR: same as in TimeBubble.gd
var time_colour = 0;
var time_colours = [Color("808080"), Color("B200FF"), Color("5400FF"), Color("FF00DC"),
Color("FF0000"), Color("0094FF"), Color("A9F05F"), Color("404040"),
Color("00FFFF"), Color("FF6A00"), Color("FFD800"), Color("FFFFFF")];
var label = null;
var shadow_labels = [];
var alpha = 0.85;
enum TimeColour {
Gray,
Purple,
Blurple,
Magenta,
Red,
Blue,
Green,
Void,
Cyan,
Orange,
Yellow,
White,
}
func poof_in() -> void:
if (state == State.In or state == State.Nominal):
return;
self.self_modulate.a = alpha;
#label.modulate.a = 1;
self.texture = preload("res://assets/PoofAwayThought1.png");
state = State.In;
rising = false;
frame = 2;
frame_timer = 0;
func poof_out() -> void:
if (state == State.Out or state == State.Hide):
return;
self.self_modulate.a = alpha;
#label.modulate.a = 1;
self.texture = preload("res://assets/PoofAwayThought1.png");
state = State.Out;
rising = true;
frame = 0;
frame_timer = 0;
func nominal() -> void:
self.self_modulate.a = alpha;
#label.modulate.a = 1;
self.texture = preload("res://assets/Thought1.png");
state = State.Nominal;
rising = true;
frame = 0;
frame_timer = 0;
func hide() -> void:
self.self_modulate.a = 0;
#label.modulate.a = 1;
state = State.Hide;
func update_time_colour(time_colour: int) -> void:
self.time_colour = time_colour;
label.add_color_override("font_color", time_colours[time_colour]);
func initialize(time_colour: int, ticks: int) -> void:
self.time_colour = time_colour;
self.ticks = ticks;
self.hframes = 3;
self.vframes = 1;
var offsets = [Vector2.UP, Vector2.DOWN, Vector2.LEFT, Vector2.RIGHT];
for offset in offsets:
var sl = Label.new();
shadow_labels.append(sl);
sl.align = Label.ALIGN_CENTER;
sl.rect_position = Vector2(-24, -7) + offset;
sl.rect_size = Vector2(48, 24);
self.add_child(sl);
sl.text = str(self.ticks);
sl.theme = preload("res://DefaultTheme.tres");
sl.add_color_override("font_color", Color(0, 0, 0, 1));
label = Label.new();
label.align = Label.ALIGN_CENTER;
label.rect_position = Vector2(-24, -7);
label.rect_size = Vector2(48, 24);
self.add_child(label);
label.text = str(self.ticks);
label.theme = preload("res://DefaultTheme.tres");
label.add_color_override("font_color", time_colours[time_colour]);
#label.add_color_override("font_color_shadow", Color(0, 0, 0, 1));
#label.add_constant_override("shadow_as_outline", 1);
poof_in();
func update_ticks(ticks: int) -> void:
self.ticks = ticks;
label.text = str(self.ticks);
for sl in shadow_labels:
sl.text = label.text;
# Called when the node enters the scene tree for the first time.
#func _ready() -> void:
# pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
frame_timer += delta;
if (frame_timer > frame_timer_max):
frame_timer -= frame_timer_max;
if rising:
if (frame < self.hframes - 1):
frame += 1;
else:
if (state == State.Out):
hide();
else:
rising = false;
else:
if (frame > 0):
frame -= 1;
else:
if (state == State.In):
nominal();
else:
rising = true;