2020-07-19 15:07:35 +02:00
|
|
|
local FighterControllerParent = require "scenes.battlesystem.controllers.parent"
|
|
|
|
local EnnemyController = FighterControllerParent:extend()
|
|
|
|
|
|
|
|
local Villain = require "scenes.battlesystem.controllers.fighters.villain"
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
local battleutils = require "game.utils.battle"
|
|
|
|
|
|
|
|
function EnnemyController:new(owner, battleData)
|
2020-07-19 15:07:35 +02:00
|
|
|
self.super.new(self, owner)
|
2020-08-04 17:50:03 +02:00
|
|
|
self:initVillains(battleData)
|
|
|
|
end
|
|
|
|
|
|
|
|
function EnnemyController:initVillains(battleData)
|
|
|
|
for i,ennemyBaseData in ipairs(battleData.ennemies) do
|
|
|
|
local ennData = battleutils.getEnnemyData(ennemyBaseData)
|
|
|
|
if (ennData.type == "normal") then
|
|
|
|
self:addVillain(ennData)
|
|
|
|
elseif (ennData.type == "boss") then
|
|
|
|
self:addBoss(ennData)
|
|
|
|
else
|
|
|
|
print("unknown type " .. ennData.type)
|
|
|
|
end
|
|
|
|
end
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function EnnemyController:addVillain(ennData)
|
|
|
|
for i=1, ennData.number do
|
|
|
|
self:add(Villain(self, ennData.category, ennData.name, self:count() + 1))
|
|
|
|
end
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function EnnemyController:addBoss(ennData)
|
|
|
|
local boss = Villain(self, ennData.category, ennData.name, self:count() + 1)
|
|
|
|
boss:setBonus(ennData.pvFactor, ennData.statFactor)
|
|
|
|
boss.isBoss = true
|
|
|
|
boss.cheapEffect = ennData.cheapEffect
|
|
|
|
self:add(boss)
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return EnnemyController
|