2020-07-19 15:07:35 +02:00
|
|
|
local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
|
|
|
local HeroFighter = FighterParent:extend()
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
local StatusBar = require "scenes.battlesystem.gui.statusbar"
|
2020-07-19 21:41:14 +02:00
|
|
|
local SelectionSystem = require "scenes.battlesystem.controllers.fighters.systems.selection"
|
2020-07-19 16:20:57 +02:00
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
local POSITIONS = {3, 1, 5}
|
|
|
|
local HEROES_LINE = 3;
|
|
|
|
|
|
|
|
function HeroFighter:new(owner, character, id)
|
|
|
|
self.name = character
|
|
|
|
self.super.new(self, owner, true, id)
|
2020-07-19 16:20:57 +02:00
|
|
|
|
|
|
|
self.statusbar = StatusBar(self)
|
2020-07-19 21:41:14 +02:00
|
|
|
|
|
|
|
self.currentAction = ""
|
|
|
|
self.actionArgument = ""
|
|
|
|
self.target = nil
|
|
|
|
|
|
|
|
self.selection = nil
|
2020-07-19 16:20:57 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:updateAssets(dt)
|
|
|
|
self.statusbar:update(dt)
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 18:09:53 +02:00
|
|
|
function HeroFighter:update(dt)
|
2020-07-19 21:41:14 +02:00
|
|
|
if (self.selection ~= nil) then
|
|
|
|
self.selection:update(dt)
|
|
|
|
end
|
2020-07-19 18:09:53 +02:00
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
function HeroFighter:getAbstract()
|
|
|
|
return game.characters.list[self.name]
|
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:createActor()
|
|
|
|
local x, y = HEROES_LINE, POSITIONS[self.id]
|
|
|
|
return self.world.obj.Hero(self.world, x, y, self)
|
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:startAction()
|
2020-07-19 18:09:53 +02:00
|
|
|
core.debug:print("cbs/heroFighter", "launching the action menu")
|
2020-07-19 21:41:14 +02:00
|
|
|
self.currentAction = ""
|
|
|
|
self.actionArgument = ""
|
|
|
|
self.target = nil
|
2020-07-19 18:09:53 +02:00
|
|
|
self.turnSystem.scene.menu:set( self )
|
2020-07-19 15:07:35 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:endAction()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2020-07-19 18:09:53 +02:00
|
|
|
-- Basic actions
|
|
|
|
function HeroFighter:doNothing()
|
|
|
|
self:setInactive()
|
|
|
|
end
|
|
|
|
|
2020-07-19 21:41:14 +02:00
|
|
|
function HeroFighter:attack()
|
|
|
|
self.currentAction = "attack"
|
|
|
|
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies)
|
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:receiveTarget(target)
|
|
|
|
self.selection = nil
|
|
|
|
self:setInactive()
|
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:goBackToMenu()
|
|
|
|
self.owner.turnSystem.scene.menusystem:activate()
|
|
|
|
self.selection = nil
|
|
|
|
end
|
|
|
|
|
2020-07-19 16:20:57 +02:00
|
|
|
-- DRAW FUNCTIONS
|
|
|
|
function HeroFighter:drawIcon(x, y)
|
|
|
|
local iconID = 1
|
|
|
|
self.assets.tileset["charicons"]:drawTile(iconID, x, y)
|
|
|
|
end
|
|
|
|
|
|
|
|
function HeroFighter:drawHUD()
|
|
|
|
self.statusbar:draw()
|
|
|
|
end
|
|
|
|
|
2020-07-19 15:07:35 +02:00
|
|
|
return HeroFighter
|