sonic-radiance/sonic-radiance.love/scenes/overworld/actors/player/charset.lua

43 lines
1.2 KiB
Lua
Raw Normal View History

local PlayerCharset = Object:extend()
2021-04-10 17:41:53 +02:00
local ACTIONS_LARGEANIM = {"jump"}
2021-04-10 19:32:41 +02:00
local ACTIONS_ISFAST = {"jump", "fly", "run", "jumpdash"}
2021-04-10 18:28:52 +02:00
local ACTIONS_ALWAYSWALK = {"fly"}
2021-04-10 17:41:53 +02:00
function PlayerCharset:initPlayerCharset()
self:updateCurrentCharset()
end
function PlayerCharset:updateCurrentCharset()
2021-04-10 17:41:53 +02:00
self:setCharset(self:getCharset(), self.active.data.charId)
self.isFast = self:getIsFast()
self.largeAnim = self:getLargeAnim()
2021-04-10 18:28:52 +02:00
self.alwaysWalk = self:getAlwaysWalk()
2021-04-10 17:41:53 +02:00
end
function PlayerCharset:getCharset()
local charset = self.active.data.charset
2021-04-10 19:32:41 +02:00
if (self.currentAction == "jump" or self.currentAction == "jumpdash") then
2021-04-10 17:41:53 +02:00
charset = charset .. "-jump"
2021-04-10 18:28:52 +02:00
elseif (self.currentAction == "fly") then
charset = charset .. "-flight"
elseif (self.currentAction == "punch") then
charset = charset .. "-jump"
end
2021-04-10 17:41:53 +02:00
return charset
end
function PlayerCharset:getLargeAnim()
2021-04-10 18:28:52 +02:00
return utils.table.contain(ACTIONS_LARGEANIM, self.currentAction)
2021-04-10 17:41:53 +02:00
end
function PlayerCharset:getIsFast()
2021-04-10 18:28:52 +02:00
return utils.table.contain(ACTIONS_ISFAST, self.currentAction)
end
function PlayerCharset:getAlwaysWalk()
return utils.table.contain(ACTIONS_ALWAYSWALK, self.currentAction)
2021-04-10 17:41:53 +02:00
end
2021-04-10 17:41:53 +02:00
return PlayerCharset