chore: more code extraction
This commit is contained in:
parent
b413946368
commit
fa6e6c2bc4
6 changed files with 106 additions and 4 deletions
|
@ -273,6 +273,12 @@ function Hero:receiveSignal(action_type, id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Hero:positionSelected(x, y)
|
||||||
|
self:changeAnimation("walk", true)
|
||||||
|
self:goTo(self.world.cursor.x, self.world.cursor.y, 'cursorMove', 1)
|
||||||
|
self.assets.sfx["woosh"]:play()
|
||||||
|
end
|
||||||
|
|
||||||
function Hero:receiveBackSignal()
|
function Hero:receiveBackSignal()
|
||||||
self.world.cursor:set(self.x, self.y, "cursorMove")
|
self.world.cursor:set(self.x, self.y, "cursorMove")
|
||||||
if (self.x ~= self.startx) or (self.y ~= self.starty) then
|
if (self.x ~= self.startx) or (self.y ~= self.starty) then
|
||||||
|
@ -344,6 +350,13 @@ function Hero:unblockChoregraphy()
|
||||||
self.blockingChoregraphy = ""
|
self.blockingChoregraphy = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- INFO FUNCTIONS
|
||||||
|
-- Getting info about the actor
|
||||||
|
|
||||||
|
function Hero:getCharacterData()
|
||||||
|
return game.characters.list[self.charid]
|
||||||
|
end
|
||||||
|
|
||||||
-- ASSETS FUNCTIONS
|
-- ASSETS FUNCTIONS
|
||||||
-- Load and play assets needed by the character
|
-- Load and play assets needed by the character
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ function TurnController:new(scene)
|
||||||
self.scene = scene
|
self.scene = scene
|
||||||
self.world = scene.world
|
self.world = scene.world
|
||||||
|
|
||||||
--self.player = Player(self)
|
self.player = Player(self)
|
||||||
--self.ennemies = Ennemy(self)
|
--self.ennemies = Ennemy(self)
|
||||||
|
|
||||||
self.isActive = false
|
self.isActive = false
|
||||||
|
@ -31,7 +31,7 @@ end
|
||||||
function TurnController:update(dt)
|
function TurnController:update(dt)
|
||||||
if (self.isActive) then
|
if (self.isActive) then
|
||||||
if (self.currentlyPlaying == "heroes") then
|
if (self.currentlyPlaying == "heroes") then
|
||||||
--self.player:update(dt)
|
self.player:update(dt)
|
||||||
elseif (self.currentlyPlaying == "ennemies") then
|
elseif (self.currentlyPlaying == "ennemies") then
|
||||||
--self.ennemies:update(dt)
|
--self.ennemies:update(dt)
|
||||||
else
|
else
|
||||||
|
@ -75,9 +75,8 @@ core.debug:print("cbs/world", "Starting action " .. self.turns.current)
|
||||||
self:nextAction()
|
self:nextAction()
|
||||||
else
|
else
|
||||||
if (nextActor.side == "heroes") then
|
if (nextActor.side == "heroes") then
|
||||||
--self.player:setActive(nextActor)
|
self.player:setActive(nextActor)
|
||||||
self.currentlyPlaying = "heroes"
|
self.currentlyPlaying = "heroes"
|
||||||
self.actionList[self.turns.current].actor:setActive()
|
|
||||||
elseif (nextActor.side == "ennemies") then
|
elseif (nextActor.side == "ennemies") then
|
||||||
--self.ennemies:setActive(nextActor)
|
--self.ennemies:setActive(nextActor)
|
||||||
self.currentlyPlaying = "ennemies"
|
self.currentlyPlaying = "ennemies"
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
local ControllerParent = Object:extend()
|
||||||
|
|
||||||
|
function ControllerParent:new(owner)
|
||||||
|
self.owner = owner
|
||||||
|
self.activeActor = nil;
|
||||||
|
self.startData = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerParent:setActive(activeActor)
|
||||||
|
self.activeActor = activeActor
|
||||||
|
activeActor:setActive()
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerParent:update(dt)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function ControllerParent:endAction()
|
||||||
|
self.owner:nextAction()
|
||||||
|
end
|
||||||
|
|
||||||
|
return PlayerController
|
|
@ -0,0 +1,28 @@
|
||||||
|
local PlayerController = Object:extend()
|
||||||
|
|
||||||
|
function PlayerController:new(owner)
|
||||||
|
self.owner = owner
|
||||||
|
self.activeActor = nil;
|
||||||
|
self.startData = {}
|
||||||
|
end
|
||||||
|
|
||||||
|
function PlayerController:setActive(activeActor)
|
||||||
|
self.activeActor = activeActor
|
||||||
|
activeActor:setActive()
|
||||||
|
end
|
||||||
|
|
||||||
|
function PlayerController:update(dt)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function PlayerController:setStartData(x, y, direction)
|
||||||
|
self.startData.x = x
|
||||||
|
self.startData.y = y
|
||||||
|
self.startData.direction = direction
|
||||||
|
end
|
||||||
|
|
||||||
|
function PlayerController:getStartData()
|
||||||
|
return self.startData.x, self.startData.y, self.startData.direction
|
||||||
|
end
|
||||||
|
|
||||||
|
return PlayerController
|
|
@ -0,0 +1 @@
|
||||||
|
self.scene.menu:set( self )
|
|
@ -0,0 +1,39 @@
|
||||||
|
local MovingView = Object:extend()
|
||||||
|
|
||||||
|
local DEFAULT_GRIDSIZE = 2
|
||||||
|
|
||||||
|
function MovingView:new(owner, actor)
|
||||||
|
self.owner = owner
|
||||||
|
self.actor = actor
|
||||||
|
self.world = actor.world
|
||||||
|
end
|
||||||
|
|
||||||
|
function MovingView:update(dt)
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
function MovingVew:start()
|
||||||
|
local character = self.actor:getCharacterData();
|
||||||
|
local gridsize = character.move
|
||||||
|
if (gridsize == nil) then
|
||||||
|
gridsize = DEFAULT_GRIDSIZE
|
||||||
|
core.debug:warning("cbs/character", "move value is nil")
|
||||||
|
end
|
||||||
|
local x, y = utils.math.round(self.actor.x), utils.math.round(self.actor.y)
|
||||||
|
self.world.cursor:setGrid(x, y, "circle", gridsize, 1, self.owner)
|
||||||
|
self.actor.x, self.actor.y = x, y
|
||||||
|
self.owner:setStartData(x, y, self.actor.direction)
|
||||||
|
|
||||||
|
self.world.cursor:set(x, y, "cursorMove")
|
||||||
|
end
|
||||||
|
|
||||||
|
function MovingView:receiveSignal(signal, id)
|
||||||
|
if (signal == "positionSelected") then
|
||||||
|
self.actor:set
|
||||||
|
elseif (signal == "characterMoved") then
|
||||||
|
self.world:resetActiveGrid()
|
||||||
|
self:endView()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return MovingView
|
Loading…
Reference in a new issue