forked from sharpobject/sgre
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanimation.lua
More file actions
67 lines (60 loc) · 1.31 KB
/
Copy pathanimation.lua
File metadata and controls
67 lines (60 loc) · 1.31 KB
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
local ani_to_framecount = {
attack = 9,
buff = 10,
death = 9,
defend = 11,
life_buff = 14,
trigger_attack = 9,
trigger_defend = 7,
trigger_start = 9,
trigger_spell = 13,
spell_death = 13,
}
local ani_to_dx = {
trigger_attack = 1,
trigger_start = 3,
}
local ani_to_dy = {
trigger_attack = 4,
}
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,}
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(2)
end