miduo_client/Assets/ManagedResources/~Lua/Modules/Battle/Logic/SkillManager.lua

103 lines
2.6 KiB
Lua
Raw Normal View History

2020-08-25 15:46:38 +08:00
SkillManager = {}
2020-05-09 13:31:21 +08:00
local this = SkillManager
local skillPool = BattleObjectPool.New(function ()
return Skill:New()
end)
--
this.SkillList = {}
this.IsSkilling = false
-- 初始化
function this.Init()
this.Clear()
end
-- 向技能列表中追加技能
function this.AddSkill(caster, effectData, type, targets, isAdd, isRage)
local skill = skillPool:Get()
skill:Init(caster, effectData, type, targets, isAdd, isRage)
table.insert(this.SkillList, skill)
return skill
end
-- 插入技能到技能列表首位
function this.InsertSkill(caster, effectData, type, targets, isAdd, isRage)
local skill = skillPool:Get()
skill:Init(caster, effectData, type, targets, isAdd, isRage)
table.insert(this.SkillList, 1, skill)
return skill
end
-- 获取是否拥有我的技能未释放
function this.HaveMySkill(role)
for _, skill in ipairs(this.SkillList) do
if skill.owner == role then
return true
end
end
return false
end
-- 设置用于轮转的方法
function this.SetTurnRoundFunc(func)
this.TurnRoundFunc = func
end
function this.CheckTurnRound()
if this.IsSkilling then
return
end
if this.SkillList and #this.SkillList > 0 then
return
end
-- 没有技能释放的时候才轮转
if this.TurnRoundFunc then
BattleLogic.WaitForTrigger(0.3, function()
this.TurnRoundFunc()
this.TurnRoundFunc = nil
end)
end
end
--
function this.Update()
--
if this.IsSkilling then
return
end
if not this.SkillList or #this.SkillList == 0 then
return
end
local skill = this.SkillList[1]
table.remove(this.SkillList, 1)
this.IsSkilling = true
-- 检测技能释放 只有角色不是死亡状态或角色身上有不灭 或这释放的技能为死亡后才释放的技能
--跟佳琦对的是角色死后只有死亡后释放的技能才能释放(DeadSkill) by:王振兴 2020/09/02 18:53
if (not skill.owner:IsDead() or not BattleUtil.CheckIsNoDead(skill.owner)) or skill.type == BattleSkillType.DeadSkill then
skill.owner:SkillCast(skill, function()
skill:Dispose()
skillPool:Put(skill)
this.IsSkilling = false
-- 检测一下轮转
this.CheckTurnRound()
end)
else
2020-05-09 13:31:21 +08:00
this.IsSkilling = false
this.CheckTurnRound()
end
2020-05-09 13:31:21 +08:00
end
-- 清除
function this.Clear()
for _, skill in ipairs(this.SkillList) do
skill:Dispose()
skillPool:Put(skill)
end
this.SkillList = {}
this.IsSkilling = false
end
return SkillManager