-
Notifications
You must be signed in to change notification settings - Fork 25
/
animation.lua
200 lines (187 loc) · 3.58 KB
/
animation.lua
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
local ani_to_framecount = {
attack = 13,
buff = 13,
death = 13,
defend = 13,
life_buff = 13,
trigger_attack = 13,
trigger_defend = 13,
trigger_start = 13,
trigger_spell = 13,
trigger_vanish = 13,
}
local ani_to_dx = {
}
local ani_to_dy = {
}
local ani_coin_blue = {
{"gray", 42},
{"gray", 85},
{"gray", 127},
{"gray", 170},
{"gray", 212},
{"gray", 255},
{"gray", 255},
{"gray", 255},
{"start0", 255},
{"start1", 255},
{"red_tl", 255},
{"red_4l2", 255},
{"red", 255},
{"red_tr", 255},
{"blue_tl", 255},
{"blue", 255},
{"blue_tr", 255},
{"red_tl", 255},
{"red", 255},
{"red_tr", 255},
{"blue_tl", 255},
{"blue_4l2", 255},
{"blue", 255},
{"blue_mr", 255},
{"blue_tr", 255},
{"red_tl", 255},
{"red_2l0", 255},
{"red_2l1", 255},
{"red", 255},
{"red_3r0", 255},
{"red_3r1", 255},
{"red_3r2", 255},
{"red_tr", 255},
{"blue_tl", 255},
{"blue_4l0", 255},
{"blue_4l1", 255},
{"blue_4l2", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 255},
{"blue", 201},
{"blue", 153},
{"blue", 102},
{"blue", 51}
}
local ani_coin_red = {
{"gray", 42},
{"gray", 85},
{"gray", 127},
{"gray", 170},
{"gray", 212},
{"gray", 255},
{"gray", 255},
{"gray", 255},
{"start0", 255},
{"start1", 255},
{"blue_tl", 255},
{"blue_4l2", 255},
{"blue", 255},
{"blue_tr", 255},
{"red_tl", 255},
{"red", 255},
{"red_tr", 255},
{"blue_tl", 255},
{"blue", 255},
{"blue_tr", 255},
{"red_tl", 255},
{"red_4l2", 255},
{"red", 255},
{"red_mr", 255},
{"red_tr", 255},
{"blue_tl", 255},
{"blue_2l0", 255},
{"blue_2l1", 255},
{"blue", 255},
{"blue_3r0", 255},
{"blue_3r1", 255},
{"blue_3r2", 255},
{"blue_tr", 255},
{"red_tl", 255},
{"red_4l0", 255},
{"red_4l1", 255},
{"red_4l2", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 255},
{"red", 201},
{"red", 153},
{"red", 102},
{"red", 51}
}
function Game:set_coin_animation(player)
if player == 1 then
self.coin_anim = ani_coin_red
else
self.coin_anim = ani_coin_blue
end
self.coin_flip = true
end
function Game:await_coin_animation()
local keep_waiting = true
local players = {self.P1, self.P2}
while keep_waiting do
if self.coin_flip then
wait(1)
else
keep_waiting = false
end
end
end
function Game:set_animation(kind, player_idx, slot)
local players = {self.P1, self.P2}
players[player_idx].animation[slot] = {kind=kind,
framecount=ani_to_framecount[kind], frame = 0,
dx = ani_to_dx[kind] or 0, dy = ani_to_dy[kind] or 0,}
play_sound(kind)
end
function Game:await_animations()
self:await_target_animations()
end
function Game:set_buff_animation(buff, player_idx, slot)
local players = {self.P1, self.P2}
local t = {}
for k,v in pairs(buff) do
t[k] = v
end
t.frame = 0
players[player_idx].buff_animation[slot] = t
end
function Game:await_buff_animations()
wait(22)
end
function Game:await_target_animations()
local keep_waiting = true
local players = {self.P1, self.P2}
while keep_waiting do
local any_animations = false
for _,p in pairs(players) do
for i=0,5 do
if p.animation[i] then
any_animations = true
end
end
end
if any_animations then
wait(1)
else
keep_waiting = false
end
end
wait(5)
end