Ajout des derniers développement #1

Merged
kazhnuz merged 68 commits from chronicles-cbs into master 2020-08-02 11:14:18 +02:00
7 changed files with 139 additions and 26 deletions
Showing only changes of commit 9ece46fbb5 - Show all commits

View file

@ -3,6 +3,7 @@ local HeroFighter = FighterParent:extend()
local StatusBar = require "scenes.battlesystem.gui.statusbar"
local SelectionSystem = require "scenes.battlesystem.controllers.fighters.systems.selection"
local actionList = require "scenes.battlesystem.controllers.fighters.systems.actions"
local POSITIONS = {3, 1, 5}
local HEROES_LINE = 3;
@ -13,15 +14,19 @@ function HeroFighter:new(owner, character, id)
self.statusbar = StatusBar(self)
self.currentAction = ""
self.actionArgument = ""
self.target = nil
self.action = nil
self.selection = nil
end
function HeroFighter:updateAssets(dt)
self.statusbar:update(dt)
if (self.action ~= nil) then
if (self.action.isStarted) then
self.action:update(dt)
end
end
end
function HeroFighter:update(dt)
@ -41,9 +46,7 @@ end
function HeroFighter:startAction()
core.debug:print("cbs/heroFighter", "launching the action menu")
self.currentAction = ""
self.actionArgument = ""
self.target = nil
self.action = nil
self.turnSystem.scene.menu:set( self )
end
@ -56,14 +59,35 @@ function HeroFighter:doNothing()
self:setInactive()
end
function HeroFighter:doBasicAction(action)
self.action = actionList[action](self)
self:verifyTargets()
end
function HeroFighter:verifyTargets()
local needTarget, targetEnnemies = self.action:needTarget()
if (needTarget) then
if (targetEnnemies) then
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies)
else
self.selection = SelectionSystem(self, self.owner)
end
else
self.action:start()
end
end
function HeroFighter:attack()
self.currentAction = "attack"
self.selection = SelectionSystem(self, self.owner.turnSystem.ennemies)
self:doBasicAction("attack")
end
function HeroFighter:receiveTarget(target)
self.selection = nil
self:setInactive()
if (self.action ~= nil) then
self.action:start()
end
end
function HeroFighter:goBackToMenu()
@ -71,6 +95,10 @@ function HeroFighter:goBackToMenu()
self.selection = nil
end
function HeroFighter:finishAction()
self:setInactive()
end
-- DRAW FUNCTIONS
function HeroFighter:drawIcon(x, y)
local iconID = 1

View file

@ -0,0 +1,17 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local AttackAction = ActionParent:extend()
function AttackAction:new(fighter)
AttackAction.super.new(self, fighter)
end
function AttackAction:needTarget()
return true, true
end
function AttackAction:startAction()
core.debug:print("cbs/action", "Starting attack action")
self:finishAction()
end
return AttackAction

View file

@ -0,0 +1,17 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local DefendAction = ActionParent:extend()
function DefendAction:new(fighter)
DefendAction.super.new(self, fighter)
end
function DefendAction:needTarget()
return false, false
end
function DefendAction:startAction()
core.debug:print("cbs/action", "Starting defend action")
self:finishAction()
end
return DefendAction

View file

@ -0,0 +1,17 @@
local ActionParent = require "scenes.battlesystem.controllers.fighters.systems.actions.parent"
local FleeAction = ActionParent:extend()
function FleeAction:new(fighter)
FleeAction.super.new(self, fighter)
end
function FleeAction:needTarget()
return false, false
end
function FleeAction:startAction()
core.debug:print("cbs/action", "Starting flee action")
self:finishAction()
end
return FleeAction

View file

@ -0,0 +1,9 @@
local actions = {}
actions.attack = require "scenes.battlesystem.controllers.fighters.systems.actions.attack"
--actions.skill = require "scenes.battlesystem.controllers.fighters.systems.actions.skill"
--actions.item = require "scenes.battlesystem.controllers.fighters.systems.actions.item"
actions.defend = require "scenes.battlesystem.controllers.fighters.systems.actions.defend"
actions.flee = require "scenes.battlesystem.controllers.fighters.systems.actions.flee"
return actions

View file

@ -0,0 +1,40 @@
local ActionParent = Object:extend()
function ActionParent:new(fighter)
self.fighter = fighter
self.target = nil
self.choregraphy = nil
self.isStarted = false
end
function ActionParent:update(dt)
if (self.choregraphy ~= nil) then
self.choregraphy:update(dt)
end
end
function ActionParent:needTarget()
-- needTarget, targetEnnemies
return false, false
end
function ActionParent:setTarget(target)
self.target = target
end
function ActionParent:start()
self.isStarted = true
self:startAction()
end
function ActionParent:startAction()
self:finishAction()
end
function ActionParent:finishAction()
self.fighter:finishAction()
end
return ActionParent

View file

@ -10,8 +10,6 @@ local SubMenuWidget = BattleWidget:extend()
local BackMenuWidget = BattleWidget:extend()
local SkillWidget = BattleWidget:extend()
local AttackWidget = ActionWidget:extend()
local MENUPOS_X1, MENUPOS_X2, MENUPOS_Y = 32, 32, 110
local MENU_WIDTH, MENU_ITEM_HEIGHT = 148, 17
local MENU_ITEM_NUMBER = 6
@ -40,7 +38,7 @@ end
function MenuConstructor:buildBaseMenu(character)
CharacterMenu(self.scene, "BaseMenu", MENUPOS_X1 - 16, MENUPOS_Y)
AttackWidget(character, "BaseMenu")
ActionWidget(character, "BaseMenu", "attack")
SubMenuWidget(character, "BaseMenu", "skills", "SkillMenu")
SubMenuWidget(character, "BaseMenu", "objects", "ObjectMenu")
ActionWidget(character, "BaseMenu", "defend")
@ -221,22 +219,9 @@ function ActionWidget:new(character, menu_name, action)
end
function ActionWidget:sendCharacterData()
self.character:doNothing()
self.character:doBasicAction(self.actionType)
end
-- AttackWidget
-- The basic action widget
function AttackWidget:new(character, menu_name)
self.actionType = "attack"
ActionWidget.super.new(self, character, menu_name, "attack", "")
end
function AttackWidget:sendCharacterData()
self.character:attack()
end
-- SubMenuWidget
-- A simple widget to change menu