diff --git a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua index 904461c..70d38e3 100644 --- a/sonic-radiance.love/scenes/battlesystem/actors/hero.lua +++ b/sonic-radiance.love/scenes/battlesystem/actors/hero.lua @@ -152,6 +152,7 @@ function Hero:updateMoving(dt) self.y = self.dy self:changeAnimation("idle") self.currentAction = "selectAttack" + self.world:resetActiveGrid() self.scene.menu:set( self ) end end @@ -215,6 +216,7 @@ end function Hero:receiveBackSignal() self.currentAction = "selectDirection" self.world.cursor:set(self.x, self.y) + self:changeAnimation("walk") end diff --git a/sonic-radiance.love/scenes/battlesystem/cursor.lua b/sonic-radiance.love/scenes/battlesystem/cursor.lua index 6297e83..844935c 100644 --- a/sonic-radiance.love/scenes/battlesystem/cursor.lua +++ b/sonic-radiance.love/scenes/battlesystem/cursor.lua @@ -26,6 +26,8 @@ function Cursor:set(x, y) self.ty = self.y self.isActive = true + + self.world:setActiveGridFromGrid(self.grid) end function Cursor:setGrid(ox, oy, shape, size, direction, whitelistedEntity) @@ -44,6 +46,8 @@ function Cursor:setGrid(ox, oy, shape, size, direction, whitelistedEntity) end end end + + self.world:setActiveGridFromGrid(self.grid) end function Cursor:testPoint(x, y, whitelistedActor) @@ -122,7 +126,7 @@ function Cursor:update(dt) end function Cursor:addTween() - self.tweens:newTween(0, 0.2, {tx = self.x, ty = self.y}, 'inCubic') + self.tweens:newTween(0, 0.2, {tx = self.x, ty = self.y}, 'linear') end function Cursor:drawBottom() diff --git a/sonic-radiance.love/scenes/battlesystem/menu.lua b/sonic-radiance.love/scenes/battlesystem/menu.lua index fc458a2..609fccc 100644 --- a/sonic-radiance.love/scenes/battlesystem/menu.lua +++ b/sonic-radiance.love/scenes/battlesystem/menu.lua @@ -135,6 +135,22 @@ function CharMenuWidget:new(scene, menu_name, label1, label2, character) local font = scene.assets.fonts["small"] CharMenuWidget.super.new(self, menu, font, core.lang:translate("battle", label1)) self.label2 = label2 or "" + self.isSelected = false +end + +function CharMenuWidget:update(dt) + CharMenuWidget.super.update(self, dt) +end + +function CharMenuWidget:selectAction() + self.isSelected = true + if self.actionType == "attack" then + self.scene.world:resetActiveGrid() + self.scene.world:setEffectGrid(self.character.x + self.character.direction, self.character.y, "point", 1, 1) + else + self.scene.world:resetActiveGrid() + self.scene.world:resetEffectGrid() + end end function CharMenuWidget:drawCanvas() @@ -204,6 +220,33 @@ function SkillWidget:new(scene, menu_name, label1, label2, character) end end +function SkillWidget:selectAction() + if self.skilldata ~= nil then + if self.skilldata.target == nil then + local x = self.character.x + self.skilldata.effectArea[1] + local y = self.character.y + self.skilldata.effectArea[2] + local shape = self.skilldata.effectArea[3] + local size = self.skilldata.effectArea[4] + local direction = self.character.direction + self.scene.world:resetActiveGrid() + self.scene.world:setEffectGrid(x, y, shape, size, direction) + else + local x = self.character.x + self.skilldata.target[1] + local y = self.character.y + self.skilldata.target[2] + local shape = self.skilldata.target[3] + local size = self.skilldata.target[4] + local direction = self.character.direction + self.scene.world:setActiveGrid(x, y, shape, size, direction) + self.scene.world:resetEffectGrid() + end + + else + self.scene.world:resetActiveGrid() + self.scene.world:resetEffectGrid() + end +end + + function SkillWidget:drawCanvas() local h local asset = love.graphics.newImage("assets/gui/attacklist.png") diff --git a/sonic-radiance.love/scenes/battlesystem/world.lua b/sonic-radiance.love/scenes/battlesystem/world.lua index 9110ff3..2cd6a09 100644 --- a/sonic-radiance.love/scenes/battlesystem/world.lua +++ b/sonic-radiance.love/scenes/battlesystem/world.lua @@ -46,6 +46,9 @@ function World:new(scene, battlefile) self.tweens = TweenManager(self) + self:resetActiveGrid() + self:resetEffectGrid() + self:initHeroes() self:initEnnemies() self:initHUD() @@ -274,14 +277,34 @@ function World:sendSignalToCurrentBattler() self.actionlist[self.turns.current].actor:validateAction() end +-- ACTIVEGRID FUNCTIONS +-- Help to handle the activeGrid system + +function World:resetActiveGrid() + self.activeGrid = maputils.newFullMap() +end + +function World:setActiveGrid(ox, oy, shape, size, direction) + self.activeGrid = maputils.maskToMap(ox, oy, shape, size, direction) +end + +function World:setActiveGridFromGrid(grid) + self.activeGrid = grid +end + +function World:resetEffectGrid() + self.effectGrid = maputils.newEmptyMap() +end + +function World:setEffectGrid(ox, oy, shape, size, direction) + self.effectGrid = maputils.maskToMap(ox, oy, shape, size, direction) +end -- DRAW FUNCTION -- Draw the world function World:draw() - local activeGrid = self.cursor:getGrid() - - self.map:draw(activeGrid) + self.map:draw(self.activeGrid, self.effectGrid) self.cursor:drawBottom() self:drawShadows() self:drawActors()