sonic-radiance/sonic-radiance.love/scenes/battlesystem/actors/systems/actions/jump.lua

41 lines
1.1 KiB
Lua
Raw Normal View History

local ChoregraphyActionParent = require "scenes.battlesystem.actors.systems.actions.parent"
local JumpAction = ChoregraphyActionParent:extend()
function JumpAction:new(system, args, effectArea)
JumpAction.super.new(self, system, args, effectArea)
end
function JumpAction:start()
local xx, yy
local spinjump = true
local factor = 1
local easing = 'inOutQuad'
if self.args.name == "jumpBack" then
xx, yy = self.controller.startx, self.controller.starty
self.actor.directionLocked = true
spinjump = false
factor = 2
easing = 'outQuad'
elseif self.args.name == "jumpToCursor" then
xx, yy = self.controller.dx, self.controller.dy
end
local dist = utils.math.pointDistance(self.actor.x, self.actor.y, xx, yy)
local jumpHeight = dist * 16 / factor
self.actor:jumpTo(xx, yy, jumpHeight, "action_jumpBack", spinjump, 1, easing)
self.actor:blockChoregraphy(self.args.blockProcess, "action_jumpBack")
if (not self.args.blockProcess) then
self:finish()
end
end
function JumpAction:getSignal(signal)
if (signal == "actorHaveFinished") then
self:finish()
end
end
return JumpAction