/// <summary> /// 增加buff /// </summary> /// <param name="type"></param> /// <param name="time"></param> /// <param name="value"></param> public void AddBuff(EnumDefine.BuffType type, float time, float value) { Debug.Log(this.gameObject.name + "--->:测试增加一个buff" + "--->" + type.ToString()); MMORPG_BaseBuff buff = m_buffs.Find(x => x.GetBuffType() == type); if (buff != null) { buff.OnInit(type, time, this, value); } else { MMORPG_BaseBuff instance = MMORPG_BaseBuff.GetInstance(type); instance.OnInit(type, time, this, value); this.m_buffs.Add(instance); } }
/// <summary> /// 更新增益buff /// </summary> protected void UpdateBuffs() { for (int i = 0; i < m_buffs.Count; i++) { m_buffs[i].OnUpdate(); } for (int j = m_buffs.Count - 1; j >= 0; j--) { MMORPG_BaseBuff buff = this.m_buffs[j]; buff.m_Time -= Time.deltaTime; if (m_buffs[j].m_Time <= 0) { m_buffs[j].OnDestory(); m_buffs.RemoveAt(j); } } }