make all 3 demo spells work with tasks
This commit is contained in:
parent
59cc0fba0b
commit
e02c221e31
@ -22,7 +22,7 @@ function spell:update(caster, dt) end
|
|||||||
|
|
||||||
function spell:draw() end
|
function spell:draw() end
|
||||||
|
|
||||||
function spell:cast(caster, target) return true end
|
function spell:cast(caster, target) return end
|
||||||
|
|
||||||
local walk = setmetatable({
|
local walk = setmetatable({
|
||||||
--- @type Deque
|
--- @type Deque
|
||||||
@ -55,32 +55,9 @@ function walk:cast(caster, target)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local testChar = Tree.level.characters[1];
|
return function(callback)
|
||||||
|
|
||||||
|
|
||||||
return function(callback) -- <- вызовется после всех анимаций
|
|
||||||
local counter = require 'lib.utils.counter' (callback)
|
|
||||||
counter.push()
|
|
||||||
return caster:has(Tree.behaviors.tiled):followPath(path)(
|
return caster:has(Tree.behaviors.tiled):followPath(path)(
|
||||||
function()
|
callback
|
||||||
do
|
|
||||||
counter.push()
|
|
||||||
local initialPos2 = caster:has(Tree.behaviors.positioned).position:floor()
|
|
||||||
local path2 = require "lib.pathfinder" (initialPos2, Vec3 { 10, math.random(1, 10) })
|
|
||||||
path:pop_front()
|
|
||||||
caster:has(Tree.behaviors.tiled):followPath(path2)(counter.pop)
|
|
||||||
end
|
|
||||||
|
|
||||||
do
|
|
||||||
counter.push()
|
|
||||||
local testInitialPos = testChar:has(Tree.behaviors.positioned).position:floor()
|
|
||||||
local testPath = require "lib.pathfinder" (testInitialPos, Vec3 { 10, math.random(20, 5) })
|
|
||||||
path:pop_front()
|
|
||||||
testChar:has(Tree.behaviors.tiled):followPath(testPath)(counter.pop)
|
|
||||||
end
|
|
||||||
|
|
||||||
counter.pop()
|
|
||||||
end
|
|
||||||
) -- <- callback вызовется после followPath
|
) -- <- callback вызовется после followPath
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -114,9 +91,10 @@ function regenerateMana:cast(caster, target)
|
|||||||
stats.mana = 10
|
stats.mana = 10
|
||||||
stats.initiative = stats.initiative + 10
|
stats.initiative = stats.initiative + 10
|
||||||
end)
|
end)
|
||||||
print(caster.id, "has regenerated mana and gained initiative")
|
|
||||||
local sprite = caster:has(Tree.behaviors.sprite)
|
local sprite = caster:has(Tree.behaviors.sprite)
|
||||||
if not sprite then return nil end
|
if not sprite then return nil end
|
||||||
|
print(caster.id, "has regenerated mana and gained initiative")
|
||||||
|
|
||||||
local light = require "lib/character/character".spawn("Light Effect")
|
local light = require "lib/character/character".spawn("Light Effect")
|
||||||
light:addBehavior {
|
light:addBehavior {
|
||||||
@ -126,11 +104,12 @@ function regenerateMana:cast(caster, target)
|
|||||||
}
|
}
|
||||||
|
|
||||||
return function(callback)
|
return function(callback)
|
||||||
print(light:has(Tree.behaviors.light).animateColor)
|
light:has(Tree.behaviors.light):animateColor(Vec3 {})(
|
||||||
light:has(Tree.behaviors.light):animateColor(Vec3 {})(function()
|
function()
|
||||||
light:die()
|
light:die()
|
||||||
callback()
|
end
|
||||||
end)
|
)
|
||||||
|
sprite:animate("hurt")(callback)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user