From d0d0b0d985b145c58b01c699838723cc5056cbba Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Fri, 5 Jun 2020 10:02:04 +0200 Subject: [PATCH] wip: rework battler --- .../scenes/battlesystem/actors/battler.lua | 2 + .../scenes/battlesystem/actors/ennemy.lua | 1 + .../scenes/battlesystem/actors/hero.lua | 1 + .../battlesystem/controllers/ennemy.lua | 0 .../battlesystem/controllers/player.lua | 22 ++++++++++ .../controllers/subcontrol/move.lua | 40 +++++++++++++++++++ .../controllers/subcontrol/parent.lua | 0 .../scenes/overworld/actors/player.lua | 0 sonic-radiance.love/scenes/overworld/init.lua | 4 ++ 9 files changed, 70 insertions(+) create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/player.lua create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/move.lua create mode 100644 sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/parent.lua create mode 100644 sonic-radiance.love/scenes/overworld/actors/player.lua diff --git a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua index c531968..c48bb6c 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/battler.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/battler.lua @@ -8,6 +8,8 @@ function Battler:new(world, x, y, z) self.speed = 3 self.isActive = false self.debugActiveTimer = 0 + + self.side = "" end function Battler:destroy() diff --git a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua index 58aeadc..758d4fb 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/ennemy.lua @@ -15,6 +15,7 @@ function Ennemy:new(world, x, y, id, number) self.pp = self.data.stats.ppmax self.shownHP = self.hp + self.side = "ennemy" end function Ennemy:draw() diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index 7c71e50..af76245 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -25,6 +25,7 @@ function Hero:new(world, x, y, charid, charnumber) self.statusbar = StatusBar(self) self.side = "heroes" + self.doing = "nothing"; end -- CHARACTER FUNCTIONS diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua b/sonic-radiance.love/scenes/battlesystem/controllers/ennemy.lua new file mode 100644 index 0000000..e69de29 diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/player.lua b/sonic-radiance.love/scenes/battlesystem/controllers/player.lua new file mode 100644 index 0000000..a20295e --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/player.lua @@ -0,0 +1,22 @@ +local Player = Object:extend() + +function Player:init() + self.activeActor = nil + self.currentScreen = "" +end + +function Player:beginTurn(activeActor) + self.activeActor = activeActor + self.startx, self.starty = self.activeActor.x, self.activeActor.y + self.currentScreen = MoveScreen(self) + core.debug:print("cbs/hero", "hero " .. self.activeActor.charid .. " is now active") + self.characterData = game.characters.list[self.activeActor.charid] + + self:initializeCursor() +end + +function Player:initializeCursor() + +end + +return Player diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/move.lua b/sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/move.lua new file mode 100644 index 0000000..e367101 --- /dev/null +++ b/sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/move.lua @@ -0,0 +1,40 @@ +local MoveSubController = Object:extend() + +function MoveSubController:new(player) + self.player = player + self.actor = player.activeActor + self.characterData = game.characters.list[self.actor.charid] +end + +function MoveSubController:initAction() + local x, y = utils.math.round(self.actor.x), utils.math.round(self.actor.y) + local gridSize = self:getGridSize() + + self.world.cursor:setGrid(x, y, "circle", gridsize, 1, self) + self.world.cursor:set(self.startx, self.starty) +end + +function MoveSubController:getGridSize() + local gridsize = self.characterData.move + if (gridsize == nil) then + gridsize = 3 + core.debug:warning("cbs/move", "move value is nil") + end + return gridsize +end + +function MoveSubController:receiveCursorSignal(x, y, cancel) + -- Comme ceci est la PREMIERE action du personnage, il n'y a pas de cancel + -- possible, puisque rien n'a été fait. + + self.actor:changeAnimation("walk", true) + self.actor:goTo(x, y, 'cursorMove', 1) + self.actor.assets.sfx["woosh"]:play() + self.actor:blockTurnSystem() +end + +function MoveSubController:moveComplete() + +end + +return MoveSubController diff --git a/sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/parent.lua b/sonic-radiance.love/scenes/battlesystem/controllers/subcontrol/parent.lua new file mode 100644 index 0000000..e69de29 diff --git a/sonic-radiance.love/scenes/overworld/actors/player.lua b/sonic-radiance.love/scenes/overworld/actors/player.lua new file mode 100644 index 0000000..e69de29 diff --git a/sonic-radiance.love/scenes/overworld/init.lua b/sonic-radiance.love/scenes/overworld/init.lua index b42be75..9befae1 100644 --- a/sonic-radiance.love/scenes/overworld/init.lua +++ b/sonic-radiance.love/scenes/overworld/init.lua @@ -1,11 +1,15 @@ local Scene = require "core.modules.scenes" local OverWorld = Scene:extend() +local World = require "core.modules.world.world2D" + function OverWorld:new() OverWorld.super.new(self) + World(self, actorlist, mapfile, maptype) end function OverWorld:update(dt) + end function OverWorld:draw()