public void UpdateWindowEquipment(HeroData hero)
    {
        GetComponentInChildren <Outline>().effectColor = Helpers.ReturnRarityColor(equip.Rarity);
        NameBackground.color = Helpers.ReturnRarityColor(equip.Rarity);
        nameText.text        = equip.Name;
        topLineText.text     = "";
        damageText.text      = "";
        statsText.text       = "";

        if (equip.IsEquipped)
        {
            craftButton.gameObject.SetActive(false);
        }
        else
        {
            craftButton.gameObject.SetActive(true);
        }

        string groupTypeString = LocalizationManager.Instance.GetLocalizationText("groupType." + equip.Base.group);
        string equipTypeString = LocalizationManager.Instance.GetLocalizationText("equipSlotType." + equip.Base.equipSlot);

        if (equip.Rarity != RarityType.UNIQUE)
        {
            topLineText.text += equip.Base.LocalizedName + "\n";
        }

        if (groupTypeString.Equals(equipTypeString))
        {
            topLineText.text += groupTypeString + "\n";
        }
        else
        {
            if (equip.Base.equipSlot == EquipSlotType.WEAPON)
            {
                if (equip.GetGroupTypes().Contains(GroupType.MELEE_WEAPON))
                {
                    equipTypeString = "Melee " + equipTypeString;
                }
                else if (equip.GetGroupTypes().Contains(GroupType.RANGED_WEAPON))
                {
                    equipTypeString = "Ranged " + equipTypeString;
                }
            }
            topLineText.text += groupTypeString + " (" + equipTypeString + ")\n";
        }

        topLineText.text += "Item Level " + equip.ItemLevel;
        if (equip.Rarity != RarityType.UNIQUE)
        {
            topLineText.text += " (Drop Level " + equip.Base.dropLevel + ")\n";
        }
        else
        {
            topLineText.text += '\n';
        }
        topLineText.text += LocalizationManager.Instance.GetRequirementText(equip);

        if (equip.GetItemType() == ItemType.ARMOR)
        {
            UpdateWindowEquipment_Armor((Armor)equip);
        }
        else if (equip.GetItemType() == ItemType.WEAPON)
        {
            UpdateWindowEquipment_Weapon((Weapon)equip);
        }

        innateText.text = "";
        prefixText.text = "";
        suffixText.text = "";

        if (equip.innate.Count > 0)
        {
            innateHeader.gameObject.SetActive(true);
            foreach (Affix a in equip.innate)
            {
                innateText.text += Affix.BuildAffixString(a.Base, Helpers.AFFIX_STRING_SPACING, a, a.GetAffixValues(), a.GetEffectValues());
            }
        }
        else
        {
            innateHeader.gameObject.SetActive(false);
        }

        if (equip.prefixes.Count > 0)
        {
            prefixHeader.gameObject.SetActive(true);
            if (equip.Rarity == RarityType.UNIQUE)
            {
                prefixHeader.headerText.text = "Affixes";
            }
            else
            {
                prefixHeader.headerText.text = "Prefixes";
            }
            foreach (Affix a in equip.prefixes)
            {
                prefixText.text += Affix.BuildAffixString(a.Base, Helpers.AFFIX_STRING_SPACING, a, a.GetAffixValues(), a.GetEffectValues());
            }
        }
        else
        {
            prefixHeader.gameObject.SetActive(false);
        }

        if (equip.suffixes.Count > 0)
        {
            suffixHeader.gameObject.SetActive(true);
            foreach (Affix a in equip.suffixes)
            {
                suffixText.text += Affix.BuildAffixString(a.Base, Helpers.AFFIX_STRING_SPACING, a, a.GetAffixValues(), a.GetEffectValues());
            }
        }
        else
        {
            suffixHeader.gameObject.SetActive(false);
        }

        if (hero != null)
        {
            scrollParent.offsetMin = new Vector2(scrollParent.offsetMin.x, 45);
            EquipButtonParent.gameObject.SetActive(true);
            EquipButtonParent.GetComponentInChildren <Button>().interactable = hero.CanEquipItem(equip);
        }
        else
        {
            scrollParent.offsetMin = new Vector2(scrollParent.offsetMin.x, 0);
            EquipButtonParent.gameObject.SetActive(false);
            EquipButtonParent.GetComponentInChildren <Button>().interactable = true;
        }
    }
Exemplo n.º 2
0
    public void UpdateWindow()
    {
        bool skipOffhandUpdate = false;

        hero = HeroDetailWindow.hero;
        foreach (HeroEquipmentSlot slot in equipSlots)
        {
            slot.slotText.text = LocalizationManager.Instance.GetLocalizationText("equipSlotType." + slot.EquipSlot);
            Equipment e = hero.GetEquipmentInSlot(slot.EquipSlot);

            if (slot.EquipSlot == EquipSlotType.OFF_HAND && skipOffhandUpdate)
            {
                continue;
            }

            if (e == null)
            {
                slot.slotBase.ClearSlot();
                int equippableCount = 0;
                if (slot.EquipSlot == EquipSlotType.OFF_HAND)
                {
                    equippableCount = GameManager.Instance.PlayerStats.EquipmentInventory.Where(x => hero.CanEquipItem(x) && HeroEquipmentSlot.OffhandFilter(x)).Count();
                }
                else if (slot.EquipSlot == EquipSlotType.RING_SLOT_1 || slot.EquipSlot == EquipSlotType.RING_SLOT_2)
                {
                    equippableCount = GameManager.Instance.PlayerStats.EquipmentInventory.Where(x => !x.IsEquipped && x.Base.equipSlot == EquipSlotType.RING && hero.CanEquipItem(x)).Count();
                }
                else
                {
                    equippableCount = GameManager.Instance.PlayerStats.EquipmentInventory.Where(x => !x.IsEquipped && x.Base.equipSlot == slot.EquipSlot && hero.CanEquipItem(x)).Count();
                }
                slot.slotBase.groupText.text = equippableCount + " Equippable Items";
            }
            else
            {
                slot.slotBase.item = e;
                slot.slotBase.UpdateSlot();
            }

            if (slot.EquipSlot == EquipSlotType.WEAPON)
            {
                if (e == null)
                {
                    OffHandSlot.GetComponent <Button>().interactable = true;
                }
                else if (!hero.GetEquipmentGroupTypes(e).Contains(GroupType.TWO_HANDED_WEAPON) ||
                         hero.HasSpecialBonus(BonusType.TWO_HANDED_WEAPONS_ARE_ONE_HANDED) ||
                         (hero.HasSpecialBonus(BonusType.CAN_USE_SPEARS_WITH_SHIELDS) && e.GetGroupTypes().Contains(GroupType.SPEAR)))
                {
                    OffHandSlot.GetComponent <Button>().interactable = true;
                }
                else
                {
                    OffHandSlot.GetComponent <Button>().interactable = false;
                    OffHandSlot.slotBase.item = e;
                    OffHandSlot.slotBase.UpdateSlot();
                    skipOffhandUpdate = true;
                }
            }
        }
    }