Ajout des derniers développement #1
10 changed files with 137 additions and 39 deletions
|
@ -1,12 +1,20 @@
|
||||||
local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
||||||
local HeroFighter = FighterParent:extend()
|
local HeroFighter = FighterParent:extend()
|
||||||
|
|
||||||
|
local StatusBar = require "scenes.battlesystem.gui.statusbar"
|
||||||
|
|
||||||
local POSITIONS = {3, 1, 5}
|
local POSITIONS = {3, 1, 5}
|
||||||
local HEROES_LINE = 3;
|
local HEROES_LINE = 3;
|
||||||
|
|
||||||
function HeroFighter:new(owner, character, id)
|
function HeroFighter:new(owner, character, id)
|
||||||
self.name = character
|
self.name = character
|
||||||
self.super.new(self, owner, true, id)
|
self.super.new(self, owner, true, id)
|
||||||
|
|
||||||
|
self.statusbar = StatusBar(self)
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroFighter:updateAssets(dt)
|
||||||
|
self.statusbar:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function HeroFighter:getAbstract()
|
function HeroFighter:getAbstract()
|
||||||
|
@ -26,4 +34,14 @@ function HeroFighter:endAction()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- DRAW FUNCTIONS
|
||||||
|
function HeroFighter:drawIcon(x, y)
|
||||||
|
local iconID = 1
|
||||||
|
self.assets.tileset["charicons"]:drawTile(iconID, x, y)
|
||||||
|
end
|
||||||
|
|
||||||
|
function HeroFighter:drawHUD()
|
||||||
|
self.statusbar:draw()
|
||||||
|
end
|
||||||
|
|
||||||
return HeroFighter
|
return HeroFighter
|
||||||
|
|
|
@ -7,6 +7,7 @@ function FighterParent:new(owner, isHero, id)
|
||||||
self.turnSystem = owner.turnSystem
|
self.turnSystem = owner.turnSystem
|
||||||
self.world = owner.world
|
self.world = owner.world
|
||||||
self.isHero = isHero
|
self.isHero = isHero
|
||||||
|
self.assets = self.turnSystem.scene.assets
|
||||||
|
|
||||||
-- Note : l'ID est ici relatif à chaque quand, il n'est donc pas unique,
|
-- Note : l'ID est ici relatif à chaque quand, il n'est donc pas unique,
|
||||||
-- ce qui est unique étant le combo id + isHero
|
-- ce qui est unique étant le combo id + isHero
|
||||||
|
@ -34,6 +35,10 @@ function FighterParent:update(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FighterParent:updateAssets(dt)
|
||||||
|
-- Vide pour l'instant
|
||||||
|
end
|
||||||
|
|
||||||
function FighterParent:setActive()
|
function FighterParent:setActive()
|
||||||
counter = 0
|
counter = 0
|
||||||
self.isActive = true
|
self.isActive = true
|
||||||
|
@ -73,4 +78,11 @@ function FighterParent:canFight()
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- DRAW FUNCTIONS
|
||||||
|
|
||||||
|
function FighterParent:drawIcon(x, y)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
love.graphics.rectangle("fill", x, y, 16, 16)
|
||||||
|
end
|
||||||
|
|
||||||
return FighterParent
|
return FighterParent
|
||||||
|
|
|
@ -1,14 +1,23 @@
|
||||||
local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
local FighterParent = require "scenes.battlesystem.controllers.fighters.parent"
|
||||||
local VillainFighter = FighterParent:extend()
|
local VillainFighter = FighterParent:extend()
|
||||||
|
|
||||||
|
local SimpleHPBar = require "scenes.battlesystem.gui.simplehpbar"
|
||||||
|
|
||||||
local POSITIONS = {3, 1, 5}
|
local POSITIONS = {3, 1, 5}
|
||||||
local ENNEMY_LINE = 10;
|
local ENNEMY_LINE = 10;
|
||||||
|
|
||||||
function VillainFighter:new(owner, ennemy, id)
|
function VillainFighter:new(owner, ennemy, id)
|
||||||
self.name = ennemy
|
self.name = ennemy
|
||||||
self.super.new(self, owner, false, id)
|
self.super.new(self, owner, false, id)
|
||||||
|
|
||||||
|
self.hpbar = SimpleHPBar(self.abstract.hp)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function VillainFighter:updateAssets(dt)
|
||||||
|
self.hpbar:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
function VillainFighter:getAbstract()
|
function VillainFighter:getAbstract()
|
||||||
return game.ennemies:getEnnemyData(self.name)
|
return game.ennemies:getEnnemyData(self.name)
|
||||||
end
|
end
|
||||||
|
@ -26,4 +35,15 @@ function VillainFighter:endAction()
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- DRAW FUNCTIONS
|
||||||
|
function VillainFighter:drawIcon(x, y)
|
||||||
|
love.graphics.setColor(1, 0, 0, 1)
|
||||||
|
love.graphics.rectangle("fill", x, y, 16, 16)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
function VillainFighter:drawHUD(x, y)
|
||||||
|
self.hpbar:draw(x, y)
|
||||||
|
end
|
||||||
|
|
||||||
return VillainFighter
|
return VillainFighter
|
||||||
|
|
|
@ -3,15 +3,14 @@ local TurnController = Object:extend()
|
||||||
local Player = require "scenes.battlesystem.controllers.player"
|
local Player = require "scenes.battlesystem.controllers.player"
|
||||||
local Ennemy = require "scenes.battlesystem.controllers.ennemy"
|
local Ennemy = require "scenes.battlesystem.controllers.ennemy"
|
||||||
|
|
||||||
|
local HUD = require "scenes.battlesystem.gui.hud"
|
||||||
|
|
||||||
local maputils = require "scenes.battlesystem.utils"
|
local maputils = require "scenes.battlesystem.utils"
|
||||||
|
|
||||||
function TurnController:new(scene)
|
function TurnController:new(scene)
|
||||||
self.scene = scene
|
self.scene = scene
|
||||||
self.world = scene.world
|
self.world = scene.world
|
||||||
|
|
||||||
self.player = Player(self)
|
|
||||||
self.ennemies = Ennemy(self)
|
|
||||||
|
|
||||||
self.isActive = false
|
self.isActive = false
|
||||||
|
|
||||||
self.currentlyPlaying = ""
|
self.currentlyPlaying = ""
|
||||||
|
@ -24,13 +23,29 @@ function TurnController:new(scene)
|
||||||
self.actionList = {}
|
self.actionList = {}
|
||||||
|
|
||||||
self.currentFighter = nil
|
self.currentFighter = nil
|
||||||
|
|
||||||
|
self.hud = HUD(self)
|
||||||
|
|
||||||
|
self.player = Player(self)
|
||||||
|
self.ennemies = Ennemy(self)
|
||||||
end
|
end
|
||||||
|
|
||||||
function TurnController:startBattle()
|
function TurnController:startBattle()
|
||||||
self.isActive = true
|
self.isActive = true
|
||||||
|
self.hud:movePlayerHUD(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
function TurnController:finishBattle()
|
||||||
|
self.isBattleActive = false
|
||||||
|
self.actionlist = {}
|
||||||
|
self.hud:movePlayerHUD(false)
|
||||||
|
self.scene:finishBattle()
|
||||||
end
|
end
|
||||||
|
|
||||||
function TurnController:update(dt)
|
function TurnController:update(dt)
|
||||||
|
self.player:update(dt)
|
||||||
|
self.ennemies:update(dt)
|
||||||
|
self.hud:update(dt)
|
||||||
if (self.isActive) then
|
if (self.isActive) then
|
||||||
if (self.currentFighter ~= nil) then
|
if (self.currentFighter ~= nil) then
|
||||||
self.currentFighter:update(dt)
|
self.currentFighter:update(dt)
|
||||||
|
@ -47,7 +62,7 @@ function TurnController:nextAction()
|
||||||
self.turns.current = self.turns.current + 1
|
self.turns.current = self.turns.current + 1
|
||||||
core.debug:print("cbs/turns", "switching to next action")
|
core.debug:print("cbs/turns", "switching to next action")
|
||||||
end
|
end
|
||||||
--self.scene.hud:moveBattleCursor(self.turns.current)
|
self.hud:moveBattleCursor(self.turns.current)
|
||||||
|
|
||||||
self:startAction()
|
self:startAction()
|
||||||
end
|
end
|
||||||
|
@ -86,13 +101,15 @@ function TurnController:endAction()
|
||||||
self.currentlyPlaying = ""
|
self.currentlyPlaying = ""
|
||||||
end
|
end
|
||||||
|
|
||||||
function TurnController:drawTurnList(x, y)
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
function TurnController:sendSignalToCurrentBattler(signal, subSignal)
|
function TurnController:sendSignalToCurrentBattler(signal, subSignal)
|
||||||
self.actionList[self.turns.current].actor:receiveSignal(signal, subSignal)
|
self.actionList[self.turns.current].actor:receiveSignal(signal, subSignal)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function TurnController:draw()
|
||||||
|
self.hud:draw()
|
||||||
|
self.player:draw()
|
||||||
|
self.ennemies:draw()
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return TurnController
|
return TurnController
|
||||||
|
|
|
@ -20,7 +20,9 @@ function FighterControllerParent:setActive(activeActor)
|
||||||
end
|
end
|
||||||
|
|
||||||
function FighterControllerParent:update(dt)
|
function FighterControllerParent:update(dt)
|
||||||
|
for i, fighter in ipairs(self.list) do
|
||||||
|
fighter:updateAssets(dt)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function FighterControllerParent:endAction()
|
function FighterControllerParent:endAction()
|
||||||
|
@ -42,5 +44,9 @@ function FighterControllerParent:putActions(actionList)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function FighterControllerParent:draw()
|
||||||
|
--Aucun dessin par defaut, ils sont géré différements
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return FighterControllerParent
|
return FighterControllerParent
|
||||||
|
|
|
@ -14,4 +14,10 @@ function HeroFighterController:initHeroes()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function HeroFighterController:draw()
|
||||||
|
for i, hero in ipairs(self.list) do
|
||||||
|
hero:drawHUD()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
return HeroFighterController
|
return HeroFighterController
|
||||||
|
|
|
@ -4,11 +4,11 @@ local gui = require "game.modules.gui"
|
||||||
local TweenManager = require "game.modules.tweenmanager"
|
local TweenManager = require "game.modules.tweenmanager"
|
||||||
|
|
||||||
|
|
||||||
function HUD:new(scene)
|
function HUD:new(turns)
|
||||||
self.scene = scene
|
self.turns = turns
|
||||||
self.world = scene.world
|
self.scene = turns.scene
|
||||||
self.assets = scene.assets
|
self.world = self.scene.world
|
||||||
self.turns = scene.turns
|
self.assets = self.scene.assets
|
||||||
|
|
||||||
self.frame = gui.newBorder(424, 30, 4)
|
self.frame = gui.newBorder(424, 30, 4)
|
||||||
self.tweens = TweenManager(self)
|
self.tweens = TweenManager(self)
|
||||||
|
@ -38,14 +38,10 @@ function HUD:getPlayerHUDPosition()
|
||||||
end
|
end
|
||||||
|
|
||||||
function HUD:draw()
|
function HUD:draw()
|
||||||
for i, battler in ipairs(self.world.battlers) do
|
|
||||||
battler:drawHUD()
|
|
||||||
end
|
|
||||||
|
|
||||||
for i, action in ipairs(self.turns.actionList) do
|
for i, action in ipairs(self.turns.actionList) do
|
||||||
action.actor:drawIcon(4 + (i-1)*(20), 6)
|
action.fighter:drawIcon(4 + (i-1)*(20), 6)
|
||||||
end
|
end
|
||||||
local cursorx = self.battlerCursor * 20 - 6
|
local cursorx = self.battlerCursor * 20 - 8
|
||||||
|
|
||||||
if #self.turns.actionList > 0 then
|
if #self.turns.actionList > 0 then
|
||||||
self.assets.images["menucursor"]:draw(cursorx, 26, math.rad(-90), 1, 1, 4, 8)
|
self.assets.images["menucursor"]:draw(cursorx, 26, math.rad(-90), 1, 1, 4, 8)
|
||||||
|
|
29
sonic-radiance.love/scenes/battlesystem/gui/simplehpbar.lua
Normal file
29
sonic-radiance.love/scenes/battlesystem/gui/simplehpbar.lua
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
local SimpleHPBar = Object:extend()
|
||||||
|
|
||||||
|
local TweenManager = require "game.modules.tweenmanager"
|
||||||
|
local gui = require "game.modules.gui"
|
||||||
|
|
||||||
|
function SimpleHPBar:new(hp)
|
||||||
|
self.tweens = TweenManager(self)
|
||||||
|
self.hp = hp
|
||||||
|
self.baseHP = hp
|
||||||
|
end
|
||||||
|
|
||||||
|
function SimpleHPBar:setHP(newHP)
|
||||||
|
self.tweens:newTween(0, 0.1, {hp = newHP}, 'inCubic')
|
||||||
|
end
|
||||||
|
|
||||||
|
function SimpleHPBar:update(dt)
|
||||||
|
self.tweens:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
function SimpleHPBar:draw(x, y)
|
||||||
|
love.graphics.setColor(0, 0, 0, 1)
|
||||||
|
gui.drawBar(x, y, 26, 4)
|
||||||
|
love.graphics.setColor(248/255, 160/255, 0, 1)
|
||||||
|
local bar = math.floor(24 * (self.hp / self.baseHP))
|
||||||
|
gui.drawBar(x, y + 1, bar, 2)
|
||||||
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
|
end
|
||||||
|
|
||||||
|
return SimpleHPBar
|
|
@ -6,16 +6,17 @@ local gui = require "game.modules.gui"
|
||||||
local HUDBASE = 8
|
local HUDBASE = 8
|
||||||
local HUDSEP = 152
|
local HUDSEP = 152
|
||||||
|
|
||||||
function StatusBar:new(actor)
|
function StatusBar:new(fighter)
|
||||||
self.actor = actor
|
self.fighter = fighter
|
||||||
self.hud = self.actor.scene.hud
|
self.hud = fighter.turnSystem.hud
|
||||||
self.assets = self.actor.assets
|
self.assets = self.fighter.assets
|
||||||
|
|
||||||
self.charid = self.actor.charid
|
self.charid = self.fighter.name
|
||||||
self.stats = game.characters.list[self.charid].stats
|
self.stats = self.fighter:getStats()
|
||||||
|
self.abstract = self.fighter.abstract
|
||||||
|
|
||||||
self.hp = self.stats.hp
|
self.hp = self.abstract.hp
|
||||||
self.pp = self.stats.pp
|
self.pp = self.abstract.pp
|
||||||
|
|
||||||
self.tweens = TweenManager(self)
|
self.tweens = TweenManager(self)
|
||||||
end
|
end
|
||||||
|
@ -41,8 +42,8 @@ function StatusBar:drawEmblem(x, y)
|
||||||
end
|
end
|
||||||
|
|
||||||
function StatusBar:draw()
|
function StatusBar:draw()
|
||||||
local x = HUDBASE + (self.actor.charnumber-1)*HUDSEP
|
local x = HUDBASE + (self.fighter.id-1)*HUDSEP
|
||||||
local y = self.actor.scene.hud:getPlayerHUDPosition()
|
local y = self.hud:getPlayerHUDPosition()
|
||||||
|
|
||||||
self:drawEmblem(x, y)
|
self:drawEmblem(x, y)
|
||||||
self.assets.images["statusbar"]:draw(x+12, y-6)
|
self.assets.images["statusbar"]:draw(x+12, y-6)
|
||||||
|
@ -63,7 +64,7 @@ function StatusBar:draw()
|
||||||
love.graphics.print(math.floor(self.hp) .. "/" .. hpmax, x+34, y+5)
|
love.graphics.print(math.floor(self.hp) .. "/" .. hpmax, x+34, y+5)
|
||||||
love.graphics.print(math.floor(self.pp) .. "/" .. ppmax, x+28, y+17)
|
love.graphics.print(math.floor(self.pp) .. "/" .. ppmax, x+28, y+17)
|
||||||
|
|
||||||
local lvl = game.characters.list[self.charid].stats.level
|
local lvl = self.abstract.level
|
||||||
|
|
||||||
if lvl < 100 then
|
if lvl < 100 then
|
||||||
lvl = "0" .. lvl
|
lvl = "0" .. lvl
|
||||||
|
|
|
@ -6,8 +6,6 @@ local World = require "scenes.battlesystem.world"
|
||||||
local MenuSystem = require "scenes.battlesystem.menu"
|
local MenuSystem = require "scenes.battlesystem.menu"
|
||||||
local Turns = require "scenes.battlesystem.controllers"
|
local Turns = require "scenes.battlesystem.controllers"
|
||||||
|
|
||||||
local HUD = require "scenes.battlesystem.gui.hud"
|
|
||||||
|
|
||||||
local VictoryScreen = require "scenes.battlesystem.screens.victory"
|
local VictoryScreen = require "scenes.battlesystem.screens.victory"
|
||||||
|
|
||||||
function BattleSystem:new()
|
function BattleSystem:new()
|
||||||
|
@ -32,17 +30,13 @@ function BattleSystem:initManagers()
|
||||||
self.world = World(self)
|
self.world = World(self)
|
||||||
self.menu = MenuSystem(self)
|
self.menu = MenuSystem(self)
|
||||||
self.turns = Turns(self)
|
self.turns = Turns(self)
|
||||||
|
|
||||||
self.hud = HUD(self)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleSystem:startBattle()
|
function BattleSystem:startBattle()
|
||||||
self.turns:startBattle()
|
self.turns:startBattle()
|
||||||
self.hud:movePlayerHUD(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function BattleSystem:finishBattle()
|
function BattleSystem:finishBattle()
|
||||||
self.hud:movePlayerHUD(false)
|
|
||||||
self.assets:setMusic("assets/music/victory.mp3")
|
self.assets:setMusic("assets/music/victory.mp3")
|
||||||
self.assets:playMusic()
|
self.assets:playMusic()
|
||||||
self.screen = VictoryScreen(self)
|
self.screen = VictoryScreen(self)
|
||||||
|
@ -58,7 +52,6 @@ end
|
||||||
function BattleSystem:update(dt)
|
function BattleSystem:update(dt)
|
||||||
self.world:update(dt)
|
self.world:update(dt)
|
||||||
self.turns:update(dt)
|
self.turns:update(dt)
|
||||||
self.hud:update(dt)
|
|
||||||
if (self.screen ~= nil) then
|
if (self.screen ~= nil) then
|
||||||
self.screen:update(dt)
|
self.screen:update(dt)
|
||||||
end
|
end
|
||||||
|
@ -66,7 +59,7 @@ end
|
||||||
|
|
||||||
function BattleSystem:draw()
|
function BattleSystem:draw()
|
||||||
self.world:draw()
|
self.world:draw()
|
||||||
self.hud:draw()
|
self.turns:draw()
|
||||||
if (self.screen ~= nil) then
|
if (self.screen ~= nil) then
|
||||||
self.screen:draw()
|
self.screen:draw()
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue