Refonte pour utiliser le systeme de GUI #112
2 changed files with 24 additions and 29 deletions
|
@ -12,15 +12,11 @@ function HeroFighter:new(owner, character, id)
|
|||
|
||||
self:initVoices()
|
||||
|
||||
self.selection = nil
|
||||
self.exp = self.abstract.exp
|
||||
end
|
||||
|
||||
function HeroFighter:update(dt)
|
||||
HeroFighter.super.update(self, dt)
|
||||
if (self.selection ~= nil) then
|
||||
self.selection:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
function HeroFighter:getAbstract()
|
||||
|
@ -72,9 +68,9 @@ function HeroFighter:verifyTargets()
|
|||
|
||||
if (needTarget) then
|
||||
if (targetEnnemies) then
|
||||
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies, true)
|
||||
SelectionSystem(self, self.owner.turnSystem.ennemies, true)
|
||||
else
|
||||
self.selection = SelectionSystem(self, self.owner, false)
|
||||
SelectionSystem(self, self.owner, false)
|
||||
end
|
||||
else
|
||||
self.action:start()
|
||||
|
@ -87,7 +83,6 @@ function HeroFighter:attack()
|
|||
end
|
||||
|
||||
function HeroFighter:receiveTarget(target)
|
||||
self.selection = nil
|
||||
if (self.action ~= nil) then
|
||||
self.action:setTarget(target)
|
||||
self.action:start()
|
||||
|
@ -96,7 +91,6 @@ end
|
|||
|
||||
function HeroFighter:goBackToMenu()
|
||||
self.turnSystem.scene.gui:setFocus("battleMenu")
|
||||
self.selection = nil
|
||||
end
|
||||
|
||||
-- LIFE functions
|
||||
|
|
|
@ -1,45 +1,42 @@
|
|||
local SelectionSystem = Object:extend()
|
||||
local GuiElement = require "birb.modules.gui.elements.parent"
|
||||
local SelectionSystem = GuiElement:extend()
|
||||
|
||||
function SelectionSystem:new(owner, fighterSide, onlyAlive)
|
||||
SelectionSystem.super.new(self, "selection", 0, 0, 1, 1)
|
||||
self.fighterList = fighterSide:getTargets(onlyAlive)
|
||||
self.owner = owner
|
||||
self.assets = self.owner.assets
|
||||
self.selectedTarget = 1
|
||||
self:updateTarget()
|
||||
self:getFocus()
|
||||
end
|
||||
|
||||
function SelectionSystem:update(dt)
|
||||
--Faire en sorte que cela permette de choisir la cible
|
||||
local keys = self.owner.turnSystem.scene:getKeys(1)
|
||||
function SelectionSystem:keypressed(key)
|
||||
if (key == "A") then
|
||||
self.assets.sfx["mSelect"]:play()
|
||||
self:selectTarget()
|
||||
elseif (key == "B") then
|
||||
self.assets.sfx["mBack"]:play()
|
||||
self:goBack()
|
||||
elseif (key == "up") then
|
||||
self:purgeTarget()
|
||||
if (keys["up"].isPressed) then
|
||||
if (self.selectedTarget == 1) then
|
||||
self.selectedTarget = #self.fighterList
|
||||
else
|
||||
self.selectedTarget = self.selectedTarget - 1
|
||||
end
|
||||
self.assets.sfx["mBeep"]:play()
|
||||
end
|
||||
if (keys["down"].isPressed) then
|
||||
self:updateTarget()
|
||||
elseif (key == "down") then
|
||||
self:purgeTarget()
|
||||
if (self.selectedTarget == #self.fighterList) then
|
||||
self.selectedTarget = 1
|
||||
else
|
||||
self.selectedTarget = self.selectedTarget + 1
|
||||
end
|
||||
self.assets.sfx["mBeep"]:play()
|
||||
end
|
||||
|
||||
self:updateTarget()
|
||||
|
||||
if (keys["A"].isPressed) then
|
||||
self.assets.sfx["mSelect"]:play()
|
||||
self:selectTarget()
|
||||
end
|
||||
|
||||
if (keys["B"].isPressed) then
|
||||
self.assets.sfx["mBack"]:play()
|
||||
self:goBack()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function SelectionSystem:purgeTarget()
|
||||
|
@ -53,11 +50,15 @@ function SelectionSystem:updateTarget()
|
|||
end
|
||||
|
||||
function SelectionSystem:selectTarget()
|
||||
self:looseFocus()
|
||||
self:destroy()
|
||||
self:purgeTarget()
|
||||
self.owner:receiveTarget(self.fighterList[self.selectedTarget])
|
||||
end
|
||||
|
||||
function SelectionSystem:goBack()
|
||||
self:looseFocus()
|
||||
self:destroy()
|
||||
self:purgeTarget()
|
||||
self.owner:goBackToMenu()
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue