Ajout des derniers développement #1
3 changed files with 19 additions and 9 deletions
|
@ -81,9 +81,9 @@ function HeroFighter:verifyTargets()
|
|||
|
||||
if (needTarget) then
|
||||
if (targetEnnemies) then
|
||||
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies)
|
||||
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies, true)
|
||||
else
|
||||
self.selection = SelectionSystem(self, self.owner)
|
||||
self.selection = SelectionSystem(self, self.owner, false)
|
||||
end
|
||||
else
|
||||
self.action:start()
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
local SelectionSystem = Object:extend()
|
||||
|
||||
function SelectionSystem:new(owner, fighterList)
|
||||
self.fighterList = fighterList
|
||||
function SelectionSystem:new(owner, fighterSide, onlyAlive)
|
||||
self.fighterList = fighterSide:getTargets(onlyAlive)
|
||||
self.owner = owner
|
||||
self.assets = self.owner.assets
|
||||
self.selectedTarget = 1
|
||||
|
@ -13,14 +13,14 @@ function SelectionSystem:update(dt)
|
|||
self:purgeTarget()
|
||||
if (keys["up"].isPressed) then
|
||||
if (self.selectedTarget == 1) then
|
||||
self.selectedTarget = self.fighterList:count()
|
||||
self.selectedTarget = #self.fighterList
|
||||
else
|
||||
self.selectedTarget = self.selectedTarget - 1
|
||||
end
|
||||
self.assets.sfx["mBeep"]:play()
|
||||
end
|
||||
if (keys["down"].isPressed) then
|
||||
if (self.selectedTarget == self.fighterList:count()) then
|
||||
if (self.selectedTarget == #self.fighterList) then
|
||||
self.selectedTarget = 1
|
||||
else
|
||||
self.selectedTarget = self.selectedTarget + 1
|
||||
|
@ -43,18 +43,18 @@ function SelectionSystem:update(dt)
|
|||
end
|
||||
|
||||
function SelectionSystem:purgeTarget()
|
||||
local target = self.fighterList:get(self.selectedTarget)
|
||||
local target = self.fighterList[self.selectedTarget]
|
||||
target.actor.isSelected = false
|
||||
end
|
||||
|
||||
function SelectionSystem:updateTarget()
|
||||
local target = self.fighterList:get(self.selectedTarget)
|
||||
local target = self.fighterList[self.selectedTarget]
|
||||
target.actor.isSelected = true
|
||||
end
|
||||
|
||||
function SelectionSystem:selectTarget()
|
||||
self:purgeTarget()
|
||||
self.owner:receiveTarget(self.fighterList:get(self.selectedTarget))
|
||||
self.owner:receiveTarget(self.fighterList[self.selectedTarget])
|
||||
end
|
||||
|
||||
function SelectionSystem:goBack()
|
||||
|
|
|
@ -18,6 +18,16 @@ function FighterControllerParent:count()
|
|||
return #self.list
|
||||
end
|
||||
|
||||
function FighterControllerParent:getTargets(onlyAlive)
|
||||
local targetList = {}
|
||||
for i, fighter in ipairs(self.list) do
|
||||
if (fighter:canFight() or (not onlyAlive)) then
|
||||
table.insert(targetList, fighter)
|
||||
end
|
||||
end
|
||||
return targetList
|
||||
end
|
||||
|
||||
function FighterControllerParent:applyDeath()
|
||||
for i, fighter in ipairs(self.list) do
|
||||
fighter:applyDeath()
|
||||
|
|
Loading…
Reference in a new issue