feat: initial qte parent
This commit is contained in:
parent
4184ef37a8
commit
e3acafc824
1 changed files with 71 additions and 33 deletions
|
@ -1,57 +1,83 @@
|
|||
local QteParent = Object:extend()
|
||||
|
||||
local TweenManager = require "game.modules.tweenmanager"
|
||||
|
||||
function QteParent:new(choregraphySystem, arguments)
|
||||
self.choregraphy = choregraphySystem
|
||||
self.arguments = arguments
|
||||
self.timer = 0
|
||||
self.origin = nil
|
||||
self.tweens = TweenManager(self)
|
||||
self.isBlocking = nil
|
||||
end
|
||||
|
||||
function QteParent:blockAction(action, blockProcess)
|
||||
if (blockProcess) then
|
||||
function QteParent:blockAction(action, isBlocked)
|
||||
if (isBlocked) then
|
||||
self.isBlocking = action
|
||||
end
|
||||
end
|
||||
|
||||
function QteParent:setOrigin(origin)
|
||||
self.origin = origin
|
||||
local x, y = 424/2, 240/2
|
||||
local argy = 24
|
||||
local battleCoord = false
|
||||
if (origin == "target") then
|
||||
local target = self.choregraphy.action.target
|
||||
x, y = target.actor:getCoordinate()
|
||||
battleCoord = true
|
||||
elseif (origin == "start") then
|
||||
x, y = self.choregraphy.actor.start.x, self.choregraphy.actor.start.y
|
||||
battleCoord = true
|
||||
elseif (origin == "actor") then
|
||||
x, y = self.choregraphy.actor:getCoordinate()
|
||||
battleCoord = true
|
||||
end
|
||||
if (not battleCoord) then
|
||||
self.x, self.y = x, y
|
||||
else
|
||||
x, y = self.choregraphy.world.map:gridToPixel(x, y, true)
|
||||
self.x, self.y = x, y - argy
|
||||
end
|
||||
end
|
||||
|
||||
function QteParent:drawButton(x, y, letter)
|
||||
local grayValue = .44
|
||||
local darkValue = .11
|
||||
love.graphics.setColor(grayValue, grayValue, grayValue, 1)
|
||||
love.graphics.circle("fill", x, y, 8, 8)
|
||||
love.graphics.setColor(darkValue, darkValue, darkValue, 1)
|
||||
love.graphics.circle("line", x, y, 8, 8)
|
||||
love.graphics.print(letter, x, y)
|
||||
utils.graphics.resetColor()
|
||||
end
|
||||
|
||||
function QteParent:updateStep(dt)
|
||||
function QteParent:updateQte(dt)
|
||||
if (not self.isStarted) then
|
||||
self:start()
|
||||
self.isStarted = true
|
||||
else
|
||||
self:update(dt)
|
||||
self:updateTimer(dt)
|
||||
self.tweens:update(dt)
|
||||
end
|
||||
end
|
||||
|
||||
function QteParent:update(dt)
|
||||
--
|
||||
end
|
||||
|
||||
function QteParent:updateTimer(dt)
|
||||
if (self.arguments.duration ~= nil) then
|
||||
self.timer = self.timer + dt
|
||||
if (self.timer > self.arguments.duration) then
|
||||
self:fail()
|
||||
end
|
||||
function QteParent:timerResponse(timer)
|
||||
if (timer == "qteTimer") then
|
||||
core.debug:print("qte", "Timer finished")
|
||||
self:finish(self:isSuccessOnEnd())
|
||||
end
|
||||
end
|
||||
|
||||
function QteParent:finish(success)
|
||||
self.choregraphy:endQte(success)
|
||||
if (self.isBlocking ~= nil) then
|
||||
self.isBlocking:getSignal("qteEnded")
|
||||
end
|
||||
end
|
||||
|
||||
-- USABLE FUNCTIONS
|
||||
-- Use these functions to access some of the API
|
||||
|
||||
function QteParent:setTimer(time)
|
||||
core.debug:print("qte", "Timer started with " .. time .. " seconds")
|
||||
self.tweens:newTimer(time, "qteTimer")
|
||||
end
|
||||
|
||||
function QteParent:delay(time)
|
||||
core.debug:print("qte", "Timer delayed by " .. time .. " seconds")
|
||||
self.tweens:delayTimer(time, "qteTimer", false)
|
||||
end
|
||||
|
||||
function QteParent:getTimerInfo()
|
||||
self.tweens:getTimerInfo("qteTimer")
|
||||
end
|
||||
|
||||
function QteParent:succes()
|
||||
self:finish(true)
|
||||
|
@ -61,11 +87,23 @@ function QteParent:fail()
|
|||
self:finish(false)
|
||||
end
|
||||
|
||||
function QteParent:finish(success)
|
||||
self.choregraphy:endQte(success)
|
||||
if (self.isBlocking ~= nil) then
|
||||
self.isBlocking:finish()
|
||||
end
|
||||
-- PUBLIC API
|
||||
-- The functions that the children must overrides
|
||||
|
||||
function QteParent:start()
|
||||
|
||||
end
|
||||
|
||||
function QteParent:update(dt)
|
||||
--
|
||||
end
|
||||
|
||||
function QteParent:isSuccessOnEnd()
|
||||
return false
|
||||
end
|
||||
|
||||
function QteParent:draw()
|
||||
|
||||
end
|
||||
|
||||
return QteParent
|
||||
|
|
Loading…
Reference in a new issue