public void Start(GUnit unit, IBuffData buffData, bool removeWhenFinish) { var processData = unit.GetData <ObjectBuffProcessData>(); if (!IsAddedBuff(processData, buffData)) { processData.currentBuffDataList.Add(buffData); OnStart(unit, buffData as T, removeWhenFinish); } else { OnUpdate(unit, buffData as T); } }
bool IsAddedBuff(ObjectBuffProcessData processData, IBuffData buffData) { if (processData.currentBuffDataList.IndexOf(buffData) != -1) { return(true); } foreach (var addedBuffData in processData.currentBuffDataList) { if (addedBuffData.GetType() == buffData.GetType()) { return(true); } } return(false); }
public void Finish(GUnit unit, IBuffData buffData, bool removeFromBuffDataList = true) { var finishResult = OnFinish(unit, buffData as T); if (finishResult && removeFromBuffDataList) { var processData = unit.GetData <ObjectBuffProcessData>(); for (var i = 0; i < processData.currentBuffDataList.Count; i++) { var addedBuffData = processData.currentBuffDataList[i]; if (addedBuffData.GetType() == buffData.GetType()) { processData.currentBuffDataList.Remove(addedBuffData); break; } } } }
static BuffData() { SceneServer.Instance.UpdateManager.InitStaticImpl(typeof(BuffData), typeof(BuffDataDefaultImpl), o => { mImpl = (IBuffData)o; }); }
public void Stop(GUnit unit, IBuffData buffData) { OnStop(unit, buffData as T); }
public static void RemoveBuff(GUnit unit, IBuffData buffData, bool removeFromBuffDataList = true) { var buffModule = ObjectBuffModuleDict.Get(buffData.GetType().GetHashCode()); buffModule.Finish(unit, buffData, removeFromBuffDataList); }
public static void AddBuff(GUnit unit, IBuffData buffData, bool removeWhenFinish = true) { var buffModule = ObjectBuffModuleDict.Get(buffData.GetType().GetHashCode()); buffModule.Start(unit, buffData, removeWhenFinish); }