| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231 | 
							- using System;
 
- using System.Collections.Generic;
 
- using Common.Utility.CombatEvent;
 
- using Fort23.Core;
 
- namespace GameLogic.Combat.Buff
 
- {
 
-     public class BuffControl : IDisposable
 
-     {
 
-         private BetterList<BuffBasic> _allBuff = new BetterList<BuffBasic>();
 
-         private CombatHeroEntity _combatHeroEntity;
 
-         public void Init(CombatHeroEntity combatHeroEntity)
 
-         {
 
-             _combatHeroEntity = combatHeroEntity;
 
-         }
 
-         public BuffBasic AddBuff(CombatHeroEntity source, BuffInfo buffInfo,
 
-             AddActionsType addActionsType = AddActionsType.Direct)
 
-         {
 
-             if (buffInfo.BuffConfig.IsControlBuff == 1)
 
-             {
 
-                 b_1015 b_1015 = GetBuffBasicForType<b_1015>();
 
-                 if (b_1015 != null)
 
-                 {
 
-                     return null;
 
-                 }
 
-             }
 
-             StartAddBuffEventData startAddBuffEventData = StartAddBuffEventData.Create();
 
-             startAddBuffEventData.BuffInfo = buffInfo;
 
-             startAddBuffEventData.source = source;
 
-             startAddBuffEventData.target = _combatHeroEntity;
 
-             startAddBuffEventData.addActionsType = addActionsType;
 
-             CombatEventManager.Instance.Dispatch(CombatEventType.StartAddBuff, startAddBuffEventData, false);
 
-             if (startAddBuffEventData.isNotAddBuff)
 
-             {
 
-                 startAddBuffEventData.Recycle();
 
-                 return null;
 
-             }
 
-             startAddBuffEventData.Recycle();
 
-             BuffBasic buffBasic = GetBuffBasicForIdGroup(buffInfo.BuffConfig.buffGroup);
 
-             if (buffBasic == null)
 
-             {
 
-                 buffBasic = GetBuffBasic(buffInfo.BuffConfig.scriptsName);
 
-                 if (buffBasic == null)
 
-                 {
 
-                     return null;
 
-                 }
 
-                 _allBuff.Add(buffBasic);
 
-                 buffBasic.Init(_combatHeroEntity, source, buffInfo);
 
-                 if (buffBasic != null)
 
-                 {
 
-                     BuffEventData buffEventData = BuffEventData.Create();
 
-                     buffEventData.BuffBasic = buffBasic;
 
-                     buffEventData.source = source;
 
-                     buffEventData.target = _combatHeroEntity;
 
-                     buffEventData.addActionsType = addActionsType;
 
-                     buffEventData.addCount = buffInfo.count;
 
-                     buffEventData.id = buffInfo.BuffConfig.ID;
 
-                     buffEventData.BuffInfo = buffInfo;
 
-                     CombatEventManager.Instance.Dispatch(CombatEventType.AddBuff, buffEventData);
 
-                 }
 
-             }
 
-             else
 
-             {
 
-                 BuffEventData buffEventData = BuffEventData.Create();
 
-                 buffEventData.BuffBasic = buffBasic;
 
-                 buffEventData.source = source;
 
-                 buffEventData.isSuperimposing = true;
 
-                 buffEventData.target = _combatHeroEntity;
 
-                 buffEventData.addActionsType = addActionsType;
 
-                 buffEventData.addCount = buffInfo.count;
 
-                 buffEventData.id = buffInfo.BuffConfig.ID;
 
-                 buffEventData.BuffInfo = buffInfo;
 
-                 int c = buffBasic.AddBuffCount(source, buffInfo);
 
-                 
 
-                 if (c > 0 && buffBasic != null)
 
-                 {
 
-                     buffEventData.addCount = c;
 
-                     CombatEventManager.Instance.Dispatch(CombatEventType.AddBuff, buffEventData);
 
-                 }
 
-                 if (buffInfo.BuffConfig.timeType == 1)
 
-                 {
 
-                     CObjectPool.Instance.Recycle(buffInfo);
 
-                 }
 
-             }
 
-             return buffBasic;
 
-         }
 
-         protected BuffBasic GetBuffBasic(string buffName)
 
-         {
 
-             string typeName = "GameLogic.Combat.Buff." + buffName;
 
-             {
 
-                 System.Type type = System.Type.GetType(typeName);
 
-                 if (type == null)
 
-                 {
 
-                     return null;
 
-                 }
 
-                 BuffBasic sb = (BuffBasic)CObjectPool.Instance.Fetch(type);
 
-                 return sb;
 
-             }
 
-         }
 
-         
 
-         public T GetBuffBasicForType<T>() where T : BuffBasic
 
-         {
 
-             for (int i = 0; i < _allBuff.Count; i++)
 
-             {
 
-                 BuffBasic b = _allBuff[i];
 
-                 if (b is T)
 
-                 {
 
-                     return (T)b;
 
-                 }
 
-             }
 
-             return null;
 
-         }
 
-         /// <summary>
 
-         /// 获得对应buff
 
-         /// </summary>
 
-         /// <param name="buffType"> 1=buff 2=debuff 3=中立</param>
 
-         /// clearType 0=全部 1=能清楚 2=不能清楚
 
-         /// <returns></returns>
 
-         public List<BuffBasic> GetBuffBasicForBuffType(int buffType,int clearType= 0)
 
-         {
 
-             List<BuffBasic> buffBasics = new List<BuffBasic>();
 
-             for (int i = 0; i < _allBuff.Count; i++)
 
-             {
 
-                 BuffBasic b = _allBuff[i];
 
-                 if (b.BuffConfig.buffType == buffType)
 
-                 {
 
-                     if (clearType ==1&& b.BuffConfig.dispelType != 1)
 
-                     {
 
-                         continue;
 
-                     }
 
-                     if (clearType ==2&& b.BuffConfig.dispelType != 2)
 
-                     {
 
-                         continue;
 
-                     }
 
-                     buffBasics.Add(b);
 
-                 }
 
-             }
 
-             return buffBasics;
 
-         }
 
-         public BuffBasic GetBuffBasicForIdGroup(int idGroup)
 
-         {
 
-             for (int i = 0; i < _allBuff.Count; i++)
 
-             {
 
-                 BuffBasic b = _allBuff[i];
 
-                 if (b.BuffConfig.buffGroup == idGroup)
 
-                 {
 
-                     return b;
 
-                 }
 
-             }
 
-             return null;
 
-         }
 
-         /// <summary>
 
-         /// 获得对应buff的数量
 
-         /// </summary>
 
-         /// <param name="buffType">1=buff,2=debuff 0=全部</param>
 
-         /// <returns></returns>
 
-         public int GetBuffCountForType(int buffType)
 
-         {
 
-             if (buffType == 0)
 
-             {
 
-                 return _allBuff.Count;
 
-             }
 
-             int c = 0;
 
-             for (int i = 0; i < _allBuff.Count; i++)
 
-             {
 
-                 if (_allBuff[i].BuffConfig.buffType == buffType)
 
-                 {
 
-                     c++;
 
-                 }
 
-             }
 
-             return c;
 
-         }
 
-         public void RemoveBuff(BuffBasic buffBasic)
 
-         {
 
-             if (buffBasic == null)
 
-             {
 
-                 return;
 
-             }
 
-             _allBuff.Remove(buffBasic);
 
-             BuffEventData buffEventData = BuffEventData.Create();
 
-             buffEventData.BuffBasic = buffBasic;
 
-             buffEventData.source = null;
 
-             buffEventData.target = _combatHeroEntity;
 
-             CombatEventManager.Instance.Dispatch(CombatEventType.RemoveBuff, buffEventData);
 
-             buffBasic.Dispose();
 
-             CObjectPool.Instance.Recycle(buffBasic);
 
-         }
 
-         public void Update(float t)
 
-         {
 
-             for (int i = 0; i < _allBuff.Count; i++)
 
-             {
 
-                 _allBuff[i].Update(t);
 
-             }
 
-         }
 
-         public void Dispose()
 
-         {
 
-             for (int i = 0; i < _allBuff.Count; i++)
 
-             {
 
-                 BuffBasic buffBasic = _allBuff[i];
 
-                 buffBasic.Dispose();
 
-                 CObjectPool.Instance.Recycle(buffBasic);
 
-             }
 
-             _allBuff.Clear();
 
-             _combatHeroEntity = null;
 
-         }
 
-     }
 
- }
 
 
  |