Refonte pour utiliser le systeme de GUI #112
5 changed files with 29 additions and 44 deletions
|
@ -31,7 +31,6 @@ function ChoregraphySystem:new(action, choregraphy, subChoregraphy)
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChoregraphySystem:update(dt)
|
function ChoregraphySystem:update(dt)
|
||||||
self:updateQte(dt)
|
|
||||||
self:updateSteps(dt)
|
self:updateSteps(dt)
|
||||||
self.tweens:update(dt)
|
self.tweens:update(dt)
|
||||||
self:updateSubChoregraphies(dt)
|
self:updateSubChoregraphies(dt)
|
||||||
|
@ -49,9 +48,4 @@ function ChoregraphySystem:endChoregraphy()
|
||||||
self.fighter.turnSystem:applyDeath()
|
self.fighter.turnSystem:applyDeath()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ChoregraphySystem:draw()
|
|
||||||
self:drawQte()
|
|
||||||
self:drawSubChoregraphies()
|
|
||||||
end
|
|
||||||
|
|
||||||
return ChoregraphySystem
|
return ChoregraphySystem
|
||||||
|
|
|
@ -1,18 +1,23 @@
|
||||||
local QteParent = Object:extend()
|
local GuiElements = require "birb.modules.gui.elements.parent"
|
||||||
|
local QteParent = GuiElements:extend()
|
||||||
|
|
||||||
local TweenManager = require "birb.classes.time"
|
|
||||||
local Prompts = require "scenes.battlesystem.choregraphy.qte.prompts"
|
local Prompts = require "scenes.battlesystem.choregraphy.qte.prompts"
|
||||||
|
|
||||||
function QteParent:new(choregraphySystem, arguments)
|
function QteParent:new(choregraphySystem, arguments)
|
||||||
self.choregraphy = choregraphySystem
|
self.choregraphy = choregraphySystem
|
||||||
self.arguments = arguments
|
self.arguments = arguments
|
||||||
self.tweens = TweenManager(self)
|
|
||||||
self.isBlocking = nil
|
self.isBlocking = nil
|
||||||
self.prompts = Prompts(self)
|
self.prompts = Prompts(self)
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
self.timerActive = false
|
self.timerActive = false
|
||||||
self.isSuccess = false
|
self.isSuccess = false
|
||||||
self.tag = ""
|
self.tag = ""
|
||||||
|
|
||||||
|
QteParent.super.new(self, "qte", -1, -1, 1, 1)
|
||||||
|
|
||||||
|
self:start()
|
||||||
|
self.isStarted = true
|
||||||
|
self:getFocus()
|
||||||
end
|
end
|
||||||
|
|
||||||
function QteParent:setTag(tag)
|
function QteParent:setTag(tag)
|
||||||
|
@ -60,18 +65,13 @@ function QteParent:setOrigin(origin)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function QteParent:updateQte(dt, isActive)
|
function QteParent:updateElement(dt)
|
||||||
if (not self.isStarted) then
|
QteParent.super.updateElement(self, dt)
|
||||||
self:start()
|
|
||||||
self.isStarted = true
|
|
||||||
else
|
|
||||||
self:update(dt)
|
|
||||||
self.tweens:update(dt)
|
|
||||||
self.prompts:update(dt)
|
self.prompts:update(dt)
|
||||||
if (isActive) then
|
|
||||||
self:verifyPrompts()
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function QteParent:keypressed(key)
|
||||||
|
self:verifyPrompts(key)
|
||||||
end
|
end
|
||||||
|
|
||||||
function QteParent:timerResponse(timer)
|
function QteParent:timerResponse(timer)
|
||||||
|
@ -87,6 +87,7 @@ function QteParent:timerResponse(timer)
|
||||||
self.prompts.defaultTimerValue = 0
|
self.prompts.defaultTimerValue = 0
|
||||||
elseif (timer == "endQte") then
|
elseif (timer == "endQte") then
|
||||||
self.choregraphy:removeQte()
|
self.choregraphy:removeQte()
|
||||||
|
self:destroy()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -97,8 +98,8 @@ function QteParent:finish(success)
|
||||||
self:endQte()
|
self:endQte()
|
||||||
end
|
end
|
||||||
|
|
||||||
function QteParent:verifyPrompts()
|
function QteParent:verifyPrompts(key)
|
||||||
local promptResult = self.prompts:verifyPrompts()
|
local promptResult = self.prompts:verifyPrompts(key)
|
||||||
if (promptResult == 1) then
|
if (promptResult == 1) then
|
||||||
self:promptSuccess()
|
self:promptSuccess()
|
||||||
elseif (promptResult == -1) then
|
elseif (promptResult == -1) then
|
||||||
|
|
|
@ -69,15 +69,14 @@ function Button:update(dt, isFirst)
|
||||||
love.graphics.arc("fill", CANVAS_SIZE/2, CANVAS_SIZE/2, BTN_SIZE/2, 0 - (math.pi/2), ((math.pi*2*self.prompt:getTimer()) - (math.pi/2)), 16)
|
love.graphics.arc("fill", CANVAS_SIZE/2, CANVAS_SIZE/2, BTN_SIZE/2, 0 - (math.pi/2), ((math.pi*2*self.prompt:getTimer()) - (math.pi/2)), 16)
|
||||||
love.graphics.setStencilTest()
|
love.graphics.setStencilTest()
|
||||||
love.graphics.setCanvas()
|
love.graphics.setCanvas()
|
||||||
|
utils.graphics.resetColor()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Button:verifyPrompts(sourceKeys, removeWhenPressed)
|
function Button:verifyPrompts(key, removeWhenPressed)
|
||||||
local mustBeRemoved = false
|
local mustBeRemoved = false
|
||||||
local keyValue = 0
|
local keyValue = 0
|
||||||
self.lum = 1
|
self.lum = 1
|
||||||
for i, key in ipairs(keys) do
|
|
||||||
if (sourceKeys[key].isPressed) then
|
|
||||||
if (key == self.key) then
|
if (key == self.key) then
|
||||||
keyValue = 1
|
keyValue = 1
|
||||||
self.lum = 0.8
|
self.lum = 0.8
|
||||||
|
@ -86,8 +85,6 @@ function Button:verifyPrompts(sourceKeys, removeWhenPressed)
|
||||||
keyValue = -1
|
keyValue = -1
|
||||||
self.isFailed = true
|
self.isFailed = true
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
|
||||||
if (removeWhenPressed and keyValue == 1) then
|
if (removeWhenPressed and keyValue == 1) then
|
||||||
self.number = self.number - 1
|
self.number = self.number - 1
|
||||||
if (self.number == 0) then
|
if (self.number == 0) then
|
||||||
|
|
|
@ -31,11 +31,10 @@ function QtePrompts:update(dt)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function QtePrompts:verifyPrompts()
|
function QtePrompts:verifyPrompts(key)
|
||||||
local buttonValue, mustBeRemoved = 0, false
|
local buttonValue, mustBeRemoved = 0, false
|
||||||
if (self.list[self.current] ~= nil) then
|
if (self.list[self.current] ~= nil) then
|
||||||
local keys = self.scene.sources[1].keys
|
buttonValue, mustBeRemoved = self.list[self.current]:verifyPrompts(key, self.removeWhenPressed)
|
||||||
buttonValue, mustBeRemoved = self.list[self.current]:verifyPrompts(keys, self.removeWhenPressed)
|
|
||||||
if (not self.canPress and buttonValue == 1) then
|
if (not self.canPress and buttonValue == 1) then
|
||||||
buttonValue = -1
|
buttonValue = -1
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,10 +53,4 @@ function ActionParent:finishAction()
|
||||||
self.fighter:finishAction()
|
self.fighter:finishAction()
|
||||||
end
|
end
|
||||||
|
|
||||||
function ActionParent:draw()
|
|
||||||
if (self.choregraphy ~= nil) then
|
|
||||||
self.choregraphy:draw()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return ActionParent
|
return ActionParent
|
||||||
|
|
Loading…
Reference in a new issue