Esempio n. 1
0
        protected override void UpdateData()
        {
            cacheStatsWithBuffs      = Data.GetStats();
            cacheAttributesWithBuffs = Data.GetAttributes();
            displayingStats          = showStatsWithBuffs ? cacheStatsWithBuffs : Data.GetStats(true, false);
            displayingAttributes     = showAttributeWithBuffs ? cacheAttributesWithBuffs : Data.GetAttributes(true, false);

            if (uiTextWeightLimit != null)
            {
                uiTextWeightLimit.text = string.Format(weightLimitStatsFormat, Data.GetTotalItemWeight().ToString("N2"), cacheStatsWithBuffs.weightLimit.ToString("N2"));
            }

            var rightHandItem    = Data.EquipWeapons.rightHand;
            var leftHandItem     = Data.EquipWeapons.leftHand;
            var rightHandWeapon  = rightHandItem.GetWeaponItem();
            var leftHandWeapon   = leftHandItem.GetWeaponItem();
            var rightHandDamages = rightHandWeapon != null?GameDataHelpers.CombineDamageAmountsDictionary(Data.GetIncreaseDamages(), rightHandWeapon.GetDamageAmount(rightHandItem.level, rightHandItem.GetEquipmentBonusRate(), Data)) : null;

            var leftHandDamages = leftHandWeapon != null?GameDataHelpers.CombineDamageAmountsDictionary(Data.GetIncreaseDamages(), leftHandWeapon.GetDamageAmount(leftHandItem.level, leftHandItem.GetEquipmentBonusRate(), Data)) : null;

            if (uiTextWeaponDamages != null)
            {
                var textDamages = "";
                if (rightHandWeapon != null)
                {
                    var sumDamages = GameDataHelpers.GetSumDamages(rightHandDamages);
                    if (!string.IsNullOrEmpty(textDamages))
                    {
                        textDamages += "\n";
                    }
                    textDamages += string.Format(weaponDamageFormat, sumDamages.min.ToString("N0"), sumDamages.max.ToString("N0"));
                }
                if (leftHandWeapon != null)
                {
                    var sumDamages = GameDataHelpers.GetSumDamages(leftHandDamages);
                    if (!string.IsNullOrEmpty(textDamages))
                    {
                        textDamages += "\n";
                    }
                    textDamages += string.Format(weaponDamageFormat, sumDamages.min.ToString("N0"), sumDamages.max.ToString("N0"));
                }
                if (rightHandWeapon == null && leftHandWeapon == null)
                {
                    var defaultWeaponItem     = GameInstance.Singleton.DefaultWeaponItem;
                    var defaultWeaponItemType = defaultWeaponItem.EquipType;
                    var damageAmount          = defaultWeaponItem.GetDamageAmount(1, 1f, Data);
                    textDamages = string.Format(weaponDamageFormat, damageAmount.Value.min.ToString("N0"), damageAmount.Value.max.ToString("N0"));
                }
                uiTextWeaponDamages.text = textDamages;
            }

            if (uiRightHandDamages != null)
            {
                if (rightHandWeapon == null)
                {
                    uiRightHandDamages.Hide();
                }
                else
                {
                    uiRightHandDamages.Show();
                    uiRightHandDamages.Data = rightHandDamages;
                }
            }

            if (uiLeftHandDamages != null)
            {
                if (leftHandWeapon == null)
                {
                    uiLeftHandDamages.Hide();
                }
                else
                {
                    uiLeftHandDamages.Show();
                    uiLeftHandDamages.Data = leftHandDamages;
                }
            }

            if (uiCharacterStats != null)
            {
                uiCharacterStats.Data = displayingStats;
            }

            if (CacheUICharacterAttributes.Count > 0 && Data != null)
            {
                Attribute tempAttribute;
                short     tempAmount;
                var       characterAttributes = Data.Attributes;
                for (var indexOfData = 0; indexOfData < characterAttributes.Count; ++indexOfData)
                {
                    tempAttribute = characterAttributes[indexOfData].GetAttribute();
                    UICharacterAttribute cacheUICharacterAttribute;
                    tempAmount = 0;
                    if (CacheUICharacterAttributes.TryGetValue(tempAttribute, out cacheUICharacterAttribute))
                    {
                        if (displayingAttributes.ContainsKey(tempAttribute))
                        {
                            tempAmount = displayingAttributes[tempAttribute];
                        }
                        cacheUICharacterAttribute.Setup(new AttributeTuple(tempAttribute, tempAmount), Data, indexOfData);
                        cacheUICharacterAttribute.Show();
                    }
                }
            }

            if (uiCharacterBuffs != null)
            {
                uiCharacterBuffs.UpdateData(Data);
            }
        }
Esempio n. 2
0
        protected override void UpdateData()
        {
            cacheStats           = showStatsWithBuffs ? Data.GetStats() : Data.GetStats(true, false);
            cacheAttributes      = showAttributeWithBuffs ? Data.GetAttributes() : Data.GetAttributes(true, false);
            cacheResistances     = showResistanceWithBuffs ? Data.GetResistances() : Data.GetResistances(true, false);
            cacheIncreaseDamages = showDamageWithBuffs ? Data.GetIncreaseDamages() : Data.GetIncreaseDamages(true, false);
            cacheWeightLimit     = cacheStats.weightLimit;
            if (!showStatsWithBuffs)
            {
                // Always increase weight limit by buff bonus because it should always show real weight limit in UIs
                cacheWeightLimit += Data.GetBuffStats().weightLimit;
            }

            if (bonusAttributes == null)
            {
                bonusAttributes = new Dictionary <Attribute, short>();
            }
            if (bonusResistances == null)
            {
                bonusResistances = new Dictionary <DamageElement, float>();
            }
            if (bonusIncreaseDamages == null)
            {
                bonusIncreaseDamages = new Dictionary <DamageElement, MinMaxFloat>();
            }
            if (bonusSkills == null)
            {
                bonusSkills = new Dictionary <Skill, short>();
            }
            if (cacheEquipmentSets == null)
            {
                cacheEquipmentSets = new Dictionary <EquipmentSet, int>();
            }

            Data.GetEquipmentSetBonus(out bonusStats, bonusAttributes, bonusResistances, bonusIncreaseDamages, bonusSkills, cacheEquipmentSets);
            // Increase stats by equipment set bonus
            cacheStats          += bonusStats;
            cacheAttributes      = GameDataHelpers.CombineAttributes(cacheAttributes, bonusAttributes);
            cacheResistances     = GameDataHelpers.CombineResistances(cacheResistances, bonusResistances);
            cacheIncreaseDamages = GameDataHelpers.CombineDamages(cacheIncreaseDamages, bonusIncreaseDamages);
            cacheWeightLimit    += bonusStats.weightLimit;

            if (uiTextWeightLimit != null)
            {
                uiTextWeightLimit.text = string.Format(
                    LanguageManager.GetText(formatKeyWeightLimitStats),
                    GameInstance.Singleton.GameplayRule.GetTotalWeight(Data).ToString("N2"),
                    cacheWeightLimit.ToString("N2"));
            }

            CharacterItem rightHandItem   = Data.EquipWeapons.rightHand;
            CharacterItem leftHandItem    = Data.EquipWeapons.leftHand;
            Item          rightHandWeapon = rightHandItem.GetWeaponItem();
            Item          leftHandWeapon  = leftHandItem.GetWeaponItem();
            Dictionary <DamageElement, MinMaxFloat> rightHandDamages = rightHandWeapon != null?GameDataHelpers.CombineDamages(cacheIncreaseDamages, rightHandWeapon.GetDamageAmount(rightHandItem.level, rightHandItem.GetEquipmentBonusRate(), Data)) : null;

            Dictionary <DamageElement, MinMaxFloat> leftHandDamages = leftHandWeapon != null?GameDataHelpers.CombineDamages(cacheIncreaseDamages, leftHandWeapon.GetDamageAmount(leftHandItem.level, leftHandItem.GetEquipmentBonusRate(), Data)) : null;

            if (uiTextWeaponDamages != null)
            {
                string textDamages = "";
                if (rightHandWeapon != null)
                {
                    MinMaxFloat sumDamages = GameDataHelpers.GetSumDamages(rightHandDamages);
                    if (!string.IsNullOrEmpty(textDamages))
                    {
                        textDamages += "\n";
                    }
                    textDamages += string.Format(
                        LanguageManager.GetText(formatKeyWeaponDamage),
                        sumDamages.min.ToString("N0"),
                        sumDamages.max.ToString("N0"));
                }
                if (leftHandWeapon != null)
                {
                    MinMaxFloat sumDamages = GameDataHelpers.GetSumDamages(leftHandDamages);
                    if (!string.IsNullOrEmpty(textDamages))
                    {
                        textDamages += "\n";
                    }
                    textDamages += string.Format(
                        LanguageManager.GetText(formatKeyWeaponDamage),
                        sumDamages.min.ToString("N0"),
                        sumDamages.max.ToString("N0"));
                }
                if (rightHandWeapon == null && leftHandWeapon == null)
                {
                    Item defaultWeaponItem = GameInstance.Singleton.DefaultWeaponItem;
                    WeaponItemEquipType defaultWeaponItemType = defaultWeaponItem.EquipType;
                    KeyValuePair <DamageElement, MinMaxFloat> damageAmount = defaultWeaponItem.GetDamageAmount(1, 1f, Data);
                    textDamages = string.Format(
                        LanguageManager.GetText(formatKeyWeaponDamage),
                        damageAmount.Value.min.ToString("N0"),
                        damageAmount.Value.max.ToString("N0"));
                }
                uiTextWeaponDamages.text = textDamages;
            }

            if (uiRightHandDamages != null)
            {
                if (rightHandWeapon == null)
                {
                    uiRightHandDamages.Hide();
                }
                else
                {
                    uiRightHandDamages.Show();
                    uiRightHandDamages.Data = rightHandDamages;
                }
            }

            if (uiLeftHandDamages != null)
            {
                if (leftHandWeapon == null)
                {
                    uiLeftHandDamages.Hide();
                }
                else
                {
                    uiLeftHandDamages.Show();
                    uiLeftHandDamages.Data = leftHandDamages;
                }
            }

            if (uiCharacterStats != null)
            {
                uiCharacterStats.Data = cacheStats;
            }

            if (uiCharacterResistances != null)
            {
                uiCharacterResistances.Data = cacheResistances;
            }

            if (CacheUICharacterAttributes.Count > 0 && Data != null)
            {
                CharacterAttribute tempCharacterAttribute;
                Attribute          tempAttribute;
                short tempAmount;
                IList <CharacterAttribute> characterAttributes = Data.Attributes;
                for (int indexOfData = 0; indexOfData < characterAttributes.Count; ++indexOfData)
                {
                    tempCharacterAttribute = characterAttributes[indexOfData];
                    tempAttribute          = tempCharacterAttribute.GetAttribute();
                    UICharacterAttribute cacheUICharacterAttribute;
                    tempAmount = 0;
                    if (CacheUICharacterAttributes.TryGetValue(tempAttribute, out cacheUICharacterAttribute))
                    {
                        if (cacheAttributes.ContainsKey(tempAttribute))
                        {
                            tempAmount = cacheAttributes[tempAttribute];
                        }
                        cacheUICharacterAttribute.Setup(new CharacterAttributeTuple(tempCharacterAttribute, tempAmount), Data, indexOfData);
                        cacheUICharacterAttribute.Show();
                    }
                }
            }

            if (uiCharacterBuffs != null)
            {
                uiCharacterBuffs.UpdateData(Data);
            }
        }