private void initBuff(BuffBaseItem buff) { if (buff.buffState == BuffState.None) { buff.addTime = _nowTime; buff.buffState = BuffState.Wait; if (!_mapBuff.ContainsKey(buff.buffType)) { _mapBuff[buff.buffType] = new List <BuffBaseItem>(); } _mapBuff[buff.buffType].Add(buff); if (buff.maxCount > -1) { var findList = _mapBuff[buff.buffType].FindAll((obj) => obj.id == buff.id); if (findList.Count > buff.maxCount) { findList.Sort((a, b) => (int)(a.addTime - b.addTime)); int removeCount = findList.Count - buff.maxCount; for (var i = 0; i < removeCount; ++i) { endBuff(findList[i]); } } } } }
private void endBuff(BuffBaseItem buff) { if (buff.buffState == BuffState.Run) { buff.endTime = _nowTime; buff.buffState = BuffState.End; buff.onEnd(); } }
private void beginBuff(BuffBaseItem buff) { if (buff.buffState == BuffState.Wait) { buff.startTime = _nowTime; buff.buffState = BuffState.Run; buff.onBegin(); } }
public bool addBuff(string buffId) { var buff = new BuffBaseItem(); if (!canAddBuff(buff)) { return(false); } initBuff(buff); return(true); }
private bool canAddBuff(BuffBaseItem buff) { return(true); }