sonic-radiance/sonic-radiance.love/scenes/battlesystem/controllers/fighters/villain.lua

98 lines
2.5 KiB
Lua
Raw Normal View History

local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
local VillainFighter = FighterParent:extend()
local SimpleHPBar = require "game.modules.gui.simplehpbar"
local EnnemyAction = require "scenes.battlesystem.controllers.fighters.systems.ennemyaction"
local behaviourList = require "scenes.battlesystem.controllers.fighters.systems.behaviours"
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;
function VillainFighter:new(owner, category, ennemy, id)
self.name = ennemy
self.category = category
self.super.new(self, owner, false, id)
self.hpbar = SimpleHPBar(self.abstract.hp)
self.isBoss = false
end
function VillainFighter:updateAssets(dt)
self.hpbar:update(dt)
end
function VillainFighter:getAbstract()
return game.ennemies:getEnnemyData(self.category, self.name)
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()
core.debug:print("cbs/villainFighter", "choosing an action")
self.action = nil
self:selectAction()
end
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
end
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
function VillainFighter:endAction()
end
function VillainFighter:setBonus(pvFactor, statFactor)
self.abstract:setBonus(pvFactor, statFactor)
end
-- LIFE FUNCTIONS
function VillainFighter:setHP(value, relative)
VillainFighter.super.setHP(self, value, relative)
self.hpbar:setHP(self.abstract.hp)
end
-- DRAW FUNCTIONS
function VillainFighter:drawIcon(x, y)
2020-08-05 11:54:39 +02:00
self.assets.images["badnicsIcon"]:draw(x-1, y-2)
self.assets.fonts["hudnbrs_small"]:print(self.id, x+10, y+8)
end
function VillainFighter:drawHUD(x, y)
if (not self.isBoss) then
self.hpbar:draw(x, y)
end
end
return VillainFighter