Example #1
0
    public void ExpandItemSlot(Equipment equip)
    {
        affixParent.SetActive(true);

        if (equip.prefixes.Count > 0)
        {
            if (equip.Rarity == RarityType.UNIQUE)
            {
                prefixText.text += "<b>Affixes</b>\n";
                suffixText.gameObject.SetActive(false);
            }
            else
            {
                prefixText.text += "<b>Prefixes</b>\n";
            }
            foreach (var x in equip.prefixes)
            {
                prefixText.text += Affix.BuildAffixString(x.Base, 0, x, x.GetAffixValues(), x.GetEffectValues());
            }
        }

        if (equip.suffixes.Count > 0)
        {
            suffixText.gameObject.SetActive(true);
            suffixText.text += "<b>Suffixes</b>\n";
            foreach (var x in equip.suffixes)
            {
                suffixText.text += Affix.BuildAffixString(x.Base, 0, x, x.GetAffixValues(), x.GetEffectValues());
            }
        }
    }
    public void LockAffixOnClick()
    {
        if (currentItem == null)
        {
            return;
        }
        PopUpWindow popUpWindow = UIManager.Instance.PopUpWindow;

        popUpWindow.OpenVerticalWindow();

        popUpWindow.SetButtonValues("Confirm", delegate { LockAffixConfirm(); }, "Cancel", delegate { UIManager.Instance.CloseCurrentWindow(); });

        TextMeshProUGUI textSlot = Instantiate(UIManager.Instance.textPrefab);

        popUpWindow.AddObjectToViewport(textSlot.gameObject);
        previousLockCount = 0;
        selectedAffixesToLock.Clear();
        foreach (Affix affix in currentItem.prefixes.Concat(currentItem.suffixes))
        {
            Button button = Instantiate(UIManager.Instance.buttonPrefab);
            button.GetComponentInChildren <TextMeshProUGUI>().fontSize = 18;
            button.GetComponentInChildren <TextMeshProUGUI>().text     = Affix.BuildAffixString(affix.Base, 0, null, affix.GetAffixValues(), affix.GetEffectValues());
            button.onClick.AddListener(delegate { LockAffixCallback(affix, textSlot, button); });
            popUpWindow.AddObjectToViewport(button.gameObject);

            if (affix.IsLocked)
            {
                previousLockCount++;
                selectedAffixesToLock.Add(affix);
                button.image.color = Helpers.SELECTION_COLOR;
            }
            else
            {
                button.image.color = new Color(0.8f, 0.8f, 0.8f);
            }
        }

        textSlot.text = "Current Cost: 0 <sprite=10>";
    }
Example #3
0
    public void UpdateSlot()
    {
        groupText.text      = "";
        slotText.text       = "";
        prefixText.text     = "";
        suffixText.text     = "";
        baseItemText.text   = "";
        equippedToText.text = "";

        stringBuilder.Clear();
        stringBuilder2.Clear();
        lockImage.gameObject.SetActive(false);
        if (item == null)
        {
            nameText.text   = "Remove item";
            infoText1.text  = "";
            infoText2.text  = "";
            slotImage.color = Color.cyan;
            return;
        }

        nameText.text = item.Name + "\n";

        switch (item.GetItemType())
        {
        case ItemType.ARMOR:
            Armor armor = item as Armor;
            groupText.text = LocalizationManager.Instance.GetLocalizationText(armor.Base.group);
            slotText.text  = LocalizationManager.Instance.GetLocalizationText(armor.Base.equipSlot);
            stringBuilder.AppendFormat("AR: {0} \n", armor.armor);
            stringBuilder.AppendFormat("MS: {0}", armor.shield);
            stringBuilder2.AppendFormat("DR: {0}\n", armor.dodgeRating);
            stringBuilder2.AppendFormat("RR: {0}", armor.resolveRating);
            if (armor.GetGroupTypes().Contains(GroupType.SHIELD))
            {
                stringBuilder.AppendFormat("\nBlock%: {0}%", armor.blockChance);
                stringBuilder2.AppendFormat("\nBlockDmg: {0}%", armor.blockProtection);
            }
            break;

        case ItemType.WEAPON:
            Weapon weapon = item as Weapon;
            groupText.text = LocalizationManager.Instance.GetLocalizationText(weapon.Base.group);

            stringBuilder.AppendFormat("<sprite=0> DPS: {0:n1} \n", weapon.GetPhysicalDPS());
            stringBuilder.AppendFormat("<sprite=7> DPS: {0:n1} \n", weapon.GetElementalDPS());
            stringBuilder.AppendFormat("<sprite=8> DPS: {0:n1}", weapon.GetPrimordialDPS());

            stringBuilder2.AppendFormat("Crit: {0:n2}%\n", weapon.CriticalChance);
            stringBuilder2.AppendFormat("APS: {0:n2}/s\n", weapon.AttackSpeed);
            stringBuilder2.AppendFormat("Range: {0:n2}", weapon.WeaponRange);
            break;

        case ItemType.ACCESSORY:
            Accessory accessory = item as Accessory;
            groupText.text = LocalizationManager.Instance.GetLocalizationText(accessory.Base.group);

            if (!UIManager.Instance.InvScrollContent.showItemAffixes || isHeroSlot)
            {
                if (accessory.prefixes.Count > 0)
                {
                    foreach (Affix prefix in accessory.prefixes)
                    {
                        stringBuilder.Append(Affix.BuildAffixString(prefix.Base, 0, prefix, prefix.GetAffixValues(), prefix.GetEffectValues()));
                    }
                }

                if (accessory.suffixes.Count > 0)
                {
                    foreach (Affix suffix in accessory.suffixes)
                    {
                        stringBuilder2.Append(Affix.BuildAffixString(suffix.Base, 0, suffix, suffix.GetAffixValues(), suffix.GetEffectValues()));
                    }
                }
            }

            break;

        default:
            break;
        }

        infoText1.text = stringBuilder.ToString();
        infoText2.text = stringBuilder2.ToString();

        if (item is Equipment equip)
        {
            if (equip.IsEquipped)
            {
                equippedToText.text = "Equipped to\n" + equip.equippedToHero.Name;
            }

            baseItemText.text = "iLvl " + equip.ItemLevel;

            if (item.Rarity > RarityType.UNCOMMON && item.Rarity != RarityType.UNIQUE)
            {
                baseItemText.text += " " + equip.Base.LocalizedName;
            }
            if (item.Rarity != RarityType.UNIQUE)
            {
                baseItemText.text += " (dLvl " + equip.Base.dropLevel + ")";
            }

            /*
             * if (equip.innate.Count > 0)
             * {
             *  affixText.text += "<b>Innate</b>\n";
             *  foreach(var x in equip.innate)
             *  {
             *      affixText.text += Affix.BuildAffixString(x.Base, 0, x, x.GetAffixValues(), x.GetEffectValues());
             *  }
             * }
             */
            if (UIManager.Instance.InvScrollContent.showItemAffixes && !isHeroSlot)
            {
                ExpandItemSlot(equip);
            }
            else
            {
                DeflateItemSlot();
            }
            slotImage.color = Helpers.ReturnRarityColor(item.Rarity);
        }
        else if (item is ArchetypeItem archetypeItem)
        {
            slotImage.color = Helpers.GetArchetypeStatColor(archetypeItem.Base);
        }
        else if (item is AbilityCoreItem abilityCoreItem)
        {
            if (abilityCoreItem.EquippedHero != null)
            {
                baseItemText.text = "Equipped to " + abilityCoreItem.EquippedHero.Name;
            }
            slotImage.color = Helpers.NORMAL_COLOR;
        }

        if (showItemValue)
        {
            if (baseItemText.text != "")
            {
                baseItemText.text += " | ";
            }
            baseItemText.text += item.GetItemValue();

            if (item is ArchetypeItem)
            {
                baseItemText.text += " <sprite=9>";
            }
            else
            {
                baseItemText.text += " <sprite=10>";
            }
        }


        //nameImage.color = Helpers.ReturnRarityColor(item.Rarity);
    }
    public void ShowAllPossibleAffixes()
    {
        if (currentItem == null)
        {
            return;
        }
        PopUpWindow popUpWindow = UIManager.Instance.PopUpWindow;

        popUpWindow.OpenTextWindow("");
        popUpWindow.SetButtonValues(null, null, "Close", delegate { UIManager.Instance.CloseCurrentWindow(); });
        popUpWindow.textField.text             = "";
        popUpWindow.textField.fontSize         = 18;
        popUpWindow.textField.paragraphSpacing = 8;
        popUpWindow.textField.alignment        = TextAlignmentOptions.Left;
        float levelSkew = craftingModifierWindow.highLevelMod.currentModifier;

        Debug.Log(levelSkew);

        WeightList <AffixBase> possibleAffixes;

        if (currentItem.GetAffixCap() > currentItem.prefixes.Count)
        {
            possibleAffixes = currentItem.GetAllPossiblePrefixes(modifiers, levelSkew);
            if (possibleAffixes.Count > 0)
            {
                popUpWindow.textField.text += "<b>Prefixes</b>\n";
                foreach (var affixBaseWeight in possibleAffixes)
                {
                    float affixPercent = (float)affixBaseWeight.weight / possibleAffixes.Sum * 100f;
                    popUpWindow.textField.text += affixPercent.ToString("F1") + "%" + Affix.BuildAffixString(affixBaseWeight.item, Helpers.AFFIX_STRING_SPACING + 3);
                    popUpWindow.textField.text += "<line-height=0.2em>\n</line-height>";
                }
                popUpWindow.textField.text += "\n";
            }
        }

        if (currentItem.GetAffixCap() > currentItem.suffixes.Count)
        {
            possibleAffixes = currentItem.GetAllPossibleSuffixes(modifiers, levelSkew);
            if (possibleAffixes.Count > 0)
            {
                popUpWindow.textField.text += "<b>Suffixes</b>\n";
                foreach (var affixBaseWeight in possibleAffixes)
                {
                    float affixPercent = (float)affixBaseWeight.weight / possibleAffixes.Sum * 100f;
                    popUpWindow.textField.text += affixPercent.ToString("F1") + "%" + Affix.BuildAffixString(affixBaseWeight.item, Helpers.AFFIX_STRING_SPACING + 3);
                    popUpWindow.textField.text += "<line-height=0.1em>\n</line-height>";
                }
            }
        }
    }
    private void UpdatePanels()
    {
        itemSlot.text.text      = "";
        itemSlot.levelText.text = "";
        //itemSlot.itemBaseText.text = "";
        itemSlot.itemRequirementText.text = "";
        prefixes.text  = "";
        suffixes.text  = "";
        innates.text   = "";
        leftInfo.text  = "";
        rightInfo.text = "";
        itemValue.text = "";
        innateHeader.gameObject.SetActive(false);
        prefixHeader.gameObject.SetActive(false);
        suffixHeader.gameObject.SetActive(false);
        playerFragmentsText.text = GameManager.Instance.PlayerStats.ItemFragments.ToString("N0") + " <sprite=10>";
        UpdateButtons();

        if (currentItem == null)
        {
            itemSlot.text.text = "Select an Item";
            itemSlot.GetComponentInChildren <Image>().color = Helpers.ReturnRarityColor(RarityType.NORMAL);
            topPanelBackground.color = Helpers.ReturnRarityColor(RarityType.NORMAL);
            return;
        }

        itemSlot.text.text      = "<b><smallcaps>" + currentItem.Name + "</smallcaps></b>";
        itemSlot.levelText.text = "ItemLevel<b><size=120%>" + currentItem.ItemLevel + "</size></b>";
        itemSlot.GetComponentInChildren <Image>().color = Helpers.ReturnRarityColor(currentItem.Rarity);
        topPanelBackground.color = Helpers.ReturnRarityColor(currentItem.Rarity);

        if (currentItem.Rarity == RarityType.UNIQUE)
        {
            prefixHeader.SetHeaderValues(0, 0, "Affixes", true);
            prefixHeader.gameObject.SetActive(true);
            suffixHeader.gameObject.SetActive(false);
        }
        else
        {
            prefixHeader.gameObject.SetActive(true);
            suffixHeader.gameObject.SetActive(true);
            int affixCap = currentItem.GetAffixCap();
            //prefixes.text = "<b>Prefixes</b> (" + currentItem.prefixes.Count + " / " + affixCap + ")\n";
            //suffixes.text = "<b>Suffixes</b> (" + currentItem.suffixes.Count + " / " + affixCap + ")\n";
            prefixHeader.SetHeaderValues(currentItem.prefixes.Count, affixCap, "Prefixes");
            suffixHeader.SetHeaderValues(currentItem.suffixes.Count, affixCap, "Suffixes");
        }

        if (currentItem is Equipment equip)
        {
            if (equip.innate.Count > 0)
            {
                innateHeader.gameObject.SetActive(true);
                //innates.text = "<b>Innate</b>\n";
                foreach (Affix a in equip.innate)
                {
                    innates.text += Affix.BuildAffixString(a.Base, Helpers.AFFIX_STRING_SPACING, a, a.GetAffixValues(), a.GetEffectValues());
                }
            }
            else
            {
                innateHeader.gameObject.SetActive(false);
            }

            //itemSlot.itemBaseText.text = equip.Base.idName;
            if (equip.Rarity != RarityType.UNIQUE)
            {
                itemSlot.text.text += "\n<i><size=80%>" + equip.Base.LocalizedName + "</size></i>";
            }
            itemSlot.itemRequirementText.text = LocalizationManager.Instance.GetRequirementText(equip);
        }

        foreach (Affix a in currentItem.prefixes)
        {
            string prefixText = Affix.BuildAffixString(a.Base, Helpers.AFFIX_STRING_SPACING, a, a.GetAffixValues(), a.GetEffectValues(), showAffixDetails, showAffixDetails && currentItem.Rarity != RarityType.UNIQUE);
            prefixes.text += prefixText;
        }

        foreach (Affix a in currentItem.suffixes)
        {
            suffixes.text += Affix.BuildAffixString(a.Base, Helpers.AFFIX_STRING_SPACING, a, a.GetAffixValues(), a.GetEffectValues(), showAffixDetails, showAffixDetails && currentItem.Rarity != RarityType.UNIQUE);
        }

        itemValue.text = "Item Value\n" + currentItem.GetItemValue() + " <sprite=10>";

        if (currentItem.GetItemType() == ItemType.WEAPON)
        {
            UpdateInfo_Weapon(currentItem as Weapon);
        }
        else if (currentItem.GetItemType() == ItemType.ARMOR)
        {
            UpdateInfo_Armor(currentItem as Armor);
        }
    }
    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;
        }
    }