feat(cbs): add jumpBack and dashForward choregraphy actions
This commit is contained in:
parent
04817f1e51
commit
3d269dca4a
2 changed files with 65 additions and 2 deletions
|
@ -62,6 +62,12 @@ return {
|
|||
-- ::
|
||||
-- :: {"sendDamage", condition, damageEffect, accuracy, isSpecial, isAerial}
|
||||
|
||||
-- "dashForward" :: Dash until your are stopped
|
||||
-- :: {"dashForward", condition, speed, blockProcess}
|
||||
|
||||
-- "jumpBack" :: jump to initial position
|
||||
-- :: {"jumpBack", condition, blockProcess}
|
||||
|
||||
CONDITION TYPES
|
||||
--
|
||||
-- "sentDamage" :: an ennemy have received damage
|
||||
|
|
|
@ -133,11 +133,13 @@ end
|
|||
|
||||
function Hero:jumpTo(dx, dy, size, timerName, spinjump, duration)
|
||||
local duration = self:getMovementDuration(dx, dy, duration)
|
||||
self:goTo(dx, dy, timerName, duration)
|
||||
self.tweens:newTween(0, duration, {x = dx, y = dy}, 'inOutQuad')
|
||||
self.tweens:newTimer(duration + 0.02, timerName)
|
||||
self:setJump(size, spinjump, duration)
|
||||
end
|
||||
|
||||
function Hero:updateSpeed(dt)
|
||||
self:applyMotion(dt)
|
||||
self.xspeed = self.x - self.xprevious
|
||||
self.yspeed = self.y - self.yprevious
|
||||
|
||||
|
@ -166,12 +168,41 @@ function Hero:initJump()
|
|||
end
|
||||
|
||||
function Hero:setJump(size, spinjump, duration)
|
||||
local duration = duration or 0.66
|
||||
local tweenDuration = duration / 2
|
||||
self.tweens:newTween(0, tweenDuration, {z = size}, 'outQuad')
|
||||
self.tweens:newTween(tweenDuration, tweenDuration, {z = 0}, 'inQuad')
|
||||
end
|
||||
|
||||
function Hero:setMotionX(direction, speed)
|
||||
self.motion = speed
|
||||
self.motionDirection = direction
|
||||
end
|
||||
|
||||
function Hero:applyMotion(dt)
|
||||
if self.motion ~= 0 and self.motion ~= nil then
|
||||
local dx = self.x + self.motion * self.motionDirection * dt
|
||||
print(dx)
|
||||
-- {1, 0, "line", 5, true}
|
||||
local ox = self.choregraphy.startx + (self.choregraphy.effectArea[1] * self.choregraphy.direction)
|
||||
local oy = self.choregraphy.starty + self.choregraphy.effectArea[2]
|
||||
local shape = self.choregraphy.effectArea[3]
|
||||
local size = self.choregraphy.effectArea[4]
|
||||
local direction = self.choregraphy.direction
|
||||
|
||||
local new_case_x = math.floor(dx)
|
||||
local new_case_y = math.floor(self.y)
|
||||
if self.maputils.isInMask(dx, self.y, ox, oy, shape, size, direction) and self.world:caseIsEmpty(new_case_x, self.y) then
|
||||
self.x = dx
|
||||
else
|
||||
self.motion = 0
|
||||
if (self.choregraphy.blockedBy == 'action_dashForward') then
|
||||
self.choregraphy.changeAction = true
|
||||
self.direction = self.choregraphy.direction
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- SIGNAL FUNCTIONS
|
||||
-- All functions related to signal receiving
|
||||
|
||||
|
@ -217,6 +248,8 @@ function Hero:timerResponse(timer)
|
|||
elseif timer == 'backMove' then
|
||||
self:changeAnimation("idle")
|
||||
self.direction = self.directionPrevious
|
||||
elseif timer == self.choregraphy.blockedBy and self.choregraphy.changeAction == false then
|
||||
self.choregraphy.changeAction = true
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -241,6 +274,10 @@ function Hero:initChoregraphySystem()
|
|||
self.choregraphy.dy = self.y
|
||||
self.choregraphy.blockedBy = ""
|
||||
|
||||
self.choregraphy.startx = self.x
|
||||
self.choregraphy.starty = self.y
|
||||
self.choregraphy.direction = self.direction
|
||||
|
||||
self.isChoregraphyActive = false
|
||||
end
|
||||
|
||||
|
@ -262,6 +299,11 @@ function Hero:startChoregraphy(skill, dx, dy)
|
|||
self.choregraphy.changeAction = true
|
||||
self.choregraphy.data = skill.choregraphy
|
||||
self.choregraphy.effectArea = skill.effectArea
|
||||
|
||||
self.choregraphy.startx = self.x
|
||||
self.choregraphy.starty = self.y
|
||||
self.choregraphy.direction = self.direction
|
||||
|
||||
self.choregraphy.dx = dx or self.x
|
||||
self.choregraphy.dy = dy or self.y
|
||||
|
||||
|
@ -335,6 +377,21 @@ function Hero:doChoregraphyAction(choregraphyAction)
|
|||
elseif type == "playSFX" then
|
||||
local sfx = choregraphyAction[3]
|
||||
self.assets.sfx[sfx]:play()
|
||||
elseif type == "dashForward" then
|
||||
local speed = choregraphyAction[3]
|
||||
local blockProcess = choregraphyAction[4]
|
||||
self:setMotionX(self.direction, speed)
|
||||
if (blockProcess) then
|
||||
self.choregraphy.blockedBy = "action_dashForward"
|
||||
self.choregraphy.changeAction = false
|
||||
end
|
||||
elseif type == "jumpBack" then
|
||||
local blockProcess = choregraphyAction[3]
|
||||
if (blockProcess) then
|
||||
self.choregraphy.blockedBy = "action_jumpBack"
|
||||
self.choregraphy.changeAction = false
|
||||
end
|
||||
self:jumpTo(self.choregraphy.startx, self.choregraphy.starty, 32, "action_jumpBack", false)
|
||||
else
|
||||
core.debug:warning("cbs/hero", "unknown action type " .. type)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue