improvement(cbs): rework effect grid
This commit is contained in:
parent
27876928ab
commit
04817f1e51
3 changed files with 42 additions and 1 deletions
|
@ -1,6 +1,11 @@
|
||||||
local Map = Object:extend()
|
local Map = Object:extend()
|
||||||
|
|
||||||
local maputils = require "scenes.battlesystem.utils"
|
local maputils = require "scenes.battlesystem.utils"
|
||||||
|
local TweenManager = require "game.modules.tweenmanager"
|
||||||
|
|
||||||
|
local DURATION = 0.66
|
||||||
|
local OPACITY_MIN = 0
|
||||||
|
local OPACITY_MAX = 0.75
|
||||||
|
|
||||||
function Map:new(world, type, terrain)
|
function Map:new(world, type, terrain)
|
||||||
self.world = world
|
self.world = world
|
||||||
|
@ -11,6 +16,10 @@ function Map:new(world, type, terrain)
|
||||||
self.datas.type = type or "city"
|
self.datas.type = type or "city"
|
||||||
self.datas.terrains = terrain or maputils.newEmptyMap()
|
self.datas.terrains = terrain or maputils.newEmptyMap()
|
||||||
|
|
||||||
|
self.tweens = TweenManager(self)
|
||||||
|
self.effectOpacity = OPACITY_MIN
|
||||||
|
self:increaseOpacity()
|
||||||
|
|
||||||
local zones = require "datas.gamedata.maps.shoot.zones"
|
local zones = require "datas.gamedata.maps.shoot.zones"
|
||||||
local datas = zones[self.datas.type]
|
local datas = zones[self.datas.type]
|
||||||
self.datas.background = datas.background
|
self.datas.background = datas.background
|
||||||
|
@ -38,6 +47,31 @@ function Map:isInGrid(x, y)
|
||||||
return ( self:getTerrain(x, y) ~= nil )
|
return ( self:getTerrain(x, y) ~= nil )
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function Map:update(dt)
|
||||||
|
self.tweens:update(dt)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- OPACITY FUNCTIONS
|
||||||
|
-- Simple functions to work on opacity
|
||||||
|
|
||||||
|
function Map:decreaseOpacity()
|
||||||
|
self.tweens:newTween(0, DURATION/2, {effectOpacity = OPACITY_MIN}, "inExpo")
|
||||||
|
self.tweens:newTimer(DURATION/2, "increaseOpacity")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Map:increaseOpacity()
|
||||||
|
self.tweens:newTween(0, DURATION/2, {effectOpacity = OPACITY_MAX}, "inExpo")
|
||||||
|
self.tweens:newTimer(DURATION/2, "decreaseOpacity")
|
||||||
|
end
|
||||||
|
|
||||||
|
function Map:timerResponse(timer)
|
||||||
|
if timer == "increaseOpacity" then
|
||||||
|
self:increaseOpacity()
|
||||||
|
elseif timer == "decreaseOpacity" then
|
||||||
|
self:decreaseOpacity()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- DRAW FUNCTIONS
|
-- DRAW FUNCTIONS
|
||||||
-- Draw the battle map
|
-- Draw the battle map
|
||||||
|
|
||||||
|
@ -124,7 +158,7 @@ function Map:drawEffectGrid(effectGrid)
|
||||||
for j=1,17 do
|
for j=1,17 do
|
||||||
if (effectGrid[i][j] == 1) then
|
if (effectGrid[i][j] == 1) then
|
||||||
local x, y = maputils.gridToPixel(j, i)
|
local x, y = maputils.gridToPixel(j, i)
|
||||||
love.graphics.setColor(1, 1, 1, .2)
|
love.graphics.setColor(1, 1, 1, self.effectOpacity)
|
||||||
self.assets.images["emptytile"]:draw(x, y)
|
self.assets.images["emptytile"]:draw(x, y)
|
||||||
love.graphics.setColor(1, 1, 1, 1)
|
love.graphics.setColor(1, 1, 1, 1)
|
||||||
end
|
end
|
||||||
|
|
|
@ -167,6 +167,8 @@ function CharMenuWidget:drawCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
function CharMenuWidget:action()
|
function CharMenuWidget:action()
|
||||||
|
self.scene.world:resetActiveGrid()
|
||||||
|
self.scene.world:resetEffectGrid()
|
||||||
self.character:receiveSignal(self.actionType)
|
self.character:receiveSignal(self.actionType)
|
||||||
self.scene:flushKeys()
|
self.scene:flushKeys()
|
||||||
self.scene.menusystem:reset()
|
self.scene.menusystem:reset()
|
||||||
|
@ -190,6 +192,8 @@ function BackMenuWidget:new(scene, menu_name, label, character)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BackMenuWidget:action()
|
function BackMenuWidget:action()
|
||||||
|
self.scene.world:resetActiveGrid()
|
||||||
|
self.scene.world:resetEffectGrid()
|
||||||
self.character:receiveBackSignal()
|
self.character:receiveBackSignal()
|
||||||
self.scene:flushKeys()
|
self.scene:flushKeys()
|
||||||
self.scene.menusystem:reset()
|
self.scene.menusystem:reset()
|
||||||
|
@ -261,6 +265,8 @@ function SkillWidget:drawCanvas()
|
||||||
end
|
end
|
||||||
|
|
||||||
function SkillWidget:action()
|
function SkillWidget:action()
|
||||||
|
self.scene.world:resetActiveGrid()
|
||||||
|
self.scene.world:resetEffectGrid()
|
||||||
if self.skilldata ~= nil then
|
if self.skilldata ~= nil then
|
||||||
self.character:receiveSignal("skill", self.actionType)
|
self.character:receiveSignal("skill", self.actionType)
|
||||||
else
|
else
|
||||||
|
|
|
@ -198,6 +198,7 @@ function World:update(dt)
|
||||||
|
|
||||||
self.cursor:update(dt)
|
self.cursor:update(dt)
|
||||||
self.tweens:update(dt)
|
self.tweens:update(dt)
|
||||||
|
self.map:update(dt)
|
||||||
end
|
end
|
||||||
|
|
||||||
function World:moveBattleCursor(dt)
|
function World:moveBattleCursor(dt)
|
||||||
|
|
Loading…
Reference in a new issue