Пример #1
0
    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]);
                    }
                }
            }
        }
    }
Пример #2
0
 private void endBuff(BuffBaseItem buff)
 {
     if (buff.buffState == BuffState.Run)
     {
         buff.endTime   = _nowTime;
         buff.buffState = BuffState.End;
         buff.onEnd();
     }
 }
Пример #3
0
 private void beginBuff(BuffBaseItem buff)
 {
     if (buff.buffState == BuffState.Wait)
     {
         buff.startTime = _nowTime;
         buff.buffState = BuffState.Run;
         buff.onBegin();
     }
 }
Пример #4
0
    public bool addBuff(string buffId)
    {
        var buff = new BuffBaseItem();

        if (!canAddBuff(buff))
        {
            return(false);
        }
        initBuff(buff);
        return(true);
    }
Пример #5
0
 private bool canAddBuff(BuffBaseItem buff)
 {
     return(true);
 }