feat: make that any actor can block choregraphy
This commit is contained in:
parent
bccc71ec58
commit
28a869a42e
3 changed files with 86 additions and 78 deletions
|
@ -25,10 +25,6 @@ function Battler:new(world, x, y, z, owner)
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
|
|
||||||
self.isDefending = false
|
self.isDefending = false
|
||||||
|
|
||||||
self.tags = {}
|
|
||||||
self.choregraphy = nil
|
|
||||||
self.frameSignals = {}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:destroy()
|
function Battler:destroy()
|
||||||
|
@ -84,68 +80,15 @@ function Battler:update(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:purgeFrameSignal()
|
|
||||||
self.frameSignals = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:receiveFrameSignal(signal)
|
|
||||||
table.insert(self.frameSignals, signal)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:haveFrameSignal(signal)
|
|
||||||
return utils.table.contain(self.frameSignals, signal)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- CHOREGRAPHY FUNCTIONS
|
-- CHOREGRAPHY FUNCTIONS
|
||||||
-- All functions related to the choregraphy system
|
-- All functions related to the choregraphy system
|
||||||
|
|
||||||
function Battler:blockChoregraphy(isBlocking, currentlyBlocking, blockedBy)
|
|
||||||
if (isBlocking) then
|
|
||||||
self.currentlyBlocking = currentlyBlocking
|
|
||||||
self.blockedBy = blockedBy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:addTaggedAction(tag, choregraphy, taggedBy)
|
|
||||||
if (not utils.string.isEmpty(tag)) then
|
|
||||||
self.tags[tag] = taggedBy
|
|
||||||
self.choregraphy = choregraphy
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:unlockTag(taggedBy)
|
|
||||||
for tag, actionTag in pairs(self.tags) do
|
|
||||||
if (self.choregraphy ~= nil) and (actionTag == taggedBy) then
|
|
||||||
self.choregraphy:finishTagAction(tag)
|
|
||||||
self.tags[tag] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:unblockChoregraphy()
|
|
||||||
self.currentlyBlocking:finish()
|
|
||||||
self.currentlyBlocking = nil
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:timerResponse(signal)
|
|
||||||
self:finishAction(signal)
|
|
||||||
|
|
||||||
if (signal == "removeOutput") then
|
|
||||||
self.showOutput = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:finishAction(signal)
|
|
||||||
if ((self.currentlyBlocking ~= nil) and (signal == self.blockedBy)) then
|
|
||||||
self:unblockChoregraphy()
|
|
||||||
end
|
|
||||||
self:unlockTag(signal)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:choregraphyEnded()
|
function Battler:choregraphyEnded()
|
||||||
self:resetMovement()
|
self:resetMovement()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- DAMAGE FUNCTIONS
|
||||||
|
|
||||||
function Battler:getHurt()
|
function Battler:getHurt()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -183,23 +126,6 @@ function Battler:initSprite()
|
||||||
self:changeAnimation("idle")
|
self:changeAnimation("idle")
|
||||||
end
|
end
|
||||||
|
|
||||||
function Battler:changeAnimation(animation, restart)
|
|
||||||
self:purgeFrameSignal()
|
|
||||||
Battler.super.changeAnimation(self, animation, restart)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:animationEnded(animation)
|
|
||||||
if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then
|
|
||||||
self:unblockChoregraphy()
|
|
||||||
end
|
|
||||||
self:unlockTag("animation")
|
|
||||||
self:getNewAnimation(animation)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:getNewAnimation(animation)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function Battler:validateAction()
|
function Battler:validateAction()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,8 @@ function Parent:new(world, x, y, z)
|
||||||
|
|
||||||
self.tweens = TweenManager(self)
|
self.tweens = TweenManager(self)
|
||||||
|
|
||||||
|
self:resetTags()
|
||||||
|
|
||||||
self:setSprite()
|
self:setSprite()
|
||||||
self:register()
|
self:register()
|
||||||
end
|
end
|
||||||
|
@ -67,6 +69,8 @@ function Parent:setSprite(spritename, ox, oy, active)
|
||||||
self.sprite.exist = (spritename ~= nil)
|
self.sprite.exist = (spritename ~= nil)
|
||||||
self.sprite.clone = nil
|
self.sprite.clone = nil
|
||||||
self.sprite.active = active or false
|
self.sprite.active = active or false
|
||||||
|
|
||||||
|
self:resetFrameSignal()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parent:cloneSprite()
|
function Parent:cloneSprite()
|
||||||
|
@ -77,6 +81,7 @@ function Parent:cloneSprite()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parent:changeAnimation(animation, restart)
|
function Parent:changeAnimation(animation, restart)
|
||||||
|
self:resetFrameSignal()
|
||||||
if (self.sprite.clone == nil) then
|
if (self.sprite.clone == nil) then
|
||||||
self.assets.sprites[self.sprite.name]:changeAnimation(animation, restart)
|
self.assets.sprites[self.sprite.name]:changeAnimation(animation, restart)
|
||||||
else
|
else
|
||||||
|
@ -93,7 +98,15 @@ function Parent:setAnimSpeed(speed)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parent:animationEnded(animation)
|
function Parent:animationEnded(animation)
|
||||||
-- Empty placeholder function
|
if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then
|
||||||
|
self:unblockChoregraphy()
|
||||||
|
end
|
||||||
|
self:unlockTag("animation")
|
||||||
|
self:getNewAnimation(animation)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:getNewAnimation(animation)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Parent:setCustomSpeed(customSpeed)
|
function Parent:setCustomSpeed(customSpeed)
|
||||||
|
@ -184,6 +197,75 @@ function Parent:drawSprite(tx, ty)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- FRAME SIGNAL
|
||||||
|
-- Get signals from specific frames of the animation
|
||||||
|
|
||||||
|
function Parent:resetFrameSignal()
|
||||||
|
self.frameSignals = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:receiveFrameSignal(signal)
|
||||||
|
table.insert(self.frameSignals, signal)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:haveFrameSignal(signal)
|
||||||
|
return utils.table.contain(self.frameSignals, signal)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- TAGS
|
||||||
|
-- Handle tags
|
||||||
|
|
||||||
|
function Parent:resetTags()
|
||||||
|
self.tags = {}
|
||||||
|
self.choregraphy = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:addTaggedAction(tag, choregraphy, taggedBy)
|
||||||
|
if (not utils.string.isEmpty(tag)) then
|
||||||
|
self.tags[tag] = taggedBy
|
||||||
|
self.choregraphy = choregraphy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:unlockTag(taggedBy)
|
||||||
|
for tag, actionTag in pairs(self.tags) do
|
||||||
|
if (self.choregraphy ~= nil) and (actionTag == taggedBy) then
|
||||||
|
self.choregraphy:finishTagAction(tag)
|
||||||
|
self.tags[tag] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- CHOREGRAPHY BLOCKING
|
||||||
|
-- Handle blocking/unblocking the choregraphy
|
||||||
|
|
||||||
|
function Parent:blockChoregraphy(isBlocking, currentlyBlocking, blockedBy)
|
||||||
|
if (isBlocking) then
|
||||||
|
self.currentlyBlocking = currentlyBlocking
|
||||||
|
self.blockedBy = blockedBy
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:unblockChoregraphy()
|
||||||
|
self.currentlyBlocking:finish()
|
||||||
|
self.currentlyBlocking = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:timerResponse(signal)
|
||||||
|
self:finishAction(signal)
|
||||||
|
|
||||||
|
if (signal == "removeOutput") then
|
||||||
|
self.showOutput = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Parent:finishAction(signal)
|
||||||
|
if ((self.currentlyBlocking ~= nil) and (signal == self.blockedBy)) then
|
||||||
|
self:unblockChoregraphy()
|
||||||
|
end
|
||||||
|
self:unlockTag(signal)
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Handle draw functions
|
-- Handle draw functions
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ function ChoregraphySystem:new(action, choregraphy)
|
||||||
self.action = action
|
self.action = action
|
||||||
self.fighter = action.fighter
|
self.fighter = action.fighter
|
||||||
self.actor = self.fighter.actor
|
self.actor = self.fighter.actor
|
||||||
self.actor:purgeFrameSignal()
|
self.actor:resetFrameSignal()
|
||||||
self.assets = self.fighter.actor.assets
|
self.assets = self.fighter.actor.assets
|
||||||
self.world = self.actor.world
|
self.world = self.actor.world
|
||||||
self.target = action.target
|
self.target = action.target
|
||||||
|
|
Loading…
Reference in a new issue