예제 #1
0
        /// <summary>
        /// Is function will be called at server to order character to attack
        /// </summary>
        protected virtual void NetFuncAttack()
        {
            if (Time.unscaledTime - lastActionCommandReceivedTime < ACTION_COMMAND_DELAY)
            {
                return;
            }
            lastActionCommandReceivedTime = Time.unscaledTime;

            if (!CanMoveOrDoActions())
            {
                return;
            }

            // Prepare requires data
            AnimActionType animActionType;
            int            dataId;
            int            animationIndex;
            CharacterItem  weapon;
            float          triggerDuration;
            float          totalDuration;
            DamageInfo     damageInfo;
            Dictionary <DamageElement, MinMaxFloat> allDamageAmounts;

            GetAttackingData(
                out animActionType,
                out dataId,
                out animationIndex,
                out weapon,
                out triggerDuration,
                out totalDuration,
                out damageInfo,
                out allDamageAmounts);

            // Reduce ammo amount
            if (weapon != null)
            {
                var weaponType = weapon.GetWeaponItem().WeaponType;
                if (weaponType.requireAmmoType != null)
                {
                    Dictionary <CharacterItem, short> decreaseItems;
                    if (!this.DecreaseAmmos(weaponType.requireAmmoType, 1, out decreaseItems))
                    {
                        return;
                    }
                    var firstEntry    = decreaseItems.FirstOrDefault();
                    var characterItem = firstEntry.Key;
                    var item          = characterItem.GetItem();
                    if (item != null && firstEntry.Value > 0)
                    {
                        allDamageAmounts = GameDataHelpers.CombineDamageAmountsDictionary(allDamageAmounts, item.GetIncreaseDamages(characterItem.level, characterItem.GetEquipmentBonusRate()));
                    }
                }
            }

            // Play animation on clients
            RequestPlayActionAnimation(animActionType, dataId, (byte)animationIndex);

            // Start attack routine
            StartCoroutine(AttackRoutine(CacheTransform.position, triggerDuration, totalDuration, weapon, damageInfo, allDamageAmounts));
        }
예제 #2
0
 public static float GetEffectivenessDamage(this Skill skill, ICharacterData character)
 {
     if (skill == null)
     {
         return(1f);
     }
     return(GameDataHelpers.GetEffectivenessDamage(skill.CacheEffectivenessAttributes, character));
 }
예제 #3
0
 public static KeyValuePair <DamageElement, MinMaxFloat> GetDamageAmount(this Skill skill, short level, ICharacterData character)
 {
     if (!skill.IsAttack() || skill.skillAttackType != SkillAttackType.Normal)
     {
         return(new KeyValuePair <DamageElement, MinMaxFloat>());
     }
     return(GameDataHelpers.MakeDamage(skill.damageAmount, level, 1f, skill.GetEffectivenessDamage(character)));
 }
예제 #4
0
 public static Dictionary <DamageElement, MinMaxFloat> GetDamageAmountWithInflictions(this Item weaponItem, short level, float rate, ICharacterData character, Dictionary <DamageElement, float> damageInflictionAmounts)
 {
     if (weaponItem == null ||
         !weaponItem.IsWeapon())
     {
         return(new Dictionary <DamageElement, MinMaxFloat>());
     }
     return(GameDataHelpers.MakeDamageAmountWithInflictions(weaponItem.damageAmount, level, rate, weaponItem.GetEffectivenessDamage(character), damageInflictionAmounts));
 }
예제 #5
0
 public static KeyValuePair <DamageElement, MinMaxFloat> GetDamageAmount(this Item weaponItem, short level, float rate, ICharacterData character)
 {
     if (weaponItem == null ||
         !weaponItem.IsWeapon())
     {
         return(new KeyValuePair <DamageElement, MinMaxFloat>());
     }
     return(GameDataHelpers.MakeDamageAmountPair(weaponItem.damageAmount, level, rate, weaponItem.GetEffectivenessDamage(character)));
 }
예제 #6
0
 public static Dictionary <DamageElement, MinMaxFloat> GetAdditionalDamageAmounts(this Skill skill, short level)
 {
     if (!skill.IsAttack())
     {
         return(new Dictionary <DamageElement, MinMaxFloat>());
     }
     level = skill.GetAdjustedLevel(level);
     return(GameDataHelpers.CombineDamages(skill.additionalDamageAmounts, new Dictionary <DamageElement, MinMaxFloat>(), level, 1f));
 }
예제 #7
0
 public static Dictionary <DamageElement, float> GetWeaponDamageInflictions(this Skill skill, short level)
 {
     if (!skill.IsAttack())
     {
         return(new Dictionary <DamageElement, float>());
     }
     level = skill.GetAdjustedLevel(level);
     return(GameDataHelpers.CombineDamageInflictions(skill.weaponDamageInflictions, new Dictionary <DamageElement, float>(), level));
 }
예제 #8
0
 public static float GetEffectivenessDamage(this Item weaponItem, ICharacterData character)
 {
     if (weaponItem == null ||
         !weaponItem.IsWeapon() ||
         character == null)
     {
         return(0f);
     }
     return(GameDataHelpers.GetEffectivenessDamage(weaponItem.WeaponType.CacheEffectivenessAttributes, character));
 }
예제 #9
0
        public static Dictionary <DamageElement, MinMaxFloat> GetIncreaseDamages(this Item equipmentItem, short level, float rate)
        {
            var result = new Dictionary <DamageElement, MinMaxFloat>();

            if (equipmentItem != null &&
                equipmentItem.IsEquipment())
            {
                result = GameDataHelpers.MakeDamageAmountsDictionary(equipmentItem.increaseDamages, result, level, rate);
            }
            return(result);
        }
예제 #10
0
        public static Dictionary <DamageElement, float> GetIncreaseResistances(this Item equipmentItem, short level, float rate)
        {
            Dictionary <DamageElement, float> result = new Dictionary <DamageElement, float>();

            if (equipmentItem != null &&
                equipmentItem.IsEquipment())
            {
                result = GameDataHelpers.CombineResistances(equipmentItem.increaseResistances, result, level, rate);
            }
            return(result);
        }
예제 #11
0
        public static Dictionary <Skill, short> GetIncreaseSkills(this Item equipmentItem)
        {
            Dictionary <Skill, short> result = new Dictionary <Skill, short>();

            if (equipmentItem != null &&
                equipmentItem.IsEquipment())
            {
                result = GameDataHelpers.CombineSkills(equipmentItem.increaseSkillLevels, result);
            }
            return(result);
        }
        public virtual void GetAttackingData(
            ref bool isLeftHand,
            out AnimActionType animActionType,
            out int dataId,
            out int animationIndex,
            out CharacterItem weapon,
            out float triggerDuration,
            out float totalDuration,
            out DamageInfo damageInfo,
            out Dictionary <DamageElement, MinMaxFloat> allDamageAmounts)
        {
            // Initialize data
            animActionType   = AnimActionType.None;
            dataId           = 0;
            animationIndex   = 0;
            weapon           = this.GetAvailableWeapon(ref isLeftHand);
            triggerDuration  = 0f;
            totalDuration    = 0f;
            damageInfo       = null;
            allDamageAmounts = new Dictionary <DamageElement, MinMaxFloat>();
            // Prepare weapon data
            Item       weaponItem = weapon.GetWeaponItem();
            WeaponType weaponType = weaponItem.WeaponType;

            // Assign data id
            dataId = weaponType.DataId;
            // Assign animation action type
            animActionType = !isLeftHand ? AnimActionType.AttackRightHand : AnimActionType.AttackLeftHand;
            // Random animation
            if (!isLeftHand)
            {
                CharacterModel.GetRandomRightHandAttackAnimation(dataId, out animationIndex, out triggerDuration, out totalDuration);
            }
            else
            {
                CharacterModel.GetRandomLeftHandAttackAnimation(dataId, out animationIndex, out triggerDuration, out totalDuration);
            }
            // Assign damage data
            damageInfo = weaponType.damageInfo;
            // Calculate all damages
            allDamageAmounts = GameDataHelpers.CombineDamages(
                allDamageAmounts,
                weaponItem.GetDamageAmount(weapon.level, weapon.GetEquipmentBonusRate(), this));
            allDamageAmounts = GameDataHelpers.CombineDamages(
                allDamageAmounts,
                CacheIncreaseDamages);
        }
예제 #13
0
 public static Dictionary <DamageElement, float> GetIncreaseResistances(this Buff buff, short level)
 {
     return(GameDataHelpers.CombineResistances(buff.increaseResistances, new Dictionary <DamageElement, float>(), level, 1f));
 }
예제 #14
0
 public static Dictionary <Attribute, short> GetIncreaseAttributes(this Buff buff, short level)
 {
     return(GameDataHelpers.CombineAttributes(buff.increaseAttributes, new Dictionary <Attribute, short>(), level, 1f));
 }
예제 #15
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);
            }
        }
예제 #16
0
        protected override void UpdateData()
        {
            if (Level <= 0)
            {
                onSetLevelZeroData.Invoke();
            }
            else
            {
                onSetNonLevelZeroData.Invoke();
            }

            if (InventoryType != InventoryType.StorageItems)
            {
                if (EquipmentItem != null)
                {
                    if (InventoryType != InventoryType.NonEquipItems)
                    {
                        onSetEquippedData.Invoke();
                    }
                    else
                    {
                        onSetUnEquippedData.Invoke();
                    }
                }
                else
                {
                    onSetUnEquippableData.Invoke();
                }
            }
            else
            {
                onSetStorageItemData.Invoke();
            }

            if (uiTextTitle != null)
            {
                string str = string.Format(
                    LanguageManager.GetText(formatKeyTitle),
                    Item == null ? LanguageManager.GetUnknowTitle() : Item.Title);
                if (!dontAppendRefineLevelToTitle && EquipmentItem != null && Level > 1)
                {
                    str = string.Format(
                        LanguageManager.GetText(formatKeyTitleWithRefineLevel),
                        (Level - 1).ToString("N0"));
                }
                uiTextTitle.text = str;
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(
                    LanguageManager.GetText(formatKeyDescription),
                    Item == null ? LanguageManager.GetUnknowDescription() : Item.Description);
            }

            if (uiTextRarity != null)
            {
                uiTextRarity.text = string.Format(
                    LanguageManager.GetText(formatKeyRarityTitle),
                    Item == null ? LanguageManager.GetUnknowTitle() : Item.RarityTitle);
            }

            if (uiTextLevel != null)
            {
                if (EquipmentItem != null)
                {
                    if (showLevelAsDefault)
                    {
                        uiTextLevel.text = string.Format(
                            LanguageManager.GetText(formatKeyLevel),
                            Level.ToString("N0"));
                    }
                    else
                    {
                        uiTextLevel.text = string.Format(
                            LanguageManager.GetText(formatKeyRefineLevel),
                            (Level - 1).ToString("N0"));
                    }
                }
                else if (PetItem != null)
                {
                    uiTextLevel.text = string.Format(
                        LanguageManager.GetText(formatKeyLevel),
                        Level.ToString("N0"));
                }
                uiTextLevel.gameObject.SetActive(EquipmentItem != null || PetItem != null);
            }

            if (imageIcon != null)
            {
                Sprite iconSprite = Item == null ? null : Item.icon;
                imageIcon.gameObject.SetActive(iconSprite != null);
                imageIcon.sprite = iconSprite;
            }

            if (uiTextItemType != null)
            {
                if (Item != null)
                {
                    switch (Item.itemType)
                    {
                    case ItemType.Junk:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_JUNK.ToString()));
                        break;

                    case ItemType.Armor:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            ArmorItem.ArmorType.Title);
                        break;

                    case ItemType.Weapon:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            WeaponItem.WeaponType.Title);
                        break;

                    case ItemType.Shield:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_SHIELD.ToString()));
                        break;

                    case ItemType.Potion:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_POTION.ToString()));
                        break;

                    case ItemType.Ammo:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_AMMO.ToString()));
                        break;

                    case ItemType.Building:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_BUILDING.ToString()));
                        break;

                    case ItemType.Pet:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_PET.ToString()));
                        break;

                    case ItemType.SocketEnhancer:
                        uiTextItemType.text = string.Format(
                            LanguageManager.GetText(formatKeyItemType),
                            LanguageManager.GetText(UILocaleKeys.UI_ITEM_TYPE_SOCKET_ENHANCER.ToString()));
                        break;
                    }
                }
            }

            if (uiTextSellPrice != null)
            {
                uiTextSellPrice.text = string.Format(
                    LanguageManager.GetText(formatKeySellPrice),
                    Item == null ? "0" : Item.sellPrice.ToString("N0"));
            }

            if (uiTextStack != null)
            {
                string stackString = "";
                if (Item == null)
                {
                    stackString = string.Format(
                        LanguageManager.GetText(formatKeyStack),
                        "0",
                        "0");
                }
                else
                {
                    stackString = string.Format(
                        LanguageManager.GetText(formatKeyStack),
                        CharacterItem.amount.ToString("N0"),
                        Item.maxStack);
                }
                uiTextStack.text = stackString;
                uiTextStack.gameObject.SetActive(showAmountWhenMaxIsOne || (Item != null && Item.maxStack > 1));
            }

            if (uiTextDurability != null)
            {
                string durabilityString = "";
                if (Item == null)
                {
                    durabilityString = string.Format(
                        LanguageManager.GetText(formatKeyDurability),
                        "0",
                        "0");
                }
                else
                {
                    durabilityString = string.Format(
                        LanguageManager.GetText(formatKeyDurability),
                        CharacterItem.durability.ToString("N0"),
                        Item.maxDurability);
                }
                uiTextDurability.text = durabilityString;
                uiTextDurability.gameObject.SetActive(EquipmentItem != null && Item.maxDurability > 0);
            }

            if (uiTextWeight != null)
            {
                uiTextWeight.text = string.Format(
                    LanguageManager.GetText(formatKeyWeight),
                    Item == null ? "0" : Item.weight.ToString("N2"));
            }

            if (uiRequirement != null)
            {
                if (EquipmentItem == null || (EquipmentItem.requirement.level == 0 && EquipmentItem.requirement.character == null && EquipmentItem.CacheRequireAttributeAmounts.Count == 0))
                {
                    uiRequirement.Hide();
                }
                else
                {
                    uiRequirement.Show();
                    uiRequirement.Data = EquipmentItem;
                }
            }

            if (uiStats != null)
            {
                CharacterStats stats = CharacterStats.Empty;
                if (EquipmentItem != null)
                {
                    stats = EquipmentItem.GetIncreaseStats(Level, CharacterItem.GetEquipmentBonusRate());
                }
                else if (SocketEnhancerItem != null)
                {
                    stats = SocketEnhancerItem.socketEnhanceEffect.stats;
                }

                if (stats.IsEmpty())
                {
                    // Hide ui if stats is empty
                    uiStats.Hide();
                }
                else
                {
                    uiStats.Show();
                    uiStats.Data = stats;
                }
            }

            if (uiIncreaseAttributes != null)
            {
                Dictionary <Attribute, short> attributes = null;
                if (EquipmentItem != null)
                {
                    attributes = EquipmentItem.GetIncreaseAttributes(Level, CharacterItem.GetEquipmentBonusRate());
                }
                else if (SocketEnhancerItem != null)
                {
                    attributes = GameDataHelpers.CombineAttributes(SocketEnhancerItem.socketEnhanceEffect.attributes, attributes, 1f);
                }

                if (attributes == null || attributes.Count == 0)
                {
                    // Hide ui if attributes is empty
                    uiIncreaseAttributes.Hide();
                }
                else
                {
                    uiIncreaseAttributes.Show();
                    uiIncreaseAttributes.Data = attributes;
                }
            }

            if (uiIncreaseResistances != null)
            {
                Dictionary <DamageElement, float> resistances = null;
                if (EquipmentItem != null)
                {
                    resistances = EquipmentItem.GetIncreaseResistances(Level, CharacterItem.GetEquipmentBonusRate());
                }
                else if (SocketEnhancerItem != null)
                {
                    resistances = GameDataHelpers.CombineResistances(SocketEnhancerItem.socketEnhanceEffect.resistances, resistances, 1f);
                }

                if (resistances == null || resistances.Count == 0)
                {
                    // Hide ui if resistances is empty
                    uiIncreaseResistances.Hide();
                }
                else
                {
                    uiIncreaseResistances.Show();
                    uiIncreaseResistances.Data = resistances;
                }
            }

            if (uiIncreaseDamageAmounts != null)
            {
                Dictionary <DamageElement, MinMaxFloat> damageAmounts = null;
                if (EquipmentItem != null)
                {
                    damageAmounts = EquipmentItem.GetIncreaseDamages(Level, CharacterItem.GetEquipmentBonusRate());
                }
                else if (SocketEnhancerItem != null)
                {
                    damageAmounts = GameDataHelpers.CombineDamages(SocketEnhancerItem.socketEnhanceEffect.damages, damageAmounts, 1f);
                }

                if (damageAmounts == null || damageAmounts.Count == 0)
                {
                    // Hide ui if damage amounts is empty
                    uiIncreaseDamageAmounts.Hide();
                }
                else
                {
                    uiIncreaseDamageAmounts.Show();
                    uiIncreaseDamageAmounts.Data = damageAmounts;
                }
            }

            if (uiIncreaseSkillLevels != null)
            {
                Dictionary <Skill, short> skillLevels = null;
                if (EquipmentItem != null)
                {
                    skillLevels = EquipmentItem.GetIncreaseSkills();
                }
                else if (SocketEnhancerItem != null)
                {
                    skillLevels = GameDataHelpers.CombineSkills(SocketEnhancerItem.socketEnhanceEffect.skills, skillLevels);
                }

                if (skillLevels == null || skillLevels.Count == 0)
                {
                    // Hide ui if skill levels is empty
                    uiIncreaseSkillLevels.Hide();
                }
                else
                {
                    uiIncreaseSkillLevels.Show();
                    uiIncreaseSkillLevels.Data = skillLevels;
                }
            }

            if (uiEquipmentSet != null)
            {
                if (EquipmentItem == null || EquipmentItem.equipmentSet == null || EquipmentItem.equipmentSet.effects.Length == 0)
                {
                    // Only equipment item has equipment set data
                    uiEquipmentSet.Hide();
                }
                else
                {
                    uiEquipmentSet.Show();
                    int equippedCount = 0;
                    Character.CacheEquipmentSets.TryGetValue(EquipmentItem.equipmentSet, out equippedCount);
                    uiEquipmentSet.Data = new EquipmentSetWithEquippedCountTuple(EquipmentItem.equipmentSet, equippedCount);
                }
            }

            if (uiEquipmentSockets != null)
            {
                if (EquipmentItem == null || EquipmentItem.maxSocket <= 0)
                {
                    uiEquipmentSockets.Hide();
                }
                else
                {
                    uiEquipmentSockets.Show();
                    uiEquipmentSockets.Data = new EnhancedSocketsWithMaxSocketTuple(CharacterItem.Sockets, EquipmentItem.maxSocket);
                }
            }

            if (uiDamageAmounts != null)
            {
                if (WeaponItem == null)
                {
                    uiDamageAmounts.Hide();
                }
                else
                {
                    uiDamageAmounts.Show();
                    KeyValuePair <DamageElement, MinMaxFloat> keyValuePair = WeaponItem.GetDamageAmount(Level, CharacterItem.GetEquipmentBonusRate(), null);
                    uiDamageAmounts.Data = new DamageElementAmountTuple(keyValuePair.Key, keyValuePair.Value);
                }
            }

            if (PetItem != null && PetItem.petEntity != null)
            {
                int[] expTree      = GameInstance.Singleton.ExpTree;
                int   currentExp   = 0;
                int   nextLevelExp = 0;
                if (CharacterItem.GetNextLevelExp() > 0)
                {
                    currentExp   = CharacterItem.exp;
                    nextLevelExp = CharacterItem.GetNextLevelExp();
                }
                else if (Level - 2 > 0 && Level - 2 < expTree.Length)
                {
                    int maxExp = expTree[Level - 2];
                    currentExp   = maxExp;
                    nextLevelExp = maxExp;
                }

                if (uiTextExp != null)
                {
                    uiTextExp.text = string.Format(
                        LanguageManager.GetText(formatKeyExp),
                        currentExp.ToString("N0"),
                        nextLevelExp.ToString("N0"));
                    uiTextExp.gameObject.SetActive(true);
                }
            }
            else
            {
                if (uiTextExp != null)
                {
                    uiTextExp.gameObject.SetActive(false);
                }
            }

            if (clones != null && clones.Length > 0)
            {
                for (int i = 0; i < clones.Length; ++i)
                {
                    if (clones[i] == null)
                    {
                        continue;
                    }
                    clones[i].Data = Data;
                }
            }

            if (uiNextLevelItem != null)
            {
                if (Level + 1 > Item.MaxLevel)
                {
                    uiNextLevelItem.Hide();
                }
                else
                {
                    uiNextLevelItem.Setup(new CharacterItemTuple(CharacterItem, (short)(Level + 1), InventoryType), Character, IndexOfData);
                    uiNextLevelItem.Show();
                }
            }
            UpdateShopUIVisibility(true);
            UpdateRefineUIVisibility(true);
            UpdateEnhanceSocketUIVisibility(true);
            UpdateStorageUIVisibility(true);
            UpdateDealingState(true);
        }
예제 #17
0
        /// <summary>
        /// Is function will be called at server to order character to use skill
        /// </summary>
        /// <param name="position">Target position to apply skill at</param>
        /// <param name="dataId">Skill's data id which will be used</param>
        protected virtual void NetFuncUseSkill(Vector3 position, int dataId)
        {
            if (Time.unscaledTime - lastActionCommandReceivedTime < ACTION_COMMAND_DELAY)
            {
                return;
            }
            lastActionCommandReceivedTime = Time.unscaledTime;

            if (!CanMoveOrDoActions())
            {
                return;
            }

            var index = this.IndexOfSkill(dataId);

            if (index < 0)
            {
                return;
            }

            var characterSkill = skills[index];

            if (!characterSkill.CanUse(this))
            {
                return;
            }

            // Prepare requires data
            AnimActionType  animActionType;
            int             animationIndex;
            SkillAttackType skillAttackType;
            CharacterItem   weapon;
            float           triggerDuration;
            float           totalDuration;
            DamageInfo      damageInfo;
            Dictionary <DamageElement, MinMaxFloat> allDamageAmounts;

            GetUsingSkillData(
                characterSkill,
                out animActionType,
                out dataId,
                out animationIndex,
                out skillAttackType,
                out weapon,
                out triggerDuration,
                out totalDuration,
                out damageInfo,
                out allDamageAmounts);

            if (weapon != null)
            {
                var weaponType = weapon.GetWeaponItem().WeaponType;
                // Reduce ammo amount
                if (skillAttackType != SkillAttackType.None && weaponType.requireAmmoType != null)
                {
                    Dictionary <CharacterItem, short> decreaseItems;
                    if (!this.DecreaseAmmos(weaponType.requireAmmoType, 1, out decreaseItems))
                    {
                        return;
                    }
                    var firstEntry    = decreaseItems.FirstOrDefault();
                    var characterItem = firstEntry.Key;
                    var item          = characterItem.GetItem();
                    if (item != null && firstEntry.Value > 0)
                    {
                        allDamageAmounts = GameDataHelpers.CombineDamageAmountsDictionary(allDamageAmounts, item.GetIncreaseDamages(characterItem.level, characterItem.GetEquipmentBonusRate()));
                    }
                }
            }

            // Play animation on clients
            RequestPlayActionAnimation(animActionType, dataId, (byte)animationIndex);

            // Start use skill routine
            StartCoroutine(UseSkillRoutine(characterSkill, position, triggerDuration, totalDuration, skillAttackType, weapon, damageInfo, allDamageAmounts));
        }
예제 #18
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);
            }
        }
예제 #19
0
 public static Dictionary <DamageElement, MinMaxFloat> GetIncreaseDamages(this Buff buff, short level)
 {
     return(GameDataHelpers.MakeDamageAmountsDictionary(buff.increaseDamages, new Dictionary <DamageElement, MinMaxFloat>(), level, 1f));
 }
예제 #20
0
 public Dictionary <DamageElement, float> GetCharacterResistances(short level)
 {
     return(GameDataHelpers.MakeResistanceAmountsDictionary(resistances, new Dictionary <DamageElement, float>(), level, 1f));
 }
예제 #21
0
 public Dictionary <Attribute, short> GetCharacterAttributes(short level)
 {
     return(GameDataHelpers.MakeAttributeAmountsDictionary(attributes, new Dictionary <Attribute, short>(), level, 1f));
 }
        private IEnumerator AttackRoutine(
            AnimActionType animActionType,
            int weaponTypeDataId,
            int animationIndex,
            float triggerDuration,
            float totalDuration,
            bool isLeftHand,
            CharacterItem weapon,
            DamageInfo damageInfo,
            Dictionary <DamageElement, MinMaxFloat> allDamageAmounts,
            bool hasAimPosition,
            Vector3 aimPosition)
        {
            if (onAttackRoutine != null)
            {
                onAttackRoutine.Invoke(animActionType, weaponTypeDataId, animationIndex, triggerDuration, totalDuration, isLeftHand, weapon, damageInfo, allDamageAmounts);
            }

            // Play animation on clients
            RequestPlayActionAnimation(animActionType, weaponTypeDataId, (byte)animationIndex);

            yield return(new WaitForSecondsRealtime(triggerDuration));

            // Reduce ammo amount
            Dictionary <DamageElement, MinMaxFloat> increaseDamages;

            ReduceAmmo(weapon, isLeftHand, out increaseDamages);
            if (increaseDamages != null)
            {
                allDamageAmounts = GameDataHelpers.CombineDamages(allDamageAmounts, increaseDamages);
            }

            // If no aim position set with attack function get aim position which set from client-controller if existed
            if (!hasAimPosition && HasAimPosition)
            {
                hasAimPosition = true;
                aimPosition    = AimPosition;
            }

            byte    fireSpread  = 0;
            Vector3 fireStagger = Vector3.zero;

            if (weapon != null && weapon.GetWeaponItem() != null)
            {
                Item weaponItem = weapon.GetWeaponItem();
                // For monsters, their weapon can be null so have to avoid null exception
                fireSpread  = weaponItem.fireSpread;
                fireStagger = weaponItem.fireStagger;
            }

            Vector3 stagger;

            for (int i = 0; i < fireSpread + 1; ++i)
            {
                stagger = new Vector3(Random.Range(-fireStagger.x, fireStagger.x), Random.Range(-fireStagger.y, fireStagger.y));
                LaunchDamageEntity(
                    isLeftHand,
                    weapon,
                    damageInfo,
                    allDamageAmounts,
                    CharacterBuff.Empty,
                    0,
                    hasAimPosition,
                    aimPosition,
                    stagger);
            }
            RequestPlayWeaponLaunchEffect(isLeftHand);
            yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration));

            isAttackingOrUsingSkill = false;
        }
예제 #23
0
        public virtual void GetUsingSkillData(
            Skill skill,
            short level,
            ref bool isLeftHand,
            out AnimActionType animActionType,
            out int skillOrWeaponTypeDataId,
            out int animationIndex,
            out CharacterItem weapon,
            out float triggerDuration,
            out float totalDuration,
            out DamageInfo damageInfo,
            out Dictionary <DamageElement, MinMaxFloat> allDamageAmounts)
        {
            // Initialize data
            animActionType          = AnimActionType.None;
            skillOrWeaponTypeDataId = 0;
            animationIndex          = 0;
            weapon           = this.GetAvailableWeapon(ref isLeftHand);
            triggerDuration  = 0f;
            totalDuration    = 0f;
            damageInfo       = null;
            allDamageAmounts = new Dictionary <DamageElement, MinMaxFloat>();
            // Prepare skill data
            if (skill == null)
            {
                return;
            }
            // Prepare weapon data
            Item       weaponItem = weapon.GetWeaponItem();
            WeaponType weaponType = weaponItem.WeaponType;
            SkillActivateAnimationType useSkillActivateAnimationType = CharacterModel.UseSkillActivateAnimationType(skill);

            // Prepare animation
            if (useSkillActivateAnimationType == SkillActivateAnimationType.UseAttackAnimation && skill.skillAttackType != SkillAttackType.None)
            {
                // If there is no cast animations
                // Assign data id
                skillOrWeaponTypeDataId = weaponType.DataId;
                // Assign animation action type
                animActionType = !isLeftHand ? AnimActionType.AttackRightHand : AnimActionType.AttackLeftHand;
                // Random animation
                if (!isLeftHand)
                {
                    CharacterModel.GetRandomRightHandAttackAnimation(skillOrWeaponTypeDataId, out animationIndex, out triggerDuration, out totalDuration);
                }
                else
                {
                    CharacterModel.GetRandomLeftHandAttackAnimation(skillOrWeaponTypeDataId, out animationIndex, out triggerDuration, out totalDuration);
                }
            }
            else if (useSkillActivateAnimationType == SkillActivateAnimationType.UseActivateAnimation)
            {
                // Assign data id
                skillOrWeaponTypeDataId = skill.DataId;
                // Assign animation action type
                animActionType = AnimActionType.Skill;
                // Random animation
                CharacterModel.GetSkillActivateAnimation(skillOrWeaponTypeDataId, out triggerDuration, out totalDuration);
            }
            // If it is attack skill
            if (skill.skillAttackType != SkillAttackType.None)
            {
                switch (skill.skillAttackType)
                {
                case SkillAttackType.Normal:
                    // Assign damage data
                    damageInfo = skill.damageInfo;
                    // Calculate all damages
                    allDamageAmounts = weaponItem.GetDamageAmountWithInflictions(weapon.level, weapon.GetEquipmentBonusRate(), this, skill.GetWeaponDamageInflictions(level));
                    // Sum damage with additional damage amounts
                    allDamageAmounts = GameDataHelpers.CombineDamages(
                        allDamageAmounts,
                        skill.GetDamageAmount(level, this));
                    // Sum damage with skill damage
                    allDamageAmounts = GameDataHelpers.CombineDamages(
                        allDamageAmounts,
                        skill.GetAdditionalDamageAmounts(level));
                    break;

                case SkillAttackType.BasedOnWeapon:
                    // Assign damage data
                    damageInfo = weaponType.damageInfo;
                    // Calculate all damages
                    allDamageAmounts = weaponItem.GetDamageAmountWithInflictions(weapon.level, weapon.GetEquipmentBonusRate(), this, skill.GetWeaponDamageInflictions(level));
                    // Sum damage with additional damage amounts
                    allDamageAmounts = GameDataHelpers.CombineDamages(
                        allDamageAmounts,
                        skill.GetAdditionalDamageAmounts(level));
                    break;
                }
                allDamageAmounts = GameDataHelpers.CombineDamages(
                    allDamageAmounts,
                    CacheIncreaseDamages);
            }
        }
예제 #24
0
        private IEnumerator UseSkillRoutine(
            Skill skill,
            short level,
            AnimActionType animActionType,
            int skillOrWeaponTypeDataId,
            int animationIndex,
            float triggerDuration,
            float totalDuration,
            bool isLeftHand,
            CharacterItem weapon,
            DamageInfo damageInfo,
            Dictionary <DamageElement, MinMaxFloat> allDamageAmounts,
            bool hasAimPosition,
            Vector3 aimPosition)
        {
            if (onUseSkillRoutine != null)
            {
                onUseSkillRoutine.Invoke(skill, level, animActionType, skillOrWeaponTypeDataId, animationIndex, triggerDuration, totalDuration, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition);
            }

            // Set doing action data
            isCastingSkillCanBeInterrupted = skill.canBeInterruptedWhileCasting;
            isCastingSkillInterrupted      = false;

            float castDuration = skill.GetCastDuration(level);

            if (castDuration > 0f)
            {
                // Play casting effects on clients
                RequestPlayEffect(skill.castEffects.Id);

                // Tell clients that character is casting
                RequestSkillCasting(skill.DataId, castDuration);

                yield return(new WaitForSecondsRealtime(castDuration));
            }

            // If skill casting not interrupted, continue doing action
            if (!isCastingSkillInterrupted || !isCastingSkillCanBeInterrupted)
            {
                // Play animation on clients
                RequestPlayActionAnimation(animActionType, skillOrWeaponTypeDataId, (byte)animationIndex);

                // Update skill usage states
                CharacterSkillUsage newSkillUsage = CharacterSkillUsage.Create(SkillUsageType.Skill, skill.DataId);
                newSkillUsage.Use(this, level);
                skillUsages.Add(newSkillUsage);

                yield return(new WaitForSecondsRealtime(triggerDuration));

                // Reduce ammo amount
                if (skill.skillAttackType != SkillAttackType.None)
                {
                    Dictionary <DamageElement, MinMaxFloat> increaseDamages;
                    ReduceAmmo(weapon, isLeftHand, out increaseDamages);
                    if (increaseDamages != null)
                    {
                        allDamageAmounts = GameDataHelpers.CombineDamages(allDamageAmounts, increaseDamages);
                    }
                }

                ApplySkill(skill, level, isLeftHand, weapon, damageInfo, allDamageAmounts, hasAimPosition, aimPosition);
                yield return(new WaitForSecondsRealtime(totalDuration - triggerDuration));
            }
            isAttackingOrUsingSkill = false;
        }
예제 #25
0
 public static Dictionary <DamageElement, MinMaxFloat> GetDamageOverTimes(this Buff buff, short level)
 {
     return(GameDataHelpers.CombineDamages(buff.damageOverTimes, new Dictionary <DamageElement, MinMaxFloat>(), level, 1f));
 }
예제 #26
0
        protected override void UpdateData()
        {
            if (uiTextDuration != null)
            {
                var duration = Buff.GetDuration(Level);
                uiTextDuration.gameObject.SetActive(duration != 0);
                uiTextDuration.text = string.Format(durationFormat, duration.ToString("N0"));
            }

            if (uiTextRecoveryHp != null)
            {
                var recoveryHp = Buff.GetRecoveryHp(Level);
                uiTextRecoveryHp.gameObject.SetActive(recoveryHp != 0);
                uiTextRecoveryHp.text = string.Format(recoveryHpFormat, recoveryHp.ToString("N0"));
            }

            if (uiTextRecoveryMp != null)
            {
                var recoveryMp = Buff.GetRecoveryMp(Level);
                uiTextRecoveryMp.gameObject.SetActive(recoveryMp != 0);
                uiTextRecoveryMp.text = string.Format(recoveryMpFormat, recoveryMp.ToString("N0"));
            }

            if (uiTextRecoveryStamina != null)
            {
                var recoveryStamina = Buff.GetRecoveryStamina(Level);
                uiTextRecoveryStamina.gameObject.SetActive(recoveryStamina != 0);
                uiTextRecoveryStamina.text = string.Format(recoveryStaminaFormat, recoveryStamina.ToString("N0"));
            }

            if (uiTextRecoveryFood != null)
            {
                var recoveryFood = Buff.GetRecoveryFood(Level);
                uiTextRecoveryFood.gameObject.SetActive(recoveryFood != 0);
                uiTextRecoveryFood.text = string.Format(recoveryFoodFormat, recoveryFood.ToString("N0"));
            }

            if (uiTextRecoveryWater != null)
            {
                var recoveryWater = Buff.GetRecoveryWater(Level);
                uiTextRecoveryWater.gameObject.SetActive(recoveryWater != 0);
                uiTextRecoveryWater.text = string.Format(recoveryWaterFormat, recoveryWater.ToString("N0"));
            }

            if (uiBuffStats != null)
            {
                uiBuffStats.Data = Buff.GetIncreaseStats(Level);
            }

            if (uiBuffAttributes != null)
            {
                uiBuffAttributes.Data = GameDataHelpers.MakeAttributeAmountsDictionary(Buff.increaseAttributes, new Dictionary <Attribute, short>(), Level, 1f);
            }

            if (uiBuffResistances != null)
            {
                uiBuffResistances.Data = GameDataHelpers.MakeResistanceAmountsDictionary(Buff.increaseResistances, new Dictionary <DamageElement, float>(), Level, 1f);
            }

            if (uiBuffDamages != null)
            {
                uiBuffDamages.Data = GameDataHelpers.MakeDamageAmountsDictionary(Buff.increaseDamages, new Dictionary <DamageElement, MinMaxFloat>(), Level, 1f);
            }
        }
예제 #27
0
        public void UpdateData(ICharacterData character)
        {
            this.character = character;
            int selectedSkillId = CacheSkillSelectionManager.SelectedUI != null ? CacheSkillSelectionManager.SelectedUI.Skill.DataId : 0;

            CacheSkillSelectionManager.DeselectSelectedUI();
            CacheSkillSelectionManager.Clear();

            if (character == null)
            {
                CacheSkillList.HideAll();
                return;
            }

            // All skills included equipment skill levels
            displayingSkills = character.GetSkills();

            BaseCharacter database = character.GetDatabase();

            if (database != null)
            {
                CharacterSkill tempCharacterSkill;
                Skill          tempSkill;
                int            tempIndexOfSkill;
                short          tempLevel;
                // Combine skills from database (skill that can level up) and equipment skills
                Dictionary <Skill, short> skillLevels = new Dictionary <Skill, short>();
                skillLevels = GameDataHelpers.CombineSkills(skillLevels, database.CacheSkillLevels);
                skillLevels = GameDataHelpers.CombineSkills(skillLevels, character.GetEquipmentSkills());
                // Filter skills to show by specific skill types / categories
                Dictionary <Skill, short> filteredSkillLevels = new Dictionary <Skill, short>();
                foreach (KeyValuePair <Skill, short> skillLevel in skillLevels)
                {
                    if (string.IsNullOrEmpty(skillLevel.Key.category) ||
                        filterCategories == null || filterCategories.Count == 0 ||
                        filterCategories.Contains(skillLevel.Key.category))
                    {
                        if (filterSkillTypes == null || filterSkillTypes.Count == 0 ||
                            filterSkillTypes.Contains(skillLevel.Key.skillType))
                        {
                            filteredSkillLevels.Add(skillLevel.Key, skillLevel.Value);
                        }
                    }
                }
                skillLevels = filteredSkillLevels;
                // Generate UIs
                CacheSkillList.Generate(skillLevels, (index, skillLevel, ui) =>
                {
                    UICharacterSkill uiCharacterSkill = ui.GetComponent <UICharacterSkill>();
                    tempSkill        = skillLevel.Key;
                    tempIndexOfSkill = character.IndexOfSkill(tempSkill.DataId);
                    // Set character skill data
                    if (tempIndexOfSkill >= 0)
                    {
                        tempCharacterSkill = character.Skills[tempIndexOfSkill];
                    }
                    else
                    {
                        tempCharacterSkill = CharacterSkill.Create(tempSkill, 0);
                    }
                    // Set skill level data
                    tempLevel = 0;
                    if (displayingSkills.ContainsKey(tempSkill))
                    {
                        tempLevel = displayingSkills[tempSkill];
                    }
                    // Set UI data
                    uiCharacterSkill.Setup(new CharacterSkillTuple(tempCharacterSkill, tempLevel), character, tempIndexOfSkill);
                    uiCharacterSkill.Show();
                    UICharacterSkillDragHandler dragHandler = uiCharacterSkill.GetComponentInChildren <UICharacterSkillDragHandler>();
                    if (dragHandler != null)
                    {
                        dragHandler.SetupForSkills(uiCharacterSkill);
                    }
                    CacheSkillSelectionManager.Add(uiCharacterSkill);
                    if (selectedSkillId == skillLevel.Key.DataId)
                    {
                        uiCharacterSkill.OnClickSelect();
                    }
                });
            }
        }
예제 #28
0
        protected override void UpdateData()
        {
            if (uiTextDuration != null)
            {
                float duration = Buff.GetDuration(Level);
                uiTextDuration.gameObject.SetActive(duration != 0);
                uiTextDuration.text = string.Format(
                    LanguageManager.GetText(formatKeyDuration),
                    duration.ToString("N0"));
            }

            if (uiTextRecoveryHp != null)
            {
                int recoveryHp = Buff.GetRecoveryHp(Level);
                uiTextRecoveryHp.gameObject.SetActive(recoveryHp != 0);
                uiTextRecoveryHp.text = string.Format(
                    LanguageManager.GetText(formatKeyRecoveryHp),
                    recoveryHp.ToString("N0"));
            }

            if (uiTextRecoveryMp != null)
            {
                int recoveryMp = Buff.GetRecoveryMp(Level);
                uiTextRecoveryMp.gameObject.SetActive(recoveryMp != 0);
                uiTextRecoveryMp.text = string.Format(
                    LanguageManager.GetText(formatKeyRecoveryMp),
                    recoveryMp.ToString("N0"));
            }

            if (uiTextRecoveryStamina != null)
            {
                int recoveryStamina = Buff.GetRecoveryStamina(Level);
                uiTextRecoveryStamina.gameObject.SetActive(recoveryStamina != 0);
                uiTextRecoveryStamina.text = string.Format(
                    LanguageManager.GetText(formatKeyRecoveryStamina),
                    recoveryStamina.ToString("N0"));
            }

            if (uiTextRecoveryFood != null)
            {
                int recoveryFood = Buff.GetRecoveryFood(Level);
                uiTextRecoveryFood.gameObject.SetActive(recoveryFood != 0);
                uiTextRecoveryFood.text = string.Format(
                    LanguageManager.GetText(formatKeyRecoveryFood),
                    recoveryFood.ToString("N0"));
            }

            if (uiTextRecoveryWater != null)
            {
                int recoveryWater = Buff.GetRecoveryWater(Level);
                uiTextRecoveryWater.gameObject.SetActive(recoveryWater != 0);
                uiTextRecoveryWater.text = string.Format(
                    LanguageManager.GetText(formatKeyRecoveryWater),
                    recoveryWater.ToString("N0"));
            }

            if (uiBuffStats != null)
            {
                uiBuffStats.Data = Buff.GetIncreaseStats(Level);
            }

            if (uiBuffAttributes != null)
            {
                uiBuffAttributes.Data = GameDataHelpers.CombineAttributes(Buff.increaseAttributes, new Dictionary <Attribute, short>(), Level, 1f);
            }

            if (uiBuffResistances != null)
            {
                uiBuffResistances.Data = GameDataHelpers.CombineResistances(Buff.increaseResistances, new Dictionary <DamageElement, float>(), Level, 1f);
            }

            if (uiBuffDamages != null)
            {
                uiBuffDamages.Data = GameDataHelpers.CombineDamages(Buff.increaseDamages, new Dictionary <DamageElement, MinMaxFloat>(), Level, 1f);
            }
        }