2020-07-19 15:07:35 +02:00
|
|
|
local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
|
|
|
local VillainFighter = FighterParent:extend()
|
|
|
|
|
2020-08-03 09:11:31 +02:00
|
|
|
local SimpleHPBar = require "game.modules.gui.simplehpbar"
|
2020-08-05 09:25:38 +02:00
|
|
|
local EnnemyAction = require "scenes.battlesystem.controllers.fighters.systems.ennemyaction"
|
|
|
|
local behaviourList = require "scenes.battlesystem.controllers.fighters.systems.behaviours"
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
|
2020-07-19 21:41:14 +02:00
|
|
|
local POSITIONS = {1, 3, 5}
|
2020-07-25 17:50:44 +02:00
|
|
|
local ENNEMY_LINE = 11;
|
2020-07-19 15:07:35 +02:00
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function VillainFighter:new(owner, category, ennemy, id)
|
2020-07-19 15:07:35 +02:00
|
|
|
self.name = ennemy
|
2020-08-04 17:50:03 +02:00
|
|
|
self.category = category
|
2020-07-19 15:07:35 +02:00
|
|
|
self.super.new(self, owner, false, id)
|
2020-07-19 16:20:57 +02:00
|
|
|
|
|
|
|
self.hpbar = SimpleHPBar(self.abstract.hp)
|
2020-08-04 17:50:03 +02:00
|
|
|
self.isBoss = false
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
function VillainFighter:updateAssets(dt)
|
|
|
|
self.hpbar:update(dt)
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function VillainFighter:getAbstract()
|
2020-08-04 17:50:03 +02:00
|
|
|
return game.ennemies:getEnnemyData(self.category, self.name)
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function VillainFighter:createActor()
|
|
|
|
local x, y = ENNEMY_LINE, POSITIONS[self.id]
|
|
|
|
return self.world.obj.Ennemy(self.world, x, y, self)
|
|
|
|
end
|
|
|
|
|
|
|
|
function VillainFighter:startAction()
|
2020-08-05 09:25:38 +02:00
|
|
|
core.debug:print("cbs/villainFighter", "choosing an action")
|
|
|
|
self.action = nil
|
|
|
|
self:selectAction()
|
|
|
|
end
|
2020-07-19 15:07:35 +02:00
|
|
|
|
2020-08-05 09:25:38 +02:00
|
|
|
function VillainFighter:selectAction()
|
|
|
|
if (#self.abstract.skills < 1) then
|
|
|
|
self:finishAction()
|
|
|
|
else
|
|
|
|
local skillId = math.floor(math.random(1, #self.abstract.skills))
|
|
|
|
local skill = self.abstract.skills[skillId]
|
|
|
|
self.action = EnnemyAction(self, skill)
|
|
|
|
self:verifyTargets()
|
|
|
|
end
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-08-05 09:25:38 +02:00
|
|
|
function VillainFighter:verifyTargets()
|
|
|
|
local needTarget, targetEnnemies = self.action:needTarget()
|
|
|
|
|
|
|
|
if (needTarget) then
|
|
|
|
if (targetEnnemies) then
|
|
|
|
--fighter, skilldata, targetList
|
|
|
|
local Behaviour = behaviourList[self.abstract.data.behaviour]
|
|
|
|
local behav = Behaviour(self, self.action:getData(), self.owner.turnSystem.player:getTargets(true))
|
|
|
|
self.action:setTarget(behav:getTarget())
|
|
|
|
self.action:start()
|
|
|
|
else
|
|
|
|
--self.selection = SelectionSystem(self, self.owner, false)
|
|
|
|
end
|
|
|
|
else
|
|
|
|
self.action:start()
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function VillainFighter:endAction()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-07-25 08:44:03 +02:00
|
|
|
function FighterParent:die()
|
|
|
|
self.isAlive = false
|
|
|
|
self.actor:destroy()
|
|
|
|
end
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
function VillainFighter:setBonus(pvFactor, statFactor)
|
|
|
|
self.abstract:setBonus(pvFactor, statFactor)
|
|
|
|
end
|
|
|
|
|
2020-07-24 19:49:24 +02:00
|
|
|
-- LIFE FUNCTIONS
|
|
|
|
function VillainFighter:setHP(value, relative)
|
|
|
|
VillainFighter.super.setHP(self, value, relative)
|
|
|
|
self.hpbar:setHP(self.abstract.hp)
|
|
|
|
end
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
-- DRAW FUNCTIONS
|
|
|
|
function VillainFighter:drawIcon(x, y)
|
|
|
|
love.graphics.setColor(1, 0, 0, 1)
|
|
|
|
love.graphics.rectangle("fill", x, y, 16, 16)
|
|
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
|
|
end
|
|
|
|
|
|
|
|
function VillainFighter:drawHUD(x, y)
|
2020-08-04 17:50:03 +02:00
|
|
|
if (not self.isBoss) then
|
|
|
|
self.hpbar:draw(x, y)
|
|
|
|
end
|
2020-07-19 16:20:57 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
return VillainFighter
|