示例#1
0
    public void AddBuff(int buffID, int sourceID, float modifyTimer, bool isServerSend)
    {
        BuffInfo info = GameTable.BuffTableAsset.Lookup(buffID);

        if (null == info)
        {
            return;
        }
        if (IsDisable(info))
        {
            return;
        }
        float length = info.BuffDuration;

        if (length != 0)
        {//不是无限的
            length += modifyTimer;
        }
        Buff buff = new Buff(buffID, !info.IsNotRemoveForDead, length, info.IsFirstWork, info.Period);

        foreach (var item in info.PropertyPercentList)
        {
            if (item != 0)
            {
                buff.IsCalcProperty = true;
                break;
            }
        }
        if (!buff.IsCalcProperty)
        {
            foreach (var item in info.PropertyValueList)
            {
                if (item != 0)
                {
                    buff.IsCalcProperty = true;
                    break;
                }
            }
        }
        //play effect
        BuffEffectInfo beInfo = GameTable.BuffEffectTableAsset.Lookup(info.BuffEffectID);

        if (beInfo != null && !string.IsNullOrEmpty(beInfo.EffectName))
        {
            Vector3 offset = new Vector3(beInfo.OffsetX, beInfo.OffsetY, beInfo.OffsetZ);
            string  bone   = beInfo.PlayBoneT;
            if (beInfo.IsSpecialPoint)
            {
                if (m_target.Type == ActorType.enNPC)
                {
                    NPC npc = m_target as NPC;
                    if (npc.GetNpcType() == ENNpcType.enBOSSNPC)
                    {
                        bone = beInfo.SpecialPointBoneT;
                    }
                }
            }
            MainGame.Singleton.StartCoroutine(Coroutine_Load(buff, beInfo.EffectName, 0, bone, beInfo.IsAdhered, offset));
        }
        BuffList.Add(buff);
        foreach (var item in info.BuffResultList)
        {
            if (buff.IsExsit(item.ID))
            {//buff中不能存在多个相同的IBuffEffect
                continue;
            }
            IBuffEffect buffEffect = BattleFactory.Singleton.GetBattleContext().CreateBuffEffect(item.ID);
            if (null == buffEffect)
            {
                continue;
            }
            buffEffect.TargetID     = m_target.ID;
            buffEffect.SourceID     = sourceID;
            buffEffect.BuffID       = buffID;
            buffEffect.BuffEffectID = info.BuffEffectID;
            buff.AddBuffEffect(buffEffect);
            buffEffect.OnGetBuffEffect();
        }
        buff.UpdateFastFilterFlag();
        if (buff.IsCalcProperty && !isServerSend)
        {
            BuffResult();
        }
        else
        {
            RefreshBuffGraphics();
        }
    }