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

85 lines
1.8 KiB
Lua
Raw Normal View History

local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
local HeroFighter = FighterParent:extend()
local StatusBar = require "scenes.battlesystem.gui.statusbar"
2020-07-19 21:41:14 +02:00
local SelectionSystem = require "scenes.battlesystem.controllers.fighters.systems.selection"
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)
self.statusbar = StatusBar(self)
2020-07-19 21:41:14 +02:00
self.currentAction = ""
self.actionArgument = ""
self.target = nil
self.selection = nil
end
function HeroFighter:updateAssets(dt)
self.statusbar:update(dt)
end
function HeroFighter:update(dt)
2020-07-19 21:41:14 +02:00
if (self.selection ~= nil) then
self.selection:update(dt)
end
end
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()
core.debug:print("cbs/heroFighter", "launching the action menu")
2020-07-19 21:41:14 +02:00
self.currentAction = ""
self.actionArgument = ""
self.target = nil
self.turnSystem.scene.menu:set( self )
end
function HeroFighter:endAction()
end
-- 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
-- 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
return HeroFighter