Compare commits
4 Commits
main
...
feature/ai
| Author | SHA1 | Date | |
|---|---|---|---|
| 86512e2c90 | |||
| d6644fb799 | |||
| af05a9fde3 | |||
| 16084044e9 |
@ -21,19 +21,9 @@ local function closestCharacter(char)
|
||||
return charTarget
|
||||
end
|
||||
|
||||
--- @class AIBehavior : Behavior
|
||||
--- @field animationNode AnimationNode?
|
||||
--- @field target Vec3?
|
||||
local behavior = {}
|
||||
behavior.__index = behavior
|
||||
behavior.id = "ai"
|
||||
|
||||
function behavior.new()
|
||||
return setmetatable({}, behavior)
|
||||
end
|
||||
|
||||
--- @return Task<nil>
|
||||
function behavior:makeTurn()
|
||||
---@type {[Class]: fun(self): Task<nil>} возможно где-то здесь на объявлении типа сломается типизация
|
||||
local aiNature = {
|
||||
["dev_warrior"] = function(self)
|
||||
return function(callback) -- почему так, описано в Task
|
||||
self.owner:try(Tree.behaviors.spellcaster, function(spellB)
|
||||
local charTarget = closestCharacter(self.owner)
|
||||
@ -54,6 +44,28 @@ function behavior:makeTurn()
|
||||
end)
|
||||
end)
|
||||
end
|
||||
end,
|
||||
["dev_mage"] = function(self)
|
||||
return function(callback)
|
||||
print("etoh... bleh")
|
||||
callback()
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
|
||||
--- @class AIBehavior : Behavior
|
||||
--- @field animationNode AnimationNode?
|
||||
--- @field target Vec3?
|
||||
local behavior = {}
|
||||
behavior.__index = behavior
|
||||
behavior.id = "ai"
|
||||
|
||||
--- @param class Class
|
||||
function behavior.new(class)
|
||||
return setmetatable({
|
||||
makeTurn = aiNature[class]
|
||||
}, behavior)
|
||||
end
|
||||
|
||||
return behavior
|
||||
|
||||
@ -1,7 +1,10 @@
|
||||
--- @alias Class "dev_warrior"|"dev_mage"
|
||||
|
||||
--- @class StatsBehavior : Behavior
|
||||
--- @field hp integer
|
||||
--- @field mana integer
|
||||
--- @field initiative integer
|
||||
--- @field class Class
|
||||
--- @field isInTurnOrder boolean
|
||||
local behavior = {}
|
||||
behavior.__index = behavior
|
||||
@ -10,13 +13,15 @@ behavior.id = "stats"
|
||||
--- @param hp? integer
|
||||
--- @param mana? integer
|
||||
--- @param initiative? integer
|
||||
--- @param class? Class
|
||||
--- @param isInTurnOrder? boolean
|
||||
function behavior.new(hp, mana, initiative, isInTurnOrder)
|
||||
function behavior.new(hp, mana, initiative, class, isInTurnOrder)
|
||||
return setmetatable({
|
||||
hp = hp or 20,
|
||||
mana = mana or 10,
|
||||
initiative = initiative or 10,
|
||||
isInTurnOrder = isInTurnOrder or true
|
||||
class = class or "dev_warrior",
|
||||
isInTurnOrder = isInTurnOrder or true,
|
||||
}, behavior)
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user