-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProjectileManager.lua
More file actions
59 lines (51 loc) · 1.79 KB
/
ProjectileManager.lua
File metadata and controls
59 lines (51 loc) · 1.79 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
ProjectileManager = Class{__includes = BaseState}
function ProjectileManager:init(name,team,xoffset,yoffset,graphics,imagesInfo)
self.projectileCount = name['projectileCount'] or 1
self.projectiles = {}
for i=1,self.projectileCount do
local imagePath
local nameString = 'projectile' .. tostring(i)
if name[nameString] then
imagePath = 'Graphics/' .. name[nameString ]
self.projectiles[i] = Projectile(team,xoffset,yoffset,name['range'..tostring(i)] or name['range'],name[nameString],imagePath)
else
nameString = 'projectile1'
imagePath = 'Graphics/' .. name[nameString]
self.projectiles[i] = Projectile(team,xoffset,yoffset,name['range'],name[nameString],imagePath)
end
if graphics[imagePath] then
self.projectiles[i]:init2(graphics[imagePath])
else
if imagesInfo[imagePath] then
table.insert(imagesInfo[imagePath][1],self.projectiles[i])
else
imagesInfo[imagePath] = {{self.projectiles[i]}, false}
end
end
end
end
function ProjectileManager:fire(projectile,card,card2)
self.projectiles[projectile]:fire(card,card2)
end
function ProjectileManager:fireall(card,card2)
for k, pair in pairs(self.projectiles) do
pair:fire(card,card2)
end
end
function ProjectileManager:update(dt)
for k, pair in pairs(self.projectiles) do
pair:update(dt)
end
end
function ProjectileManager:hideProjectiles(graphics)
for k, pair in pairs(self.projectiles) do
pair:hideProjectile(graphics)
end
end
function ProjectileManager:render(graphics)
if graphics then
for k, pair in pairs(self.projectiles) do
pair:render(graphics)
end
end
end