Example #1
0
        private void TriggerIntervalEvent()
        {
            if (m_BuffAttr == null)
            {
                return;
            }

            if (m_BuffAttr.Attr1 != 0)
            {
                BuffAttrData attrData1 = new BuffAttrData((AttributeType)m_BuffAttr.Attr1,
                                                          (DataValueType)m_BuffAttr.ValueType1,
                                                          m_BuffAttr.Value1);
                AttrList.Add(attrData1);
                TriggerIntervalEventByBuffAttr(attrData1);
            }

            if (m_BuffAttr.Attr2 != 0)
            {
                BuffAttrData attrData2 = new BuffAttrData((AttributeType)m_BuffAttr.Attr2,
                                                          (DataValueType)m_BuffAttr.ValueType2,
                                                          m_BuffAttr.Value2);
                AttrList.Add(attrData2);
                TriggerIntervalEventByBuffAttr(attrData2);
            }

            if (m_BuffAttr.Attr3 != 0)
            {
                BuffAttrData attrData3 = new BuffAttrData((AttributeType)m_BuffAttr.Attr3,
                                                          (DataValueType)m_BuffAttr.ValueType3,
                                                          m_BuffAttr.Value3);
                AttrList.Add(attrData3);
                TriggerIntervalEventByBuffAttr(attrData3);
            }
        }
Example #2
0
        private void TriggerIntervalEventByBuffAttr(BuffAttrData data)
        {
            int current     = m_Owner.Attrbute.GetValue(data.AttrType);
            int changeValue = 0;

            switch (data.ValueType)
            {
            case DataValueType.Fix:
            {
                changeValue = data.Value;
            }
            break;

            case DataValueType.Per:
            {
                changeValue = Mathf.FloorToInt((data.Value / 10000f + 1) * current);
            }
            break;

            case DataValueType.Com:
            {
                if (data.AttrType == AttributeType.Hp)
                {
                    int maxHp = m_Owner.Attrbute.GetValue(AttributeType.MaxHp);
                    changeValue = Mathf.FloorToInt((data.Value / 10000f) * maxHp);
                }
                else
                {
                    int maxMp = m_Owner.Attrbute.GetValue(AttributeType.MaxMp);
                    changeValue = Mathf.FloorToInt((data.Value / 10000f) * maxMp);
                }
            }
            break;
            }


            switch ((BattleActType)Data.Result)
            {
            case BattleActType.Lddattr:
            {
                if (data.AttrType == AttributeType.Mp)
                {
                    m_Owner.AddMp(changeValue, true);
                }
                else if (data.AttrType == AttributeType.Hp)
                {
                    m_Owner.AddHp(changeValue, true);
                }
            }
            break;

            case BattleActType.Lubattr:
            {
                if (data.AttrType == AttributeType.Mp)
                {
                    m_Owner.UseMp(changeValue);
                }
                else if (data.AttrType == AttributeType.Hp)
                {
                    m_Owner.TakeDamage(m_Caster, changeValue);
                }
            }
            break;
            }
        }
Example #3
0
        public virtual void UpdateCurAttribute(bool init = false)
        {
            ActorAttribute      bfAttr = new ActorAttribute();
            ActorAttribute      bpAttr = new ActorAttribute();
            Map <int, BuffBase> buffs  = m_ActorBuff.GetAllBuff();

            for (buffs.Begin(); buffs.Next();)
            {
                for (int i = 0; i < buffs.Value.AttrList.Count; i++)
                {
                    BuffAttrData attrData = buffs.Value.AttrList[i];
                    switch (attrData.ValueType)
                    {
                    case DataValueType.Fix:
                        bfAttr.UpdateValue(attrData.AttrType, attrData.Value);
                        break;

                    case DataValueType.Per:
                        bpAttr.UpdateValue(attrData.AttrType, attrData.Value);
                        break;
                    }
                }
            }

            int maxHp = m_BaseAttribute.MaxHp;//(m_BaseAttribute.MaxHp + bfAttr.MaxHp) * (1 + bpAttr.MaxHp / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.MaxHp, maxHp);

            int maxMp = (m_BaseAttribute.MaxMp + bfAttr.MaxMp) * (1 + bpAttr.MaxMp / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.MaxMp, maxMp);

            int attack = (m_BaseAttribute.Attack + bfAttr.Attack) * (1 + bpAttr.Attack / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Attack, attack);

            int defense = (m_BaseAttribute.Defense + bfAttr.Defense) * (1 + bpAttr.Defense / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Defense, defense);

            int absorb = (m_BaseAttribute.Absorb + bfAttr.Absorb) * (1 + bpAttr.Absorb / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Absorb, absorb);

            int speed = (m_BaseAttribute.Speed + bfAttr.Speed) * (1 + bpAttr.Speed / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Speed, speed);

            int reflex = (m_BaseAttribute.Reflex + bfAttr.Reflex) * (1 + bpAttr.Reflex / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Reflex, reflex);

            int suckBlood = (m_BaseAttribute.SuckBlood + bfAttr.SuckBlood) * (1 + bpAttr.SuckBlood / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.SuckBlood, suckBlood);

            int crit = (m_BaseAttribute.Crit + bfAttr.Crit) * (1 + bpAttr.Crit / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Crit, crit);

            int critDamage = (int)((m_BaseAttribute.CritDamage + bfAttr.CritDamage) * (1 + bpAttr.CritDamage / Constant.Define.PerBase));

            m_CurAttribute.UpdateValue(AttributeType.CritDamage, critDamage);

            int dodge = (m_BaseAttribute.Dodge + bfAttr.Dodge) * (1 + bpAttr.Dodge / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Dodge, dodge);

            int hit = (m_BaseAttribute.Hit + bfAttr.Hit) * (1 + bpAttr.Hit / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.Hit, hit);

            int mpRecover = (m_BaseAttribute.MpRecover + bfAttr.MpRecover) * (1 + bpAttr.MpRecover / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.MpRecover, mpRecover);

            int hpRecover = (m_BaseAttribute.HpRecover + bfAttr.HpRecover) * (1 + bpAttr.HpRecover / Constant.Define.PerBase);

            m_CurAttribute.UpdateValue(AttributeType.MpRecover, hpRecover);

            if (init)
            {
                m_CurAttribute.UpdateValue(AttributeType.Hp, m_BaseAttribute.Hp);
                m_CurAttribute.UpdateValue(AttributeType.Mp, m_BaseAttribute.Mp);
            }
            else
            {
                int hp = m_CurAttribute.Hp > m_BaseAttribute.MaxHp ? m_BaseAttribute.MaxHp : m_CurAttribute.Hp;
                int mp = m_CurAttribute.Mp > m_BaseAttribute.MaxMp ? m_BaseAttribute.MaxMp : m_CurAttribute.Mp;

                m_CurAttribute.UpdateValue(AttributeType.MaxHp, hp);
                m_CurAttribute.UpdateValue(AttributeType.MaxMp, mp);
            }
        }