feat: add initial action checking system
This commit is contained in:
parent
16fa9f49eb
commit
8f27270c39
4 changed files with 20 additions and 1 deletions
|
@ -4,5 +4,6 @@ return {
|
|||
y = 10,
|
||||
area = "test.plain"
|
||||
},
|
||||
baseteam = {"sonic", "tails", "amy"}
|
||||
baseteam = {"sonic", "tails", "amy"},
|
||||
actions = {"run", "punch", "fly"}
|
||||
}
|
|
@ -55,6 +55,7 @@ function Game:new()
|
|||
self.variables = {}
|
||||
self.completion = 0
|
||||
self.mapName = ""
|
||||
self.actions = startdata.actions
|
||||
|
||||
self.version = "0.0.0"
|
||||
end
|
||||
|
@ -73,6 +74,7 @@ function Game:setData(data)
|
|||
self.variables = data.variables
|
||||
self.flags = data.flags
|
||||
self.position = data.position
|
||||
self.actions = data.actions
|
||||
self.characters:setData(data.characters)
|
||||
self.loot:setData(data.loot)
|
||||
end
|
||||
|
@ -86,6 +88,7 @@ function Game:getData()
|
|||
data.destroyedGizmo = self.destroyedGizmo
|
||||
data.variables = self.variables
|
||||
data.position = self.position
|
||||
data.actions = self.actions
|
||||
|
||||
return data
|
||||
end
|
||||
|
|
|
@ -3,10 +3,21 @@ local PlayerActions = Object:extend()
|
|||
local BASE_SPEED = 120
|
||||
local JMP_STRENGHT = 2.5
|
||||
|
||||
local ACTIONS = {}
|
||||
ACTIONS["speedster"] = {"run"}
|
||||
ACTIONS["technic"] = {"fly"}
|
||||
ACTIONS["power"] = {"punch"}
|
||||
|
||||
function PlayerActions:initActions()
|
||||
self.currentAction = "idle"
|
||||
end
|
||||
|
||||
function PlayerActions:canDoAction(action)
|
||||
local classCanDoAction = utils.table.contain(ACTIONS[self:getCurrentCharType()], action)
|
||||
local playerCanDoAction = utils.table.contain(game.actions, action)
|
||||
return (classCanDoAction and playerCanDoAction)
|
||||
end
|
||||
|
||||
function PlayerActions:actionMove()
|
||||
if self.keys["up"].isDown then
|
||||
self.ysp = -BASE_SPEED
|
||||
|
|
|
@ -15,6 +15,10 @@ function Team:initTeam()
|
|||
self.canChangeActive = true
|
||||
end
|
||||
|
||||
function Team:getCurrentCharType()
|
||||
return self.active.data.class
|
||||
end
|
||||
|
||||
function Team:switchActiveCharacter()
|
||||
if (self.canChangeActive) then
|
||||
game.characters:setActiveCharacter()
|
||||
|
|
Loading…
Reference in a new issue