战斗同步
parent
ea09a2f3d3
commit
8c09de153d
|
@ -275,7 +275,9 @@ function BuffManager:PassUpdate()
|
|||
local buff = buffList.buffer[index]
|
||||
if not buff.disperse -- 没过期
|
||||
and buff.caster.camp == curCamp -- 释放者是当前轮到的人
|
||||
and buff.caster.position == curPos then
|
||||
and buff.caster.position == curPos
|
||||
and buff.roundDuration > 0 -- 不是无限存在的buff
|
||||
then
|
||||
-- 当前轮释放的buff不结算
|
||||
if buff.startRound ~= BattleLogic.GetCurRound() then
|
||||
buff.roundPass = buff.roundPass + 1
|
||||
|
|
|
@ -2145,8 +2145,6 @@ local passivityList = {
|
|||
local list = BattleLogic.Query(function(v) return v.camp == role.camp and v.position <= 3 end)
|
||||
for _, role in ipairs(list) do
|
||||
BattleLogic.BuffMgr:QueryBuff(role, function(buff)
|
||||
Log(tostring(buff.type == BuffName.Shield))
|
||||
Log(tostring(buff.ShieldType == ShieldTypeName.RateReduce))
|
||||
if buff.type == BuffName.Shield and buff.shieldType == ShieldTypeName.RateReduce then
|
||||
buff:ChangeShieldValue(ct, f1)
|
||||
end
|
||||
|
|
|
@ -22,7 +22,7 @@ function Skill:New()
|
|||
return o
|
||||
end
|
||||
|
||||
function Skill:Init(role, effectData, type) --type 0 异妖 1 点技 2 滑技
|
||||
function Skill:Init(role, effectData, type, targets, isAdd, isRage) --type 0 异妖 1 点技 2 滑技
|
||||
local isTeamSkill = type == 0
|
||||
self.type = type
|
||||
--skill = {技能ID, {目标id1, 效果时间, 效果1, 效果2, ...},{目标id2, 效果时间, 效果3, 效果4, ...}, ...}
|
||||
|
@ -34,6 +34,9 @@ function Skill:Init(role, effectData, type) --type 0 异妖 1 点技 2 滑技
|
|||
self.id = effectData[1] -- 技能ID
|
||||
-- self.EffectDuration = 0 -- 效果命中需要的时间
|
||||
|
||||
self.targets = targets or {}
|
||||
self.isAdd = isAdd
|
||||
self.isRage = isRage
|
||||
|
||||
for i=2, #effectData do
|
||||
local v = effectData[i]
|
||||
|
@ -95,20 +98,16 @@ end
|
|||
|
||||
-- 释放技能
|
||||
-- func 技能释放完成回调
|
||||
-- targets 指定技能释放目标
|
||||
-- isAdd 是否是追加技能
|
||||
function Skill:Cast(func, targets, isAdd)
|
||||
function Skill:Cast(func)
|
||||
self.castDoneFunc = func
|
||||
self.effectTargets = {}
|
||||
self.isAdd = isAdd
|
||||
|
||||
|
||||
-- 先计算出技能的目标
|
||||
for i=1, self.effectList.size do
|
||||
-- 是否重新选择目标
|
||||
local isReTarget = true
|
||||
if targets and targets[i] then
|
||||
self.effectTargets[i] = targets[i]
|
||||
if self.targets and self.targets[i] then
|
||||
self.effectTargets[i] = self.targets[i]
|
||||
-- 判断是否有有效目标
|
||||
for _, role in ipairs(self.effectTargets[i]) do
|
||||
if not role.isDead then
|
||||
|
@ -116,7 +115,7 @@ function Skill:Cast(func, targets, isAdd)
|
|||
end
|
||||
end
|
||||
end
|
||||
-- 重新选择目标
|
||||
-- 重新选择目标a
|
||||
if isReTarget then
|
||||
local effectGroup = self.effectList.buffer[i]
|
||||
local chooseId = effectGroup.chooseId
|
||||
|
@ -208,6 +207,5 @@ function Skill:EndSkill()
|
|||
end)
|
||||
--
|
||||
self.effectTargets = {}
|
||||
self.isAdd = nil
|
||||
end
|
||||
|
||||
|
|
|
@ -106,6 +106,8 @@ function BattleLogic.Init(data, optionData)
|
|||
BattleLogic.BuffMgr:Init()
|
||||
BattleLogic.IsEnd = false
|
||||
BattleLogic.Result = -1
|
||||
|
||||
SkillManager.Init()
|
||||
end
|
||||
|
||||
function BattleLogic.StartOrder()
|
||||
|
@ -568,6 +570,7 @@ function BattleLogic.Update()
|
|||
end
|
||||
|
||||
BattleLogic.BuffMgr:Update()
|
||||
SkillManager.Update()
|
||||
|
||||
bMyAllDead = true
|
||||
bEnemyAllDead = true
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
|
||||
require("Modules.Battle.Logic.SkillManager")
|
||||
|
||||
RoleLogic = {}
|
||||
RoleLogic.__index = RoleLogic
|
||||
--local RoleLogic = RoleLogic
|
||||
|
@ -42,24 +45,14 @@ function RoleLogic:Init(uid, data, position)
|
|||
|
||||
self.Event:ClearEvent()
|
||||
|
||||
if data.skill and #data.skill > 0 then
|
||||
self.skill = skillPool:Get()
|
||||
self.skill:Init(self, data.skill, 1)
|
||||
end
|
||||
if data.superSkill and #data.superSkill > 0 then
|
||||
self.superSkill = skillPool:Get()
|
||||
self.superSkill:Init(self, data.superSkill, 2)
|
||||
end
|
||||
self.skill = data.skill
|
||||
self.superSkill = data.superSkill
|
||||
|
||||
--首次读条时间=速度/(20*(等级+10)
|
||||
self.sp = 0
|
||||
local time = self:GetRoleData(RoleDataName.Speed)/(20*(self:GetRoleData(RoleDataName.Level)+10))
|
||||
self.spPass = floor( BattleUtil.ErrorCorrection(time) * BattleLogic.GameFrameRate)
|
||||
|
||||
|
||||
-- 技能释放列表 技能改为按列表顺序释放 方便添加追加技能
|
||||
self.SkillList = {}
|
||||
self.CurSkillCastIndex = 0
|
||||
self.SkillCastDoneFunc = nil
|
||||
--
|
||||
self.passiveList = {}
|
||||
if data.passivity and #data.passivity > 0 then
|
||||
|
@ -234,16 +227,7 @@ function RoleLogic:AddBuff(buff)
|
|||
end
|
||||
|
||||
function RoleLogic:Dispose()
|
||||
if self.skill then
|
||||
self.skill:Dispose()
|
||||
skillPool:Put(self.skill)
|
||||
self.skill = nil
|
||||
end
|
||||
if self.superSkill then
|
||||
self.superSkill:Dispose()
|
||||
skillPool:Put(self.superSkill)
|
||||
self.superSkill = nil
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
@ -264,47 +248,49 @@ function RoleLogic:IsAvailable()
|
|||
return true
|
||||
end
|
||||
|
||||
-- 检测自身的技能释放
|
||||
function RoleLogic:CheckCastSkill()
|
||||
-- 释放技能
|
||||
function RoleLogic:SkillCast(skill, func)
|
||||
|
||||
local _CastDone = function()
|
||||
if func then
|
||||
func()
|
||||
end
|
||||
end
|
||||
|
||||
-- 角色不可用直接结束技能释放
|
||||
if not self:IsAvailable() then
|
||||
self:SkillCastDone()
|
||||
if not skill or not self:IsAvailable() then
|
||||
_CastDone()
|
||||
return
|
||||
end
|
||||
-- 没有要释放的技能了结束技能释放
|
||||
if self.CurSkillCastIndex >= #self.SkillList then
|
||||
self:SkillCastDone()
|
||||
return
|
||||
end
|
||||
-- 拿到下一个技能
|
||||
self.CurSkillCastIndex = self.CurSkillCastIndex + 1
|
||||
local skill = self.SkillList[self.CurSkillCastIndex]
|
||||
-- 技能释放回调(递归检测下一个技能)
|
||||
local _CheckNext = function ()
|
||||
self:CheckCastSkill()
|
||||
end
|
||||
|
||||
-- 没有麻痹,释放普通攻击
|
||||
if skill.type == BattleSkillType.Normal and not self.ctrl_palsy then
|
||||
-- 释放普技
|
||||
self.skill:Cast(_CheckNext, skill.targets, skill.isAdd)
|
||||
-- 后成长怒气
|
||||
if skill.isRage then
|
||||
-- 检测被动技能对怒气成长的影响
|
||||
local grow = self.RageGrow
|
||||
local _RageGrowPassivity = function(finalGrow)
|
||||
grow = finalGrow
|
||||
|
||||
local function _CheckRage()
|
||||
-- 后成长怒气
|
||||
if skill.isRage then
|
||||
-- 检测被动技能对怒气成长的影响
|
||||
local grow = self.RageGrow
|
||||
local _RageGrowPassivity = function(finalGrow)
|
||||
grow = finalGrow
|
||||
end
|
||||
self.Event:DispatchEvent(BattleEventName.RoleRageGrow, grow, _RageGrowPassivity)
|
||||
--
|
||||
self.Rage = self.Rage + grow
|
||||
end
|
||||
self.Event:DispatchEvent(BattleEventName.RoleRageGrow, grow, _RageGrowPassivity)
|
||||
--
|
||||
self.Rage = self.Rage + grow
|
||||
-- 释放完成
|
||||
_CastDone()
|
||||
end
|
||||
-- 释放普技
|
||||
skill:Cast(_CheckRage)
|
||||
|
||||
-- 没有沉默,释放大技能
|
||||
elseif skill.type == BattleSkillType.Special and not self.ctrl_slient then
|
||||
-- 先消耗怒气
|
||||
if skill.isRage then
|
||||
if self.Rage < self.SuperSkillRage then
|
||||
-- 怒气值不足不能释放技能
|
||||
_CheckNext()
|
||||
_CastDone()
|
||||
return
|
||||
end
|
||||
-- 检测被动技能对怒气消耗的影响
|
||||
|
@ -323,51 +309,51 @@ function RoleLogic:CheckCastSkill()
|
|||
self.Rage = self.Rage - costRage
|
||||
end)
|
||||
end
|
||||
|
||||
-- 释放绝技
|
||||
self.superSkill:Cast(_CheckNext, skill.targets, skill.isAdd)
|
||||
skill:Cast(_CastDone)
|
||||
|
||||
-- 没有符合条件的技能直接进入下一个技能检测
|
||||
else
|
||||
_CheckNext()
|
||||
_CastDone()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
-- 加入一个技能
|
||||
-- type 加入的技能类型
|
||||
-- targets 指定目标
|
||||
-- isAdd 是否是追加技能
|
||||
-- isRage 是否正常操作怒气值
|
||||
function RoleLogic:AddSkill(type, isRage, isAdd, targets)
|
||||
local skill = {
|
||||
type = type,
|
||||
isRage = isRage,
|
||||
isAdd = isAdd,
|
||||
targets = targets,
|
||||
}
|
||||
table.insert(self.SkillList, skill)
|
||||
if not self.SkillNum then
|
||||
self.SkillNum = 0
|
||||
end
|
||||
self.SkillNum = self.SkillNum + 1
|
||||
|
||||
local effectData = type == BattleSkillType.Normal and self.skill or self.superSkill
|
||||
SkillManager.AddSkill(self, effectData, type, targets, isAdd, isRage)
|
||||
end
|
||||
|
||||
|
||||
|
||||
-- 正常触发技能
|
||||
function RoleLogic:CastSkill(func)
|
||||
self.SkillList = {}
|
||||
self.CurSkillCastIndex = 0
|
||||
self.SkillCastDoneFunc = func
|
||||
-- 设置轮转方法
|
||||
SkillManager.SetTurnRoundFunc(func)
|
||||
-- 没有沉默
|
||||
if not self.ctrl_slient and self.Rage >= self.SuperSkillRage then
|
||||
-- 释放大技能
|
||||
self:AddSkill(BattleSkillType.Special, true, false, nil)
|
||||
self:CheckCastSkill()
|
||||
return
|
||||
end
|
||||
-- 没有麻痹 释放普通技能
|
||||
if not self.ctrl_palsy then
|
||||
self:AddSkill(BattleSkillType.Normal, true, false, nil)
|
||||
self:CheckCastSkill()
|
||||
return
|
||||
end
|
||||
self:CheckCastSkill()
|
||||
--
|
||||
end
|
||||
|
||||
-- 强制释放技能,测试技能时使用
|
||||
|
@ -375,39 +361,41 @@ end
|
|||
-- targets 追加技能的目标 nil则自动选择目标
|
||||
-- func 追加技能释放完成回调
|
||||
function RoleLogic:ForceCastSkill(type, targets, func)
|
||||
self.SkillList = {}
|
||||
self.CurSkillCastIndex = 0
|
||||
self.SkillCastDoneFunc = func
|
||||
|
||||
-- 清除技能控制
|
||||
self.ctrl_dizzy = false --眩晕 不能释放技能
|
||||
self.ctrl_slient = false --沉默 只能1技能
|
||||
self.ctrl_palsy = false --麻痹 只能2技能
|
||||
|
||||
-- 设置轮转方法
|
||||
SkillManager.SetTurnRoundFunc(func)
|
||||
-- 释放技能
|
||||
if type == 1 and self.skill then
|
||||
self:AddSkill(BattleSkillType.Normal, true, false, nil)
|
||||
self:CheckCastSkill()
|
||||
elseif type == 2 and self.superSkill then
|
||||
if self.Rage < self.SuperSkillRage then
|
||||
self.Rage = self.SuperSkillRage
|
||||
end
|
||||
self:AddSkill(BattleSkillType.Special, true, false, nil)
|
||||
self:CheckCastSkill()
|
||||
else
|
||||
if func then func() end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
-- 技能释放完毕
|
||||
function RoleLogic:SkillCastDone()
|
||||
BattleLogic.WaitForTrigger(1, function()
|
||||
if self.SkillCastDoneFunc then
|
||||
self.SkillCastDoneFunc()
|
||||
end
|
||||
end)
|
||||
-- 设置我被杀死时的信息
|
||||
function RoleLogic:SetkillMeInfo(caster, skill)
|
||||
self.killCaster = caster
|
||||
self.killSkill = skill
|
||||
end
|
||||
|
||||
function RoleLogic:Update()
|
||||
|
||||
|
||||
if self:GetRoleData(RoleDataName.Hp) <= 0 then
|
||||
self.isDead = true
|
||||
BattleLogic.BuffMgr:ClearBuff(self)
|
||||
self.Event:DispatchEvent(BattleEventName.RoleDead, self.killCaster)
|
||||
self.killCaster.Event:DispatchEvent(BattleEventName.RoleKill, self)
|
||||
BattleLogic.Event:DispatchEvent(BattleEventName.BattleRoleDead, self, self.killCaster)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -0,0 +1,88 @@
|
|||
SkillManager = {}
|
||||
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, skill, 1)
|
||||
return skill
|
||||
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(1, 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
|
||||
-- 检测技能释放
|
||||
skill.owner:SkillCast(skill, function()
|
||||
skill:Dispose()
|
||||
skillPool:Put(skill)
|
||||
this.IsSkilling = false
|
||||
-- 检测一下轮转
|
||||
this.CheckTurnRound()
|
||||
end)
|
||||
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
|
Loading…
Reference in New Issue