-
Notifications
You must be signed in to change notification settings - Fork 0
/
block.gd
125 lines (100 loc) · 2.22 KB
/
block.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
extends Node2D
@export var number = 2
signal animation_start
signal animation_end
# Called when the node enters the scene tree for the first time.
func _ready():
set_number(number)
func set_number(num):
number = num
$Number.text = str(number)
var gradient_data := {
0.0: "#A6CCF5",
1.0: "#A6CCF5",
}
if (number == 2):
gradient_data = {
0.0: "#ffada6",
0.4: "#FE1E3C"
}
elif (number == 3):
gradient_data = {
0.0: "#FFD0A1",
0.4: "#FF7F00"
}
elif (number == 4):
gradient_data = {
0.0: "#fdffd7",
0.4: "#FFFF00",
}
elif (number == 5):
gradient_data = {
0.0: "#B4E0B4",
0.4: "#32cd32",
}
elif (number == 6):
gradient_data = {
0.0: "#87ceeb",
0.4: "#36B7EB",
}
elif (number == 7):
gradient_data = {
0.0: "#FFC0CB",
0.4: "#FF7D93",
}
elif (number == 8):
gradient_data = {
0.0: "#a083c4",
0.4: "#8754C4",
}
elif (number == 0):
gradient_data = {
0.0: "#737373",
0.4: "#333",
}
$Number.text = ""
else:
$Number.text = ""
var gradient := Gradient.new()
gradient.offsets = gradient_data.keys()
gradient.colors = gradient_data.values()
var gradient_texture := GradientTexture2D.new()
gradient_texture.gradient = gradient
gradient_texture.width = 60
gradient_texture.height =60
gradient.set_offset(0, 0.01)
gradient.set_offset(1, 0.7)
$TextureRect.texture = gradient_texture
func play_fall_in():
animation_start.emit()
var final_y = self.position.y
self.position.y = 0
while (self.position.y < final_y):
self.position.y += 20
await get_tree().create_timer(0.001).timeout
$HitSound.play()
animation_end.emit()
func show_pop_number(number):
var pop_string = "+%s"
if number == 0:
number = 10
$PopNumber.text = pop_string % number
$PopNumber.show()
await get_tree().create_timer(1).timeout
$PopNumber.hide()
func get_number():
return number
#if (number == 2):
# $ColorRect.color = "#ff0000"
#elif (number == 3):
# $ColorRect.color = "#FFA500"
#elif (number == 4):
# $ColorRect.color = "#FFC0CB"
#elif (number == 5):
# $ColorRect.color = "#800080"
#elif (number == 6):
# $ColorRect.color = "#00FF00"
#elif (number == 7):
# $ColorRect.color = "#FFFF00"
#elif (number == 8):
# $ColorRect.color = "#21acc5"