示例#1
0
    public void Deserialize(PHeroAttr data, bool notifyChange)
    {
        EntityID      = data.heroId;
        ConfigID      = data.heroCfgId;
        StarLevel     = data.starLv;
        FightingScore = data.fighting;
        Exp           = data.xiuwei;
        Level         = data.level;

        EquipedItem.Clear();
        foreach (var item in data.fitups)
        {
            ItemInfo info = new ItemInfo();
            info.Deserialize(item);
            EquipedItem.Add(info);
        }

        LearnedSkill.Clear();
        foreach (var item in data.skillList)
        {
            SkillInfo info = new SkillInfo();
            info.Deserialize(item);
            LearnedSkill.Add(info);
        }

        HeroProperty oldProperty = Property;

        if (data.basicAttr != null)
        {
            Property.Strength     = data.basicAttr.strength;
            Property.Intelligence = data.basicAttr.Intelligence;
            Property.Leadership   = data.basicAttr.LeaderShip;
        }

        if (data.battleAttr != null)
        {
            Property.Attack      = data.battleAttr.physAtk;
            Property.MagicAttack = data.battleAttr.magicAtk;
            Property.Hp          = data.battleAttr.hp;
            Property.Def         = data.battleAttr.damReduce;
            Property.Critical    = data.battleAttr.criticStrike;
            Property.Stum        = data.battleAttr.damDeepen;
            Property.AttackSpeed = data.battleAttr.atkSpeed;
            Property.Cooldown    = data.battleAttr.coolDown;
        }

        if (notifyChange)
        {
            const float delayTimeInterval = 0.2f;
            float       delayTime         = 0;
            if (Property.Strength != oldProperty.Strength)
            {
                AddFloatingMsg(Str.Get("ATTR_STR"), Property.Strength - oldProperty.Strength, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Property.Intelligence != oldProperty.Intelligence)
            {
                AddFloatingMsg(Str.Get("ATTR_INT"), Property.Intelligence - oldProperty.Intelligence, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Property.Leadership != oldProperty.Leadership)
            {
                AddFloatingMsg(Str.Get("ATTR_LEADER"), Property.Leadership - oldProperty.Leadership, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Property.Attack != oldProperty.Attack)
            {
                AddFloatingMsg(Str.Get("ATTR_ATTACK"), Property.Attack - oldProperty.Attack, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Property.MagicAttack != oldProperty.MagicAttack)
            {
                AddFloatingMsg(Str.Get("ATTR_MAGIC_ATTACK"), Property.MagicAttack - oldProperty.MagicAttack, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Property.Hp != oldProperty.Hp)
            {
                AddFloatingMsg(Str.Get("ATTR_HP"), Property.Hp - oldProperty.Hp, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Math.Abs(Property.Def - oldProperty.Def) > 0.01f)
            {
                AddFloatingMsg(Str.Get("ATTR_DEF"), Property.Def - oldProperty.Def, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Math.Abs(Property.Critical - oldProperty.Critical) > 0.01f)
            {
                AddFloatingMsg(Str.Get("ATTR_CRIT"), Property.Critical - oldProperty.Critical, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Math.Abs(Property.HpSorb - oldProperty.HpSorb) > 0.01f)
            {
                AddFloatingMsg(Str.Get("ATTR_HP_SORB"), Property.HpSorb - oldProperty.HpSorb, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Math.Abs(Property.Stum - oldProperty.Stum) > 0.01f)
            {
                AddFloatingMsg(Str.Get("ATTR_STUM"), Property.Stum - oldProperty.Stum, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Property.AttackSpeed != oldProperty.AttackSpeed)
            {
                AddFloatingMsg(Str.Get("ATTR_ATTACK_SPEED"), Property.AttackSpeed - oldProperty.AttackSpeed, delayTime);
                delayTime += delayTimeInterval;
            }

            if (Math.Abs(Property.Cooldown - oldProperty.Cooldown) > 0.01f)
            {
                AddFloatingMsg(Str.Get("ATTR_CD"), Property.Cooldown - oldProperty.Cooldown, delayTime);
                delayTime += delayTimeInterval;
            }
        }
    }