public override void OnInit(BuffDataBase buffData, Unit theUnitFrom, Unit theUnitBelongto) { //设置Buff来源Unit和归属Unit this.TheUnitFrom = theUnitFrom; this.TheUnitBelongto = theUnitBelongto; this.BuffData = buffData; BuffTimerAndOverlayHelper.CalculateTimerAndOverlay(this, this.BuffData); }
/// <summary> /// 取得Buff,Buff流程是Acquire->OnInit(CalculateTimerAndOverlay)->AddTemp->经过筛选->AddReal /// </summary> /// <param name="buffDataBase">Buff数据</param> /// <param name="theUnitFrom">Buff来源者</param> /// <param name="theUnitBelongTo">Buff寄生者</param> /// <returns></returns> public static ABuffSystemBase AcquireBuff(BuffDataBase buffDataBase, Unit theUnitFrom, Unit theUnitBelongTo, NP_RuntimeTree theSkillCanvasBelongTo) { ABuffSystemBase resultBuff = ReferencePool.Acquire(AllBuffSystemTypes[buffDataBase.BelongBuffSystemType]) as ABuffSystemBase; resultBuff.BelongtoRuntimeTree = theSkillCanvasBelongTo; resultBuff.OnInit(buffDataBase, theUnitFrom, theUnitBelongTo); return(resultBuff); }
public void Clear() { BelongtoRuntimeTree = null; BuffState = BuffState.Waiting; CurrentOverlay = 0; MaxLimitTime = 0; BuffData = null; TheUnitFrom = null; TheUnitBelongto = null; }
/// <summary> /// 取得Buff,Buff流程是Acquire->OnInit(CalculateTimerAndOverlay)->AddTemp->经过筛选->AddReal /// </summary> /// <param name="buffDataBase">Buff数据</param> /// <param name="theUnitFrom">Buff来源者</param> /// <param name="theUnitBelongTo">Buff寄生者</param> /// <returns></returns> public ABuffSystemBase AcquireBuff(BuffDataBase buffDataBase, Unit theUnitFrom, Unit theUnitBelongTo, NP_RuntimeTree theSkillCanvasBelongTo) { Queue <ABuffSystemBase> buffBase; Type targetBuffSystemType = AllBuffSystemTypes[buffDataBase.BelongBuffSystemType]; ABuffSystemBase resultBuff; if (this.BuffSystems.TryGetValue(targetBuffSystemType, out buffBase)) { if (buffBase.Count > 0) { resultBuff = buffBase.Dequeue(); resultBuff.BelongtoRuntimeTree = theSkillCanvasBelongTo; resultBuff.OnInit(buffDataBase, theUnitFrom, theUnitBelongTo); return(resultBuff); } } resultBuff = (ABuffSystemBase)Activator.CreateInstance(targetBuffSystemType); resultBuff.BelongtoRuntimeTree = theSkillCanvasBelongTo; resultBuff.OnInit(buffDataBase, theUnitFrom, theUnitBelongTo); return(resultBuff); }
/// <summary> /// 初始化buff数据 /// </summary> /// <param name="buffData">Buff数据</param> /// <param name="theUnitFrom">来自哪个Unit</param> /// <param name="theUnitBelongto">寄生于哪个Unit</param> public abstract void OnInit(BuffDataBase buffData, Unit theUnitFrom, Unit theUnitBelongto);
/// <summary> /// 计算刷新的持续时间和层数 /// </summary> private static void CalculateTimerAndOverlayHelper(ABuffSystemBase targetBuffSystemBase, BuffDataBase targetBuffDataBase) { //可以叠加,并且当前层数加上要添加Buff的目标层数未达到最高层 if (targetBuffSystemBase.BuffData.CanOverlay) { if (targetBuffSystemBase.CurrentOverlay + targetBuffSystemBase.BuffData.TargetOverlay <= targetBuffSystemBase.BuffData.MaxOverlay) { targetBuffSystemBase.CurrentOverlay += targetBuffSystemBase.BuffData.TargetOverlay; } else { targetBuffSystemBase.CurrentOverlay = targetBuffSystemBase.BuffData.MaxOverlay; } } else { targetBuffSystemBase.CurrentOverlay = 1; } //如果是有限时长的 TODO:这里考虑处理持续时间和Buff层数挂钩的情况(比如磕了5瓶药,就是5*单瓶药的持续时间) if (targetBuffSystemBase.BuffData.SustainTime + 1 > 0) { //Log.Info($"原本结束时间:{temp.MaxLimitTime},续命之后的结束时间{TimeHelper.Now() + buffDataBase.SustainTime}"); targetBuffSystemBase.MaxLimitTime = TimeHelper.Now() + targetBuffDataBase.SustainTime; } }