/// <summary> /// 为Buff计算时间和层数 /// </summary> /// <param name="buffSystemBase">Buff逻辑类</param> /// <param name="buffDataBase">Buff数据类</param> /// <typeparam name="A"></typeparam> /// <typeparam name="B"></typeparam> public static void CalculateTimerAndOverlay<A, B>(A buffSystemBase, B buffDataBase) where A : ABuffSystemBase where B : BuffDataBase { BuffManagerComponent buffManagerComponent = buffSystemBase.GetBuffTarget().GetComponent<BuffManagerComponent>(); //先尝试从真正的Buff链表取得Buff ABuffSystemBase targetBuffSystemBase = buffManagerComponent.GetBuffById(buffDataBase.BuffId); if (targetBuffSystemBase != null) { CalculateTimerAndOverlayHelper(targetBuffSystemBase, buffDataBase); //Log.Info($"本次续命BuffID为{buffDataBase.FlagId},当前层数{temp.CurrentOverlay},最高层为{temp.MSkillBuffDataBase.MaxOverlay}"); buffSystemBase.CurrentOverlay = targetBuffSystemBase.CurrentOverlay; //刷新当前已有的Buff targetBuffSystemBase.OnRefresh(); //TODO 把这个临时的回收,因为已经用不到他了 } else { //尝试从临时Buff字典取 targetBuffSystemBase = buffManagerComponent.GetBuffById_FromTempDic(buffDataBase.BuffId); //如果有,那就计算层数与时间,并且替换临时字典中 if (targetBuffSystemBase != null) { CalculateTimerAndOverlayHelper(targetBuffSystemBase, buffDataBase); //Log.Info($"本次续命BuffID为{buffDataBase.FlagId},当前层数{temp.CurrentOverlay},最高层为{temp.MSkillBuffDataBase.MaxOverlay}"); buffSystemBase.CurrentOverlay = targetBuffSystemBase.CurrentOverlay; //刷新当前已有的Buff targetBuffSystemBase.OnRefresh(); //TODO 把这个临时的回收,因为已经用不到他了 } else//如果没有,那就说明确实没有这个Buff,需要重新加入 { CalculateTimerAndOverlayHelper(buffSystemBase, buffDataBase); //Log.Info($"本次新加BuffID为{buffDataBase.FlagId}"); buffSystemBase.BuffState = BuffState.Waiting; buffManagerComponent.TempBuffsToBeAdded.Add(buffDataBase.BuffId, buffSystemBase); } } }
/// <summary> /// 为Buff计算时间和层数 /// </summary> /// <param name="buffSystemBase">Buff逻辑类</param> /// <param name="buffDataBase">Buff数据类</param> /// <typeparam name="A"></typeparam> /// <typeparam name="B"></typeparam> public static void CalculateTimerAndOverlay<A, B>(A buffSystemBase, B buffDataBase) where A : ABuffSystemBase where B : BuffDataBase { BuffManagerComponent buffManagerComponent = buffSystemBase.GetBuffTarget().GetComponent<BuffManagerComponent>(); //先尝试从Buff链表取得Buff ABuffSystemBase targetBuffSystemBase = buffManagerComponent.GetBuffById(buffDataBase.BuffId); if (targetBuffSystemBase != null) { CalculateTimerAndOverlayHelper(targetBuffSystemBase, buffDataBase); //Log.Info($"本次续命BuffID为{buffDataBase.FlagId},当前层数{temp.CurrentOverlay},最高层为{temp.MSkillBuffDataBase.MaxOverlay}"); buffSystemBase.CurrentOverlay = targetBuffSystemBase.CurrentOverlay; //刷新当前已有的Buff targetBuffSystemBase.OnRefresh(); } else { CalculateTimerAndOverlayHelper(buffSystemBase, buffDataBase); //Log.Info($"本次新加BuffID为{buffDataBase.FlagId}"); buffSystemBase.BuffState = BuffState.Waiting; buffManagerComponent.AddBuff(buffSystemBase); } }