//提供给外部 移除Buff // TODO 移除的这块逻辑,目前不是特别明确 public void DetachBuff(BuffId buffId) { // 1.不存在buff,return BaseBuff existBuff = _get_exist_buff(buffId._buffId); if (existBuff == null) { return; } // 2.存在就移除当前buff _detach_buff(existBuff._bid); }
//detach所有同id的buff public void _detach_buff(BuffId bid) { // 1.移除定时器 int length = _buffList.Count - 1; for (int i = length; i >= 0; i--) { if (!_buffList[i]._bid.CheckByIid(bid)) { continue; } BuffLog.Log("Detach Buff-->[{0}] detach [{1}] Buff", _owner.ToDes(), _buffList[i].Info.ToDes()); _buffList[i].OnDetach(); } }
//有些buff是过程无效果,上buff和下buff的时候带功能的。例如设置角色朝向/攻击力 public void OnAttach(BaseEntity target, BaseEntity caster) { _bid = new BuffId(target.Id, Info.Id); _target = target; _caster = caster; // 1.默认为1层 //vbo.OnDefaultLayer(); // 2.初始化效果 _init_effs(); // 3.添加VFX/Sound //_add_Vfx(); //_add_sound(); // 4.触发OnAttach回调 RaiseEvent(E_BuffEvent.BUFF_ON_ATTACH); GameEventSystem.Instance.RaiseEvent(E_GLOBAL_EVT.buff_attach, this); }
public void OnDetach() { GameEventSystem.Instance.RaiseEvent(E_GLOBAL_EVT.buff_detach, this); RaiseEvent(E_BuffEvent.BUFF_ON_DETACH); // 1.移除vfx/sound //_remove_Vfx(); //_remove_sound(); // 2.触发OnDeatch回调,effect int length = _effects.Count; for (int i = 0; i < length; i++) { _effects[i].OnDetach(); } _effects.Clear(); _caster = null; _target = null; Info = null; _bid = null; }
public virtual void OnInit(BuffId bid, EffectTemplateInfo info) { _info = info; _bid = bid; }