chore: first round of actor cleanup
There is still a lot of work though
This commit is contained in:
parent
a41aabbd7d
commit
6bca41d794
3 changed files with 28 additions and 60 deletions
|
@ -3,10 +3,10 @@ local Ennemy = Battler:extend()
|
||||||
|
|
||||||
local gui = require "game.modules.gui"
|
local gui = require "game.modules.gui"
|
||||||
|
|
||||||
function Ennemy:new(world, x, y, id, number)
|
function Ennemy:new(world, x, y, owner)
|
||||||
Ennemy.super.new(self, world, x, y, 0)
|
Ennemy.super.new(self, world, x, y, 0)
|
||||||
self.isEnnemy = true
|
self.isEnnemy = true
|
||||||
self.ennid = id or "motobug"
|
self.owner = owner
|
||||||
|
|
||||||
self.actionPerTurn = 2
|
self.actionPerTurn = 2
|
||||||
|
|
||||||
|
@ -18,31 +18,16 @@ function Ennemy:new(world, x, y, id, number)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Ennemy:draw()
|
function Ennemy:draw()
|
||||||
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
local x, y = self.world.map:gridToPixel(self.x, self.y, true)
|
||||||
love.graphics.setColor(1, 0, 0, 1)
|
love.graphics.setColor(1, 0, 0, 1)
|
||||||
love.graphics.rectangle("fill", x - 8, y - 32, 16, 32)
|
love.graphics.rectangle("fill", x - 8, y - 32, 16, 32)
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
end
|
|
||||||
|
|
||||||
function Ennemy:drawHUD()
|
self.owner:drawHUD(x - 14, y - 38)
|
||||||
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
|
||||||
love.graphics.setColor(0, 0, 0, 1)
|
|
||||||
gui.drawBar(x - 14, y - 38, 26, 4)
|
|
||||||
love.graphics.setColor(248/255, 160/255, 0, 1)
|
|
||||||
local bar = math.floor(24 * (self.shownHP / self.data.stats.hpmax))
|
|
||||||
gui.drawBar(x - 14, y - 37, bar, 2)
|
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function Ennemy: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
|
end
|
||||||
|
|
||||||
function Ennemy:receiveDatas()
|
function Ennemy:receiveDatas()
|
||||||
self.data = game.ennemies:getEnnemyData(self.ennid)
|
self.data = game.ennemies:getEnnemyData(self.owner.name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Ennemy:setHP(value, relative)
|
function Ennemy:setHP(value, relative)
|
||||||
|
|
|
@ -2,28 +2,26 @@ local Battler = require("scenes.battlesystem.actors.battler")
|
||||||
local Hero = Battler:extend()
|
local Hero = Battler:extend()
|
||||||
|
|
||||||
local gui = require "game.modules.gui"
|
local gui = require "game.modules.gui"
|
||||||
local StatusBar = require "scenes.battlesystem.gui.statusbar"
|
|
||||||
|
|
||||||
local ChoregraphySystem = require "scenes.battlesystem.actors.systems.choregraphy"
|
local ChoregraphySystem = require "scenes.battlesystem.actors.systems.choregraphy"
|
||||||
|
|
||||||
-- INIT FUNCTIONS
|
-- INIT FUNCTIONS
|
||||||
-- Initialize the hero
|
-- Initialize the hero
|
||||||
|
|
||||||
function Hero:new(world, x, y, charid, charnumber)
|
function Hero:new(world, x, y, owner, charnumber)
|
||||||
Hero.super.new(self, world, x, y, 0)
|
Hero.super.new(self, world, x, y, 0)
|
||||||
self.isHero = true
|
self.isHero = true
|
||||||
|
self.owner = owner
|
||||||
|
|
||||||
self:initMovementSystem()
|
self:initMovementSystem()
|
||||||
|
|
||||||
self:initCharacter(charid)
|
--self:initCharacter(charid)
|
||||||
|
|
||||||
self:initSprite()
|
self:initSprite()
|
||||||
self:initChoregraphySystem()
|
self:initChoregraphySystem()
|
||||||
|
|
||||||
self:initVoices()
|
self:initVoices()
|
||||||
|
|
||||||
self.statusbar = StatusBar(self)
|
|
||||||
|
|
||||||
self.side = "heroes"
|
self.side = "heroes"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,37 +32,31 @@ function Hero:initCharacter(charid)
|
||||||
if charid == nil then
|
if charid == nil then
|
||||||
core.debug:error("FATAL ERROR: charid not set")
|
core.debug:error("FATAL ERROR: charid not set")
|
||||||
end
|
end
|
||||||
self.charid = charid
|
self.owner.name = charid
|
||||||
self.charnumber = charnumber or 1
|
|
||||||
|
|
||||||
self.hp = game.characters.list[self.charid].stats.hp
|
|
||||||
self.pp = game.characters.list[self.charid].stats.pp
|
|
||||||
|
|
||||||
self.actionPerTurn = game.characters.list[self.charid].turns
|
|
||||||
|
|
||||||
self.turnAction = nil
|
self.turnAction = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:getStats()
|
function Hero:getStats()
|
||||||
return game.characters.list[self.charid].stats
|
return game.characters.list[self.owner.name].stats
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:setHP(value, relative)
|
function Hero:setHP(value, relative)
|
||||||
if relative == true then
|
if relative == true then
|
||||||
value = game.characters.list[self.charid].stats.hp + value
|
value = game.characters.list[self.owner.name].stats.hp + value
|
||||||
end
|
end
|
||||||
|
|
||||||
game.characters.list[self.charid].stats.hp = value
|
game.characters.list[self.owner.name].stats.hp = value
|
||||||
self.statusbar:updateHP()
|
--self.statusbar:updateHP()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:setPP(value, relative)
|
function Hero:setPP(value, relative)
|
||||||
if relative == true then
|
if relative == true then
|
||||||
value = game.characters.list[self.charid].stats.pp + value
|
value = game.characters.list[self.owner.name].stats.pp + value
|
||||||
end
|
end
|
||||||
|
|
||||||
game.characters.list[self.charid].stats.pp = value
|
game.characters.list[self.owner.name].stats.pp = value
|
||||||
self.statusbar:updatePP()
|
--self.statusbar:updatePP()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,8 +64,8 @@ end
|
||||||
-- Function to set or unset activity to the character
|
-- Function to set or unset activity to the character
|
||||||
|
|
||||||
function Hero:setActive()
|
function Hero:setActive()
|
||||||
core.debug:print("cbs/hero", "hero " .. self.charid .. " is now active")
|
core.debug:print("cbs/hero", "hero " .. self.owner.name .. " is now active")
|
||||||
local gridsize = game.characters.list[self.charid].move
|
local gridsize = game.characters.list[self.owner.name].move
|
||||||
if (gridsize == nil) then
|
if (gridsize == nil) then
|
||||||
gridsize = 3
|
gridsize = 3
|
||||||
core.debug:warning("cbs/character", "move value is nil")
|
core.debug:warning("cbs/character", "move value is nil")
|
||||||
|
@ -110,7 +102,7 @@ function Hero:update(dt)
|
||||||
self.yprevious = self.y
|
self.yprevious = self.y
|
||||||
self.zprevious = self.z
|
self.zprevious = self.z
|
||||||
|
|
||||||
self.statusbar:update(dt)
|
--self.statusbar:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- MOVE FUNCTIONS
|
-- MOVE FUNCTIONS
|
||||||
|
@ -354,16 +346,16 @@ end
|
||||||
-- Getting info about the actor
|
-- Getting info about the actor
|
||||||
|
|
||||||
function Hero:getCharacterData()
|
function Hero:getCharacterData()
|
||||||
return game.characters.list[self.charid]
|
return game.characters.list[self.owner.name]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ASSETS FUNCTIONS
|
-- ASSETS FUNCTIONS
|
||||||
-- Load and play assets needed by the character
|
-- Load and play assets needed by the character
|
||||||
|
|
||||||
function Hero:initSprite()
|
function Hero:initSprite()
|
||||||
self.assets:addSprite(self.charid, "datas/gamedata/characters/" .. self.charid .. "/sprites")
|
self.assets:addSprite(self.owner.name, "datas/gamedata/characters/" .. self.owner.name .. "/sprites")
|
||||||
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
self.assets.sprites[self.owner.name]:setCustomSpeed(16)
|
||||||
self:setSprite(self.charid, 32, 48, true)
|
self:setSprite(self.owner.name, 32, 48, true)
|
||||||
self:cloneSprite()
|
self:cloneSprite()
|
||||||
self:changeAnimation("idle")
|
self:changeAnimation("idle")
|
||||||
end
|
end
|
||||||
|
@ -380,13 +372,13 @@ function Hero:initVoices()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:addVoiceEffect(name)
|
function Hero:addVoiceEffect(name)
|
||||||
local completename = self.charid .. "_" .. name
|
local completename = self.owner.name .. "_" .. name
|
||||||
local path = "datas/gamedata/characters/" .. self.charid .. "/voices/" .. name .. ".wav"
|
local path = "datas/gamedata/characters/" .. self.owner.name .. "/voices/" .. name .. ".wav"
|
||||||
self.assets:newSFX(completename, path)
|
self.assets:newSFX(completename, path)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:talk(name)
|
function Hero:talk(name)
|
||||||
local completename = self.charid .. "_" .. name
|
local completename = self.owner.name .. "_" .. name
|
||||||
self.assets.sfx[completename]:play()
|
self.assets.sfx[completename]:play()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -397,13 +389,4 @@ function Hero:draw()
|
||||||
self:drawSprite(0, -self.z)
|
self:drawSprite(0, -self.z)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:drawIcon(x, y)
|
|
||||||
local iconID = 1
|
|
||||||
self.assets.tileset["charicons"]:drawTile(iconID, x, y)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Hero:drawHUD()
|
|
||||||
self.statusbar:draw()
|
|
||||||
end
|
|
||||||
|
|
||||||
return Hero
|
return Hero
|
||||||
|
|
|
@ -153,7 +153,7 @@ end
|
||||||
function Parent:drawSprite(tx, ty)
|
function Parent:drawSprite(tx, ty)
|
||||||
utils.graphics.resetColor()
|
utils.graphics.resetColor()
|
||||||
|
|
||||||
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
local x, y = self.world.map:gridToPixel(self.x, self.y, true)
|
||||||
|
|
||||||
local tx = tx or 0
|
local tx = tx or 0
|
||||||
local ty = ty or 0
|
local ty = ty or 0
|
||||||
|
@ -176,7 +176,7 @@ function Parent:draw()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parent:drawShadow()
|
function Parent:drawShadow()
|
||||||
local x, y = self.maputils.gridToPixel(self.x, self.y, true)
|
local x, y = self.world.map:gridToPixel(self.x, self.y, true)
|
||||||
self.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
|
self.assets.images["actorsShadow"]:draw(x, y, 0, 1, 1, 12, 5)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue