2019-08-14 16:26:23 +02:00
|
|
|
local Parent = require("scenes.battlesystem.actors.parent")
|
|
|
|
local Battler = Parent:extend()
|
|
|
|
|
2020-08-04 22:40:58 +02:00
|
|
|
local MIDDLE_ARENA = 6
|
|
|
|
|
2020-08-03 17:38:30 +02:00
|
|
|
function Battler:new(world, x, y, z, owner)
|
2019-08-14 16:26:23 +02:00
|
|
|
Battler.super.new(self, world, x, y, z)
|
|
|
|
|
2020-08-04 22:40:58 +02:00
|
|
|
self.direction = utils.math.sign(MIDDLE_ARENA - x)
|
|
|
|
|
2020-07-25 10:24:07 +02:00
|
|
|
self.start = {}
|
|
|
|
self.start.x = x
|
|
|
|
self.start.y = y
|
2020-08-04 22:40:58 +02:00
|
|
|
self.start.direction = self.direction
|
2020-07-25 10:24:07 +02:00
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
self.isBattler = true
|
|
|
|
self.speed = 3
|
|
|
|
self.isActive = false
|
|
|
|
self.debugActiveTimer = 0
|
2020-07-19 21:41:14 +02:00
|
|
|
|
|
|
|
self.isSelected = false
|
2020-08-03 17:38:30 +02:00
|
|
|
self.owner = owner
|
2019-08-14 16:26:23 +02:00
|
|
|
end
|
|
|
|
|
2019-08-15 19:00:01 +02:00
|
|
|
function Battler:destroy()
|
|
|
|
Battler.super.destroy(self)
|
|
|
|
end
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
function Battler:setActive()
|
|
|
|
core.debug:print("cbs/actor","actor " .. self.id .. " is active")
|
|
|
|
self.isActive = true
|
|
|
|
self.debugActiveTimer = 0
|
|
|
|
end
|
|
|
|
|
|
|
|
function Battler:update(dt)
|
2019-08-16 23:04:30 +02:00
|
|
|
Battler.super.update(self, dt)
|
2019-08-14 16:26:23 +02:00
|
|
|
if (self.isActive) then
|
|
|
|
self.debugActiveTimer = self.debugActiveTimer + dt
|
|
|
|
if self.debugActiveTimer >= 0.5 then
|
2019-08-14 20:44:20 +02:00
|
|
|
core.debug:print("cbs/battler", "counter ended, switching active battler")
|
2019-08-14 16:26:23 +02:00
|
|
|
self.isActive = false
|
2019-08-15 19:00:01 +02:00
|
|
|
self.world:switchActiveBattler()
|
2019-08-14 16:26:23 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2020-08-03 17:38:30 +02:00
|
|
|
function Battler:draw()
|
|
|
|
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
|
|
|
|
|
2020-08-04 22:19:11 +02:00
|
|
|
function Battler:initSprite()
|
|
|
|
if (self.assets.sprites[self.owner.name] == nil) then
|
|
|
|
self.assets:addSprite(self.owner.name, self:getSpritePath())
|
|
|
|
end
|
|
|
|
self.assets.sprites[self.owner.name]:setCustomSpeed(16)
|
|
|
|
self:setSprite(self.owner.name, 32, 48, true)
|
|
|
|
self:cloneSprite()
|
|
|
|
self:changeAnimation("idle")
|
|
|
|
end
|
|
|
|
|
2019-08-14 16:26:23 +02:00
|
|
|
function Battler:validateAction()
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
return Battler
|