Ajout des derniers développement #1
1 changed files with 13 additions and 105 deletions
|
@ -14,7 +14,6 @@ function Hero:new(world, x, y, owner, charnumber)
|
||||||
self:initMovementSystem()
|
self:initMovementSystem()
|
||||||
|
|
||||||
self:initSprite()
|
self:initSprite()
|
||||||
self:initChoregraphySystem()
|
|
||||||
|
|
||||||
self.side = "heroes"
|
self.side = "heroes"
|
||||||
end
|
end
|
||||||
|
@ -27,8 +26,6 @@ function Hero:update(dt)
|
||||||
-- Calculate speed to calculate animation speed
|
-- Calculate speed to calculate animation speed
|
||||||
self:updateSpeed(dt)
|
self:updateSpeed(dt)
|
||||||
|
|
||||||
self:updateChoregraphy(dt)
|
|
||||||
|
|
||||||
self.xprevious = self.x
|
self.xprevious = self.x
|
||||||
self.yprevious = self.y
|
self.yprevious = self.y
|
||||||
self.zprevious = self.z
|
self.zprevious = self.z
|
||||||
|
@ -152,114 +149,25 @@ function Hero:applyMotion(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- SIGNAL FUNCTIONS
|
|
||||||
-- All functions related to signal receiving
|
|
||||||
|
|
||||||
function Hero:receiveSignal(action_type, id)
|
|
||||||
if id == nil then
|
|
||||||
core.debug:print("battler/hero", "action selected : " .. action_type)
|
|
||||||
else
|
|
||||||
core.debug:print("battler/hero", "action selected : " .. action_type .. " (" .. id .. ")")
|
|
||||||
end
|
|
||||||
if (action_type == "defend") then
|
|
||||||
self.turnAction = "defend"
|
|
||||||
self:switchActiveBattler( )
|
|
||||||
elseif (action_type == "attack") then
|
|
||||||
--self:changeAnimation("hit1")
|
|
||||||
self:attack()
|
|
||||||
elseif (action_type == "skill") then
|
|
||||||
self.world.cursor:unset( )
|
|
||||||
self:useSkill(id, self.world.cursor.x, self.world.cursor.y)
|
|
||||||
elseif (action_type == "cursorMove") then
|
|
||||||
if (self.x ~= self.world.cursor.x) or (self.y ~= self.world.cursor.y) then
|
|
||||||
self:changeAnimation("walk", true)
|
|
||||||
self:goTo(self.world.cursor.x, self.world.cursor.y, 'cursorMove', 1)
|
|
||||||
self.assets.sfx["woosh"]:play()
|
|
||||||
else
|
|
||||||
self.world:resetActiveGrid()
|
|
||||||
self.scene.menu:set( self )
|
|
||||||
end
|
|
||||||
self.world.cursor:unset( )
|
|
||||||
else
|
|
||||||
self:switchActiveBattler( )
|
|
||||||
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()
|
|
||||||
self.world.cursor:set(self.x, self.y, "cursorMove")
|
|
||||||
if (self.x ~= self.startx) or (self.y ~= self.starty) then
|
|
||||||
self.world.cursor:set(self.x, self.y, "cursorMove")
|
|
||||||
self.assets.sfx["woosh"]:play()
|
|
||||||
self:changeAnimation("walk")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function Hero:timerResponse(timer)
|
|
||||||
if timer == "switchActiveBattler" then
|
|
||||||
self.scene.turns:nextAction()
|
|
||||||
elseif timer == "wait" then
|
|
||||||
self.choregraphy.changeAction = true
|
|
||||||
elseif timer == "cursorMove" then
|
|
||||||
self:changeAnimation("idle")
|
|
||||||
self.world:resetActiveGrid()
|
|
||||||
self.scene.menu:set( self )
|
|
||||||
elseif timer == 'backMove' then
|
|
||||||
self:changeAnimation("idle")
|
|
||||||
self.direction = self.directionPrevious
|
|
||||||
elseif timer == 'action_jumpBack' then
|
|
||||||
self.unlockDirection = true
|
|
||||||
self:unblockChoregraphy()
|
|
||||||
elseif timer == self.choregraphy.blockedBy then
|
|
||||||
self:unblockChoregraphy()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- ACTION FUNCTIONS
|
|
||||||
-- All functions related to actions
|
|
||||||
|
|
||||||
function Hero:switchActiveBattler()
|
|
||||||
print("Switching Active Battler")
|
|
||||||
self.tweens:newTimer(0.15, "switchActiveBattler")
|
|
||||||
end
|
|
||||||
|
|
||||||
-- CHOREGRAPHY FUNCTIONS
|
-- CHOREGRAPHY FUNCTIONS
|
||||||
-- All functions related to the choregraphy system
|
-- All functions related to the choregraphy system
|
||||||
|
|
||||||
function Hero:initChoregraphySystem()
|
function Hero:blockChoregraphy(isBlocking, currentlyBlocking, blockedBy)
|
||||||
self.choregraphy = ChoregraphySystem(self)
|
if (isBlocking) then
|
||||||
self.blockingChoregraphy = nil
|
self.currentlyBlocking = currentlyBlocking
|
||||||
end
|
self.blockedBy = blockedBy
|
||||||
|
|
||||||
function Hero:attack(id, dx, dy)
|
|
||||||
local skill = game.skills:getSkillData("attack")
|
|
||||||
self.choregraphy:start(skill, dx, dy)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Hero:useSkill(id, dx, dy)
|
|
||||||
local skill = game.skills:getSkillData(id)
|
|
||||||
self:setPP(skill.cost * -1, true)
|
|
||||||
self.choregraphy:start(skill, dx, dy)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Hero:updateChoregraphy(dt)
|
|
||||||
self.choregraphy:update(dt)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Hero:blockChoregraphy(isBlocked, blockedBy)
|
|
||||||
if (isBlocked) then
|
|
||||||
self.blockingChoregraphy = blockedBy
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:unblockChoregraphy()
|
function Hero:unblockChoregraphy()
|
||||||
self.choregraphy:endAction()
|
self.currentlyBlocking:finish()
|
||||||
self.blockingChoregraphy = ""
|
self.currentlyBlocking = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
function Hero:receiveSignal(signal)
|
||||||
|
if (self.currentlyBlocking ~= nil) then
|
||||||
|
self:unblockChoregraphy()
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- ASSETS FUNCTIONS
|
-- ASSETS FUNCTIONS
|
||||||
|
@ -274,7 +182,7 @@ function Hero:initSprite()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Hero:animationEnded(animation)
|
function Hero:animationEnded(animation)
|
||||||
if (animation == self.blockingChoregraphy) then
|
if (self.currentlyBlocking ~= nil and self.blockedBy=="animation") then
|
||||||
self:unblockChoregraphy()
|
self:unblockChoregraphy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue