Пример #1
0
    public IBuff NewBuff(IBuff.BuffType type)
    {
        IBuff buff = null;

        if (mRecoveryBuffList[(int)type].Count > 0)
        {
            buff = mRecoveryBuffList[(int)type].Pop();
        }
        else
        {
            if (type == IBuff.BuffType.Move)
            {
                buff = new MoveBuff();
            }
            else if (type == IBuff.BuffType.Behavior)
            {
                buff = new BehaviorBuff();
            }
            else if (type == IBuff.BuffType.Hurt)
            {
                buff = new HurtBuff();
            }
            else if (type == IBuff.BuffType.Control)
            {
                buff = new ControlBuff();
            }
        }

        buff.mInstId = ++mInstId;
        return(buff);
    }
Пример #2
0
    public void RemoveBuff(IBuff.BuffType type, int insId)
    {
        BuffId id = new BuffId();

        id.mType   = type;
        id.mTypeId = insId;
        mDeathBuffList.Add(id);
    }
Пример #3
0
    public bool HasSameBuff(IBuff.BuffType type, int typeId)
    {
        foreach (var item in mCurrBuffList[(int)type])
        {
            if (item.Value.mBuffConfig.mTypeId == typeId)
            {
                return(true);
            }
        }

        return(false);
    }
Пример #4
0
    public IBuff GetSameBuff(IBuff.BuffType type, int typeId)
    {
        foreach (var item in mCurrBuffList[(int)type])
        {
            if (item.Value.mBuffConfig.mTypeId == typeId)
            {
                return(item.Value);
            }
        }

        return(null);
    }
Пример #5
0
 static public void ParseBuffString(ref List <BuffId> outList, string info, IBuff.BuffType type)
 {
     string[] sArray = info.Split(';');
     for (int i = 0; i < sArray.Length; ++i)
     {
         if (sArray[i] != string.Empty)
         {
             string[] sArrayTrigger = sArray[i].Split(',');
             BuffId   buff          = new BuffId();
             buff.mType       = type;
             buff.mBuffAttach = (IBuff.BuffAttach) int.Parse(sArrayTrigger[0]);
             buff.mTrigger    = (IBuff.BuffStage) int.Parse(sArrayTrigger[1]);
             buff.mTypeId     = int.Parse(sArrayTrigger[2]);
             outList.Add(buff);
         }
     }
 }
Пример #6
0
    public int AddBuff(Role sendRole, IBuff.BuffType type, int typeId)
    {
        IBuff buff = null;

        if (type == IBuff.BuffType.Behavior)
        {
            if (EnableBehaviorBuff())
            {
                buff = GetSameBuff(type, typeId);
                if (buff == null)
                {
                    buff = NewBuff(type);
                }
                else
                {
                    Debug.Log("");
                }
                buff.Init(sendRole, mRole, BuffCofig.singleton.GetBehaviorBuffConfig(typeId), Time.fixedTime);
            }
        }
        else if (type == IBuff.BuffType.Move)
        {
            if (EnableMoveBuff())
            {
                buff = GetSameBuff(type, typeId);
                if (buff == null)
                {
                    buff = NewBuff(type);
                }
                else
                {
                    Debug.Log("");
                }

                buff.Init(sendRole, mRole, BuffCofig.singleton.GetMoveBuffConfig(typeId), Time.fixedTime);
            }
        }
        else if (type == IBuff.BuffType.Hurt)
        {
            if (EnableHurtBuff())
            {
                buff = GetSameBuff(type, typeId);
                if (buff == null)
                {
                    buff = NewBuff(type);
                }
                else
                {
                    Debug.Log("");
                }
                buff.Init(sendRole, mRole, BuffCofig.singleton.GetHurtBuffConfig(typeId), Time.fixedTime);
            }
        }
        else if (type == IBuff.BuffType.Control)
        {
            buff = GetSameBuff(type, typeId);
            if (buff == null)
            {
                buff = NewBuff(type);
            }
            else
            {
                Debug.Log("");
            }
            buff.Init(sendRole, mRole, BuffCofig.singleton.GetControlBuffConfig(typeId), Time.fixedTime);
        }

        if (buff != null)
        {
            buff.OnEnter();
            mCurrBuffList[(int)type][buff.mInstId] = buff;
            return(mInstId);
        }
        else
        {
            return(-1);
            // Debug.Log("AddBuff " + "type=" + type + " typeId=" + typeId);
        }
    }