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"
|
||||
|
||||
function Ennemy:new(world, x, y, id, number)
|
||||
function Ennemy:new(world, x, y, owner)
|
||||
Ennemy.super.new(self, world, x, y, 0)
|
||||
self.isEnnemy = true
|
||||
self.ennid = id or "motobug"
|
||||
self.owner = owner
|
||||
|
||||
self.actionPerTurn = 2
|
||||
|
||||
|
@ -18,31 +18,16 @@ function Ennemy:new(world, x, y, id, number)
|
|||
end
|
||||
|
||||
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.rectangle("fill", x - 8, y - 32, 16, 32)
|
||||
love.graphics.setColor(1, 1, 1, 1)
|
||||
end
|
||||
|
||||
function Ennemy:drawHUD()
|
||||
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)
|
||||
self.owner:drawHUD(x - 14, y - 38)
|
||||
end
|
||||
|
||||
function Ennemy:receiveDatas()
|
||||
self.data = game.ennemies:getEnnemyData(self.ennid)
|
||||
self.data = game.ennemies:getEnnemyData(self.owner.name)
|
||||
end
|
||||
|
||||
function Ennemy:setHP(value, relative)
|
||||
|
|
|
@ -2,28 +2,26 @@ local Battler = require("scenes.battlesystem.actors.battler")
|
|||
local Hero = Battler:extend()
|
||||
|
||||
local gui = require "game.modules.gui"
|
||||
local StatusBar = require "scenes.battlesystem.gui.statusbar"
|
||||
|
||||
local ChoregraphySystem = require "scenes.battlesystem.actors.systems.choregraphy"
|
||||
|
||||
-- INIT FUNCTIONS
|
||||
-- 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)
|
||||
self.isHero = true
|
||||
self.owner = owner
|
||||
|
||||
self:initMovementSystem()
|
||||
|
||||
self:initCharacter(charid)
|
||||
--self:initCharacter(charid)
|
||||
|
||||
self:initSprite()
|
||||
self:initChoregraphySystem()
|
||||
|
||||
self:initVoices()
|
||||
|
||||
self.statusbar = StatusBar(self)
|
||||
|
||||
self.side = "heroes"
|
||||
end
|
||||
|
||||
|
@ -34,37 +32,31 @@ function Hero:initCharacter(charid)
|
|||
if charid == nil then
|
||||
core.debug:error("FATAL ERROR: charid not set")
|
||||
end
|
||||
self.charid = 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.owner.name = charid
|
||||
|
||||
self.turnAction = nil
|
||||
end
|
||||
|
||||
function Hero:getStats()
|
||||
return game.characters.list[self.charid].stats
|
||||
return game.characters.list[self.owner.name].stats
|
||||
end
|
||||
|
||||
function Hero:setHP(value, relative)
|
||||
if relative == true then
|
||||
value = game.characters.list[self.charid].stats.hp + value
|
||||
value = game.characters.list[self.owner.name].stats.hp + value
|
||||
end
|
||||
|
||||
game.characters.list[self.charid].stats.hp = value
|
||||
self.statusbar:updateHP()
|
||||
game.characters.list[self.owner.name].stats.hp = value
|
||||
--self.statusbar:updateHP()
|
||||
end
|
||||
|
||||
function Hero:setPP(value, relative)
|
||||
if relative == true then
|
||||
value = game.characters.list[self.charid].stats.pp + value
|
||||
value = game.characters.list[self.owner.name].stats.pp + value
|
||||
end
|
||||
|
||||
game.characters.list[self.charid].stats.pp = value
|
||||
self.statusbar:updatePP()
|
||||
game.characters.list[self.owner.name].stats.pp = value
|
||||
--self.statusbar:updatePP()
|
||||
end
|
||||
|
||||
|
||||
|
@ -72,8 +64,8 @@ end
|
|||
-- Function to set or unset activity to the character
|
||||
|
||||
function Hero:setActive()
|
||||
core.debug:print("cbs/hero", "hero " .. self.charid .. " is now active")
|
||||
local gridsize = game.characters.list[self.charid].move
|
||||
core.debug:print("cbs/hero", "hero " .. self.owner.name .. " is now active")
|
||||
local gridsize = game.characters.list[self.owner.name].move
|
||||
if (gridsize == nil) then
|
||||
gridsize = 3
|
||||
core.debug:warning("cbs/character", "move value is nil")
|
||||
|
@ -110,7 +102,7 @@ function Hero:update(dt)
|
|||
self.yprevious = self.y
|
||||
self.zprevious = self.z
|
||||
|
||||
self.statusbar:update(dt)
|
||||
--self.statusbar:update(dt)
|
||||
end
|
||||
|
||||
-- MOVE FUNCTIONS
|
||||
|
@ -354,16 +346,16 @@ end
|
|||
-- Getting info about the actor
|
||||
|
||||
function Hero:getCharacterData()
|
||||
return game.characters.list[self.charid]
|
||||
return game.characters.list[self.owner.name]
|
||||
end
|
||||
|
||||
-- ASSETS FUNCTIONS
|
||||
-- Load and play assets needed by the character
|
||||
|
||||
function Hero:initSprite()
|
||||
self.assets:addSprite(self.charid, "datas/gamedata/characters/" .. self.charid .. "/sprites")
|
||||
self.assets.sprites[self.charid]:setCustomSpeed(16)
|
||||
self:setSprite(self.charid, 32, 48, true)
|
||||
self.assets:addSprite(self.owner.name, "datas/gamedata/characters/" .. self.owner.name .. "/sprites")
|
||||
self.assets.sprites[self.owner.name]:setCustomSpeed(16)
|
||||
self:setSprite(self.owner.name, 32, 48, true)
|
||||
self:cloneSprite()
|
||||
self:changeAnimation("idle")
|
||||
end
|
||||
|
@ -380,13 +372,13 @@ function Hero:initVoices()
|
|||
end
|
||||
|
||||
function Hero:addVoiceEffect(name)
|
||||
local completename = self.charid .. "_" .. name
|
||||
local path = "datas/gamedata/characters/" .. self.charid .. "/voices/" .. name .. ".wav"
|
||||
local completename = self.owner.name .. "_" .. name
|
||||
local path = "datas/gamedata/characters/" .. self.owner.name .. "/voices/" .. name .. ".wav"
|
||||
self.assets:newSFX(completename, path)
|
||||
end
|
||||
|
||||
function Hero:talk(name)
|
||||
local completename = self.charid .. "_" .. name
|
||||
local completename = self.owner.name .. "_" .. name
|
||||
self.assets.sfx[completename]:play()
|
||||
end
|
||||
|
||||
|
@ -397,13 +389,4 @@ function Hero:draw()
|
|||
self:drawSprite(0, -self.z)
|
||||
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
|
||||
|
|
|
@ -153,7 +153,7 @@ end
|
|||
function Parent:drawSprite(tx, ty)
|
||||
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 ty = ty or 0
|
||||
|
@ -176,7 +176,7 @@ function Parent:draw()
|
|||
end
|
||||
|
||||
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)
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue