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,
|
y = 10,
|
||||||
area = "test.plain"
|
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.variables = {}
|
||||||
self.completion = 0
|
self.completion = 0
|
||||||
self.mapName = ""
|
self.mapName = ""
|
||||||
|
self.actions = startdata.actions
|
||||||
|
|
||||||
self.version = "0.0.0"
|
self.version = "0.0.0"
|
||||||
end
|
end
|
||||||
|
@ -73,6 +74,7 @@ function Game:setData(data)
|
||||||
self.variables = data.variables
|
self.variables = data.variables
|
||||||
self.flags = data.flags
|
self.flags = data.flags
|
||||||
self.position = data.position
|
self.position = data.position
|
||||||
|
self.actions = data.actions
|
||||||
self.characters:setData(data.characters)
|
self.characters:setData(data.characters)
|
||||||
self.loot:setData(data.loot)
|
self.loot:setData(data.loot)
|
||||||
end
|
end
|
||||||
|
@ -86,6 +88,7 @@ function Game:getData()
|
||||||
data.destroyedGizmo = self.destroyedGizmo
|
data.destroyedGizmo = self.destroyedGizmo
|
||||||
data.variables = self.variables
|
data.variables = self.variables
|
||||||
data.position = self.position
|
data.position = self.position
|
||||||
|
data.actions = self.actions
|
||||||
|
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,10 +3,21 @@ local PlayerActions = Object:extend()
|
||||||
local BASE_SPEED = 120
|
local BASE_SPEED = 120
|
||||||
local JMP_STRENGHT = 2.5
|
local JMP_STRENGHT = 2.5
|
||||||
|
|
||||||
|
local ACTIONS = {}
|
||||||
|
ACTIONS["speedster"] = {"run"}
|
||||||
|
ACTIONS["technic"] = {"fly"}
|
||||||
|
ACTIONS["power"] = {"punch"}
|
||||||
|
|
||||||
function PlayerActions:initActions()
|
function PlayerActions:initActions()
|
||||||
self.currentAction = "idle"
|
self.currentAction = "idle"
|
||||||
end
|
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()
|
function PlayerActions:actionMove()
|
||||||
if self.keys["up"].isDown then
|
if self.keys["up"].isDown then
|
||||||
self.ysp = -BASE_SPEED
|
self.ysp = -BASE_SPEED
|
||||||
|
|
|
@ -15,6 +15,10 @@ function Team:initTeam()
|
||||||
self.canChangeActive = true
|
self.canChangeActive = true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Team:getCurrentCharType()
|
||||||
|
return self.active.data.class
|
||||||
|
end
|
||||||
|
|
||||||
function Team:switchActiveCharacter()
|
function Team:switchActiveCharacter()
|
||||||
if (self.canChangeActive) then
|
if (self.canChangeActive) then
|
||||||
game.characters:setActiveCharacter()
|
game.characters:setActiveCharacter()
|
||||||
|
|
Loading…
Reference in a new issue