forked from Moe-/Bacteria
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobj.formation.lua
More file actions
65 lines (47 loc) · 1.53 KB
/
Copy pathobj.formation.lua
File metadata and controls
65 lines (47 loc) · 1.53 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
cFormation = CreateClass()
function cFormation:Init()
self.enemies = {}
self.constraints = {}
end
function cFormation:addEnemy(enemy, offsetX, offsetY)
table.insert(self.enemies, {enemy = enemy, offsetX = offsetX, offsetY = offsetY})
end
function cFormation:addConstraint(constraint)
table.insert(self.constraints, constraint)
end
function cFormation:maySpawn()
local maySpawn = true
if (self.min_total_spawned and gFormationsSpawnedTotal < self.min_total_spawned) then return false end
if (self.min_spawned_since_boss and gFormationsSpawnedSinceBoss < self.min_spawned_since_boss) then return false end
for k,v in pairs(self.constraints) do
if (v:maySpawn() == false) then
maySpawn = false
break
end
end
return maySpawn
end
-- FormationConstraints following
cFormationConstraintNumberSpawns = CreateClass()
function cFormationConstraintNumberSpawns:Init(formation, numberOfSpawns)
self.numberOfSpawns = numberOfSpawns
end
function cFormationConstraintNumberSpawns:maySpawn()
local count = 0
for k,v in pairs(gFormationsHistory) do
count = count + v
end
return (count >= self.numberOfSpawns)
end
cFormationConstraintSpawnOnce = CreateClass()
function cFormationConstraintSpawnOnce:Init(formation)
self.formation = formation
end
function cFormationConstraintSpawnOnce:maySpawn()
for k,v in pairs(gFormationsHistory) do
if (k == self.formation) then -- already was here
return false
end
end
return true
end