Exemplo n.º 1
0
        protected override void UpdateData()
        {
            var characterHotkey = Data;
            var skill           = characterHotkey.GetSkill();
            var item            = characterHotkey.GetItem();

            var owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiCharacterSkill != null)
            {
                if (skill == null)
                {
                    uiCharacterSkill.Hide();
                }
                else
                {
                    var index = owningCharacter.IndexOfSkill(characterHotkey.dataId);
                    if (index >= 0 && index < owningCharacter.Skills.Count)
                    {
                        var characterSkill = owningCharacter.Skills[index];
                        uiCharacterSkill.Setup(new SkillTuple(characterSkill.GetSkill(), characterSkill.level), owningCharacter, index);
                        uiCharacterSkill.Show();
                    }
                    else
                    {
                        uiCharacterSkill.Hide();
                    }
                }
            }

            if (uiCharacterItem != null)
            {
                if (item == null)
                {
                    uiCharacterItem.Hide();
                }
                else
                {
                    var index = owningCharacter.IndexOfNonEquipItem(characterHotkey.dataId);
                    if (index >= 0 && index < owningCharacter.NonEquipItems.Count)
                    {
                        var characterItem = owningCharacter.NonEquipItems[index];
                        uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, string.Empty), owningCharacter, index);
                        uiCharacterItem.Show();
                    }
                    else
                    {
                        uiCharacterItem.Hide();
                    }
                }
            }
        }
Exemplo n.º 2
0
 protected void OnDeselectCharacterItem(UICharacterItem ui)
 {
     if (uiItemDialog != null)
     {
         uiItemDialog.Hide();
     }
 }
Exemplo n.º 3
0
        protected override void UpdateData()
        {
            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiCraftingItem != null)
            {
                if (CraftingItem == null)
                {
                    // Hide if crafting item is null
                    uiCraftingItem.Hide();
                }
                else
                {
                    uiCraftingItem.Show();
                    uiCraftingItem.Data = new CharacterItemTuple(CharacterItem.Create(CraftingItem), 1, InventoryType.NonEquipItems);
                }
            }

            if (uiRequireItemAmounts != null)
            {
                if (CraftingItem == null)
                {
                    // Hide if crafting item is null
                    uiRequireItemAmounts.Hide();
                }
                else
                {
                    uiRequireItemAmounts.showAsRequirement = true;
                    uiRequireItemAmounts.Show();
                    uiRequireItemAmounts.Data = ItemCraft.CacheCraftRequirements;
                }
            }

            if (uiTextRequireGold != null)
            {
                if (CraftingItem == null)
                {
                    uiTextRequireGold.text = string.Format(
                        LanguageManager.GetText(formatKeyRequireGold),
                        "0",
                        "0");
                }
                else
                {
                    int currentAmount = 0;
                    if (owningCharacter != null)
                    {
                        currentAmount = owningCharacter.Gold;
                    }
                    uiTextRequireGold.text = string.Format(
                        currentAmount >= ItemCraft.RequireGold ?
                        LanguageManager.GetText(formatKeyRequireGold) :
                        LanguageManager.GetText(formatKeyRequireGoldNotEnough),
                        currentAmount.ToString("N0"),
                        ItemCraft.RequireGold.ToString("N0"));
                }
            }
        }
Exemplo n.º 4
0
 protected void OnDeselectCharacterItem(UICharacterItem ui)
 {
     if (uiItemDialog != null)
     {
         uiItemDialog.onHide.RemoveListener(OnItemDialogHide);
         uiItemDialog.Hide();
         uiItemDialog.onHide.AddListener(OnItemDialogHide);
     }
 }
 protected override void UpdateData()
 {
     if (uiCharacterItem != null)
     {
         if (CharacterItem == null)
         {
             uiCharacterItem.Hide();
         }
         else
         {
             uiCharacterItem.Setup(new CharacterItemTuple(CharacterItem, Level, InventoryType), OwningCharacter, IndexOfData);
             uiCharacterItem.Show();
         }
     }
 }
Exemplo n.º 6
0
        protected override void UpdateData()
        {
            if (uiCharacterItem != null)
            {
                if (Data.item == null)
                {
                    uiCharacterItem.Hide();
                }
                else
                {
                    uiCharacterItem.Setup(new CharacterItemTuple(CharacterItem.Create(Data.item), 1, string.Empty), null, -1);
                    uiCharacterItem.Show();
                }
            }

            if (uiTextSellPrice != null)
            {
                uiTextSellPrice.text = string.Format(sellPriceFormat, Data.sellPrice.ToString("N0"));
            }
        }
Exemplo n.º 7
0
        protected override void UpdateData()
        {
            if (uiCraftingItem != null)
            {
                if (ItemCraft.craftingItem == null)
                {
                    uiCraftingItem.Hide();
                }
                else
                {
                    uiCraftingItem.Show();
                    uiCraftingItem.Data = new CharacterItemTuple(CharacterItem.Create(ItemCraft.craftingItem), 1, string.Empty);
                }
            }

            if (uiRequireItemAmounts != null)
            {
                if (ItemCraft.craftingItem == null)
                {
                    uiRequireItemAmounts.Hide();
                }
                else
                {
                    uiRequireItemAmounts.Show();
                    uiRequireItemAmounts.Data = ItemCraft.CacheCraftRequirements;
                }
            }

            if (uiTextRequireGold != null)
            {
                if (ItemCraft.craftingItem == null)
                {
                    uiTextRequireGold.text = string.Format(requireGoldFormat, 0.ToString("N0"));
                }
                else
                {
                    uiTextRequireGold.text = string.Format(requireGoldFormat, ItemCraft.requireGold.ToString("N0"));
                }
            }
        }
Exemplo n.º 8
0
        protected override void UpdateData()
        {
            if (uiCharacterItem != null)
            {
                if (Data.item == null)
                {
                    uiCharacterItem.Hide();
                }
                else
                {
                    uiCharacterItem.Setup(new CharacterItemTuple(CharacterItem.Create(Data.item), 1, InventoryType.NonEquipItems), null, -1);
                    uiCharacterItem.Show();
                }
            }

            if (uiTextSellPrice != null)
            {
                uiTextSellPrice.text = string.Format(
                    LanguageManager.GetText(formatKeySellPrice),
                    Data.sellPrice.ToString("N0"));
            }
        }
Exemplo n.º 9
0
        protected override void UpdateUI()
        {
            Profiler.BeginSample("UIRefineItem - Update UI");
            var owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiRefiningItem != null)
            {
                if (CharacterItem == null)
                {
                    uiRefiningItem.Hide();
                }
                else
                {
                    uiRefiningItem.Setup(new CharacterItemTuple(CharacterItem, Level, string.Empty), owningCharacter, Data);
                    uiRefiningItem.Show();
                }
            }

            if (uiRequireItemAmounts != null)
            {
                if (!CanRefine)
                {
                    uiRequireItemAmounts.Hide();
                }
                else
                {
                    uiRequireItemAmounts.Show();
                    uiRequireItemAmounts.Data = RefineLevel.RequireItems;
                }
            }

            if (uiTextRequireGold != null)
            {
                if (!CanRefine)
                {
                    uiTextRequireGold.text = string.Format(requireGoldFormat, 0.ToString("N0"));
                }
                else
                {
                    uiTextRequireGold.text = string.Format(requireGoldFormat, RefineLevel.RequireGold.ToString("N0"));
                }
            }

            if (uiTextSuccessRate != null)
            {
                if (!CanRefine)
                {
                    uiTextSuccessRate.text = string.Format(successRateFormat, 0.ToString("N2"));
                }
                else
                {
                    uiTextSuccessRate.text = string.Format(successRateFormat, (RefineLevel.SuccessRate * 100f).ToString("N2"));
                }
            }

            if (uiTextRefiningLevel != null)
            {
                if (!CanRefine)
                {
                    uiTextRefiningLevel.text = string.Format(refiningLevelFormat, (Level - 1).ToString("N0"));
                }
                else
                {
                    uiTextRefiningLevel.text = string.Format(refiningLevelFormat, Level.ToString("N0"));
                }
            }
            Profiler.EndSample();
        }
Exemplo n.º 10
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);
        }
Exemplo n.º 11
0
        protected override void UpdateData()
        {
            CharacterHotkey characterHotkey = Data;
            Skill           skill           = characterHotkey.GetSkill();
            Item            item            = characterHotkey.GetItem();

            BasePlayerCharacterEntity owningCharacter = BasePlayerCharacterController.OwningCharacter;

            if (uiCharacterSkill == null && uiCharacterHotkeys != null && uiCharacterHotkeys.uiCharacterSkillPrefab != null)
            {
                uiCharacterSkill = Instantiate(uiCharacterHotkeys.uiCharacterSkillPrefab, transform);
                GenericUtils.SetAndStretchToParentSize(uiCharacterSkill.transform as RectTransform, transform as RectTransform);
                uiCharacterSkill.transform.SetAsFirstSibling();
            }

            if (uiCharacterItem == null && uiCharacterHotkeys != null && uiCharacterHotkeys.uiCharacterItemPrefab != null)
            {
                uiCharacterItem = Instantiate(uiCharacterHotkeys.uiCharacterItemPrefab, transform);
                GenericUtils.SetAndStretchToParentSize(uiCharacterItem.transform as RectTransform, transform as RectTransform);
                uiCharacterItem.transform.SetAsFirstSibling();
            }

            if (uiCharacterSkill != null)
            {
                if (skill == null)
                {
                    uiCharacterSkill.Hide();
                }
                else
                {
                    Dictionary <Skill, short> allSkills = owningCharacter.GetSkills();
                    short skillLevel = 0;
                    if (allSkills.TryGetValue(characterHotkey.GetSkill(), out skillLevel))
                    {
                        int            index          = owningCharacter.IndexOfSkill(characterHotkey.dataId);
                        CharacterSkill characterSkill = index >= 0 ? owningCharacter.Skills[index] : CharacterSkill.Create(characterHotkey.GetSkill(), skillLevel);
                        uiCharacterSkill.Setup(new CharacterSkillTuple(characterSkill, skillLevel), owningCharacter, index);
                        uiCharacterSkill.Show();
                        UICharacterSkillDragHandler dragHandler = uiCharacterSkill.GetComponentInChildren <UICharacterSkillDragHandler>();
                        if (dragHandler != null)
                        {
                            dragHandler.SetupForHotkey(this);
                        }
                    }
                    else
                    {
                        uiCharacterSkill.Hide();
                    }
                }
            }

            if (uiCharacterItem != null)
            {
                if (item == null)
                {
                    uiCharacterItem.Hide();
                }
                else
                {
                    int index = owningCharacter.IndexOfNonEquipItem(characterHotkey.dataId);
                    if (index >= 0 && index < owningCharacter.NonEquipItems.Count)
                    {
                        CharacterItem characterItem = owningCharacter.NonEquipItems[index];
                        uiCharacterItem.Setup(new CharacterItemTuple(characterItem, characterItem.level, InventoryType.NonEquipItems), owningCharacter, index);
                        uiCharacterItem.Show();
                        UICharacterItemDragHandler dragHandler = uiCharacterItem.GetComponentInChildren <UICharacterItemDragHandler>();
                        if (dragHandler != null)
                        {
                            dragHandler.SetupForHotkey(this);
                        }
                    }
                    else
                    {
                        uiCharacterItem.Hide();
                    }
                }
            }
        }
Exemplo n.º 12
0
        protected override void UpdateData()
        {
            if (Level <= 0)
            {
                onSetLevelZeroData.Invoke();
            }
            else
            {
                onSetNonLevelZeroData.Invoke();
            }

            if (EquipmentItem != null)
            {
                if (!string.IsNullOrEmpty(EquipPosition))
                {
                    onSetEquippedData.Invoke();
                }
                else
                {
                    onSetUnEquippedData.Invoke();
                }
            }
            else
            {
                onSetUnEquippableData.Invoke();
            }

            if (uiTextTitle != null)
            {
                var str = string.Format(titleFormat, Item == null ? "Unknow" : Item.title);
                if (!dontAppendRefineLevelToTitle && EquipmentItem != null)
                {
                    str += string.Format(titleRefineLevelFormat, (Level - 1).ToString("N0"));
                }
                uiTextTitle.text = str;
            }

            if (uiTextDescription != null)
            {
                uiTextDescription.text = string.Format(descriptionFormat, Item == null ? "N/A" : Item.description);
            }

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

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

            if (uiTextItemType != null)
            {
                switch (Item.itemType)
                {
                case ItemType.Junk:
                    uiTextItemType.text = string.Format(itemTypeFormat, junkItemType);
                    break;

                case ItemType.Armor:
                    uiTextItemType.text = string.Format(itemTypeFormat, ArmorItem.ArmorType.title);
                    break;

                case ItemType.Weapon:
                    uiTextItemType.text = string.Format(itemTypeFormat, WeaponItem.WeaponType.title);
                    break;

                case ItemType.Shield:
                    uiTextItemType.text = string.Format(itemTypeFormat, shieldItemType);
                    break;

                case ItemType.Potion:
                    uiTextItemType.text = string.Format(itemTypeFormat, potionItemType);
                    break;

                case ItemType.Ammo:
                    uiTextItemType.text = string.Format(itemTypeFormat, ammoItemType);
                    break;

                case ItemType.Building:
                    uiTextItemType.text = string.Format(itemTypeFormat, buildingItemType);
                    break;

                case ItemType.Pet:
                    uiTextItemType.text = string.Format(itemTypeFormat, petItemType);
                    break;
                }
            }

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

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

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

            if (uiTextWeight != null)
            {
                uiTextWeight.text = string.Format(weightFormat, 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)
            {
                var stats = EquipmentItem.GetIncreaseStats(Level, CharacterItem.GetEquipmentBonusRate());
                if (EquipmentItem == null || stats.IsEmpty())
                {
                    uiStats.Hide();
                }
                else
                {
                    uiStats.Show();
                    uiStats.Data = stats;
                }
            }

            if (uiIncreaseAttributes != null)
            {
                var attributes = EquipmentItem.GetIncreaseAttributes(Level, CharacterItem.GetEquipmentBonusRate());
                if (EquipmentItem == null || attributes == null || attributes.Count == 0)
                {
                    uiIncreaseAttributes.Hide();
                }
                else
                {
                    uiIncreaseAttributes.Show();
                    uiIncreaseAttributes.Data = attributes;
                }
            }

            if (uiIncreaseResistances != null)
            {
                var resistances = EquipmentItem.GetIncreaseResistances(Level, CharacterItem.GetEquipmentBonusRate());
                if (EquipmentItem == null || resistances == null || resistances.Count == 0)
                {
                    uiIncreaseResistances.Hide();
                }
                else
                {
                    uiIncreaseResistances.Show();
                    uiIncreaseResistances.Data = resistances;
                }
            }

            if (uiIncreaseDamageAmounts != null)
            {
                var damageAmounts = EquipmentItem.GetIncreaseDamages(Level, CharacterItem.GetEquipmentBonusRate());
                if (EquipmentItem == null || damageAmounts == null || damageAmounts.Count == 0)
                {
                    uiIncreaseDamageAmounts.Hide();
                }
                else
                {
                    uiIncreaseDamageAmounts.Show();
                    uiIncreaseDamageAmounts.Data = damageAmounts;
                }
            }

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

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

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

            if (uiNextLevelItem != null)
            {
                if (Level + 1 > Item.MaxLevel)
                {
                    uiNextLevelItem.Hide();
                }
                else
                {
                    uiNextLevelItem.Setup(new CharacterItemTuple(CharacterItem, (short)(Level + 1), EquipPosition), character, indexOfData);
                    uiNextLevelItem.Show();
                }
            }
            UpdateShopUIVisibility(true);
            UpdateRefineUIVisibility(true);
            UpdateDealingState(true);
        }