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 (needTarget) then
|
||||||
if (targetEnnemies) then
|
if (targetEnnemies) then
|
||||||
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies)
|
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies, true)
|
||||||
else
|
else
|
||||||
self.selection = SelectionSystem(self, self.owner)
|
self.selection = SelectionSystem(self, self.owner, false)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
self.action:start()
|
self.action:start()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local SelectionSystem = Object:extend()
|
local SelectionSystem = Object:extend()
|
||||||
|
|
||||||
function SelectionSystem:new(owner, fighterList)
|
function SelectionSystem:new(owner, fighterSide, onlyAlive)
|
||||||
self.fighterList = fighterList
|
self.fighterList = fighterSide:getTargets(onlyAlive)
|
||||||
self.owner = owner
|
self.owner = owner
|
||||||
self.assets = self.owner.assets
|
self.assets = self.owner.assets
|
||||||
self.selectedTarget = 1
|
self.selectedTarget = 1
|
||||||
|
@ -13,14 +13,14 @@ function SelectionSystem:update(dt)
|
||||||
self:purgeTarget()
|
self:purgeTarget()
|
||||||
if (keys["up"].isPressed) then
|
if (keys["up"].isPressed) then
|
||||||
if (self.selectedTarget == 1) then
|
if (self.selectedTarget == 1) then
|
||||||
self.selectedTarget = self.fighterList:count()
|
self.selectedTarget = #self.fighterList
|
||||||
else
|
else
|
||||||
self.selectedTarget = self.selectedTarget - 1
|
self.selectedTarget = self.selectedTarget - 1
|
||||||
end
|
end
|
||||||
self.assets.sfx["mBeep"]:play()
|
self.assets.sfx["mBeep"]:play()
|
||||||
end
|
end
|
||||||
if (keys["down"].isPressed) then
|
if (keys["down"].isPressed) then
|
||||||
if (self.selectedTarget == self.fighterList:count()) then
|
if (self.selectedTarget == #self.fighterList) then
|
||||||
self.selectedTarget = 1
|
self.selectedTarget = 1
|
||||||
else
|
else
|
||||||
self.selectedTarget = self.selectedTarget + 1
|
self.selectedTarget = self.selectedTarget + 1
|
||||||
|
@ -43,18 +43,18 @@ function SelectionSystem:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function SelectionSystem:purgeTarget()
|
function SelectionSystem:purgeTarget()
|
||||||
local target = self.fighterList:get(self.selectedTarget)
|
local target = self.fighterList[self.selectedTarget]
|
||||||
target.actor.isSelected = false
|
target.actor.isSelected = false
|
||||||
end
|
end
|
||||||
|
|
||||||
function SelectionSystem:updateTarget()
|
function SelectionSystem:updateTarget()
|
||||||
local target = self.fighterList:get(self.selectedTarget)
|
local target = self.fighterList[self.selectedTarget]
|
||||||
target.actor.isSelected = true
|
target.actor.isSelected = true
|
||||||
end
|
end
|
||||||
|
|
||||||
function SelectionSystem:selectTarget()
|
function SelectionSystem:selectTarget()
|
||||||
self:purgeTarget()
|
self:purgeTarget()
|
||||||
self.owner:receiveTarget(self.fighterList:get(self.selectedTarget))
|
self.owner:receiveTarget(self.fighterList[self.selectedTarget])
|
||||||
end
|
end
|
||||||
|
|
||||||
function SelectionSystem:goBack()
|
function SelectionSystem:goBack()
|
||||||
|
|
|
@ -18,6 +18,16 @@ function FighterControllerParent:count()
|
||||||
return #self.list
|
return #self.list
|
||||||
end
|
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()
|
function FighterControllerParent:applyDeath()
|
||||||
for i, fighter in ipairs(self.list) do
|
for i, fighter in ipairs(self.list) do
|
||||||
fighter:applyDeath()
|
fighter:applyDeath()
|
||||||
|
|
Loading…
Reference in a new issue