private void OnDisable()
 {
     selectedOption        = null;
     currentSelectedButton = null;
     currentItem           = null;
     showAffixDetails      = false;
 }
    public void LockAffixCallback(Affix affix, TextMeshProUGUI costText, Button button)
    {
        if (selectedAffixesToLock.Contains(affix))
        {
            selectedAffixesToLock.Remove(affix);
            button.image.color = new Color(0.8f, 0.8f, 0.8f);
        }
        else if (selectedAffixesToLock.Count < 3)
        {
            selectedAffixesToLock.Add(affix);
            button.image.color = Helpers.SELECTION_COLOR;
        }

        int cost = 0;

        for (int i = 0; i < selectedAffixesToLock.Count; i++)
        {
            if (i < previousLockCount)
            {
                continue;
            }
            cost += AffixedItem.GetLockCost(currentItem, i);
        }

        costText.text = "Current Cost: " + cost + " <sprite=10>";
    }
    public void LockAffixConfirm()
    {
        UIManager.Instance.CloseCurrentWindow();
        currentItem.RemoveAllAffixLocks();
        int cost = 0;

        for (int i = 0; i < selectedAffixesToLock.Count; i++)
        {
            Affix affix = selectedAffixesToLock[i];

            if (i >= previousLockCount)
            {
                cost += -AffixedItem.GetLockCost(currentItem);
            }

            affix.SetAffixLock(true);
        }

        Debug.Log(cost);

        GameManager.Instance.PlayerStats.ModifyItemFragments(cost);

        SaveManager.CurrentSave.SavePlayerData();
        SaveManager.CurrentSave.SaveEquipmentData(currentItem as Equipment);
        SaveManager.Save();

        UpdatePanels();
    }
 public void SetItem(Item item)
 {
     if (item?.GetItemType() == ItemType.ARCHETYPE)
     {
         return;
     }
     currentItem = item as AffixedItem;
     UpdatePanels();
 }
    public void ModifyItem(CraftingButton.CraftingOptionType optionType)
    {
        if (currentItem == null)
        {
            return;
        }

        int cost = 0;

        switch (optionType)
        {
        case CraftingButton.CraftingOptionType.REROLL_AFFIX:
            currentItem.RerollAffixesAtRarity(modifiers);
            currentItem.RemoveAllAffixLocks();
            cost = (int)(-AffixedItem.GetRerollAffixCost(currentItem) * costModifier);
            break;

        case CraftingButton.CraftingOptionType.REROLL_VALUES:
            currentItem.RerollValues();
            currentItem.RemoveAllAffixLocks();
            cost = -AffixedItem.GetRerollValuesCost(currentItem);
            break;

        case CraftingButton.CraftingOptionType.ADD_AFFIX:
            currentItem.AddRandomAffix(modifiers);
            cost = (int)(-AffixedItem.GetAddAffixCost(currentItem) * costModifier);
            break;

        case CraftingButton.CraftingOptionType.REMOVE_AFFIX:
            cost = -AffixedItem.GetRemoveAffixCost(currentItem);
            currentItem.RemoveRandomAffix();
            currentItem.RemoveAllAffixLocks();
            break;

        case CraftingButton.CraftingOptionType.UPGRADE_RARITY:
            cost = (int)(-AffixedItem.GetUpgradeCost(currentItem) * costModifier);
            currentItem.UpgradeRarity();
            currentItem.AddRandomAffix(modifiers);
            break;

        case CraftingButton.CraftingOptionType.TO_NORMAL:
            cost = -AffixedItem.GetToNormalCost(currentItem);
            currentItem.SetRarityToNormal();
            currentItem.RemoveAllAffixLocks();
            break;

        case CraftingButton.CraftingOptionType.LOCK_AFFIX:
            LockAffixOnClick();
            return;
        }
        GameManager.Instance.PlayerStats.ModifyItemFragments(cost);
        SaveManager.CurrentSave.SavePlayerData();
        SaveManager.CurrentSave.SaveEquipmentData(currentItem as Equipment);
        SaveManager.Save();

        UpdatePanels();
    }
Beispiel #6
0
    public static int GetLockCost(AffixedItem currentItem, int lockedAffixesCount = -1)
    {
        int currentCostMod = 1;

        if (lockedAffixesCount == -1)
        {
            lockedAffixesCount = 0;
            foreach (Affix affix in currentItem.GetAllAffixes())
            {
                if (affix.IsLocked)
                {
                    lockedAffixesCount++;
                }
            }
        }

        if (lockedAffixesCount == 1)
        {
            currentCostMod = 2;
        }
        if (lockedAffixesCount == 2)
        {
            currentCostMod = 5;
        }
        if (lockedAffixesCount >= 3)
        {
            return(0);
        }

        switch (currentItem.Rarity)
        {
        case RarityType.UNCOMMON:
            return(currentItem.ItemLevel * 15 * currentCostMod);

        case RarityType.RARE:
            return(currentItem.ItemLevel * 50 * currentCostMod);

        case RarityType.EPIC:
            return(currentItem.ItemLevel * 300 * currentCostMod);

        case RarityType.UNIQUE:
            return(currentItem.ItemLevel * 20 * currentCostMod);

        default:
            return(0);
        }
    }
Beispiel #7
0
    public static int GetUpgradeCost(AffixedItem currentItem)
    {
        switch (currentItem.Rarity)
        {
        case RarityType.NORMAL:
            return(currentItem.ItemLevel * 1);

        case RarityType.UNCOMMON:
            return(currentItem.ItemLevel * 8);

        case RarityType.RARE:
            return(currentItem.ItemLevel * 500);

        default:
            return(0);
        }
    }
Beispiel #8
0
    public static int GetRemoveAffixCost(AffixedItem currentItem)
    {
        switch (currentItem.Rarity)
        {
        case RarityType.UNCOMMON:
            return(currentItem.ItemLevel * 3);

        case RarityType.RARE:
            return(currentItem.ItemLevel * 15);

        case RarityType.EPIC:
            return(currentItem.ItemLevel * 75);

        default:
            return(0);
        }
    }
Beispiel #9
0
    public static int GetRerollValuesCost(AffixedItem currentItem)
    {
        switch (currentItem.Rarity)
        {
        case RarityType.UNCOMMON:
            return(currentItem.ItemLevel * 1);

        case RarityType.RARE:
            return(currentItem.ItemLevel * 2);

        case RarityType.EPIC:
            return(currentItem.ItemLevel * 3);

        case RarityType.UNIQUE:
            return(currentItem.ItemLevel * 2);

        default:
            return(0);
        }
    }
Beispiel #10
0
 public static int GetToNormalCost(AffixedItem currentItem)
 {
     return(currentItem.ItemLevel * 3);
 }
Beispiel #11
0
    public void UpdateButton(AffixedItem currentItem)
    {
        var button = GetComponent <UIKeyButton>();

        if (!button.initialized)
        {
            button.Initialize();
        }

        GetComponentInChildren <TextMeshProUGUI>().text = button.localizedString;

        if (currentItem == null)
        {
            DisableButton(button);
        }
        else
        {
            int   itemFragments = GameManager.Instance.PlayerStats.ItemFragments;
            float cost;
            switch (optionType)
            {
            case CraftingOptionType.REROLL_AFFIX when currentItem.Rarity != RarityType.NORMAL && currentItem.Rarity != RarityType.UNIQUE:
                cost = AffixedItem.GetRerollAffixCost(currentItem) * UIManager.Instance.ItemCraftingPanel.costModifier;
                break;

            case CraftingOptionType.REROLL_VALUES when currentItem.Rarity != RarityType.NORMAL:
                cost = AffixedItem.GetRerollValuesCost(currentItem);
                break;

            case CraftingOptionType.ADD_AFFIX when currentItem.GetRandomOpenAffixType() != null:
                cost = AffixedItem.GetAddAffixCost(currentItem) * UIManager.Instance.ItemCraftingPanel.costModifier;

                break;

            case CraftingOptionType.REMOVE_AFFIX when currentItem.GetRandomAffix() != null:
                cost = AffixedItem.GetRemoveAffixCost(currentItem);

                break;

            case CraftingOptionType.UPGRADE_RARITY when currentItem.Rarity != RarityType.UNIQUE && currentItem.Rarity != RarityType.EPIC:
                cost = AffixedItem.GetUpgradeCost(currentItem) * UIManager.Instance.ItemCraftingPanel.costModifier;
                break;

            case CraftingOptionType.TO_NORMAL when currentItem.Rarity != RarityType.NORMAL && currentItem.Rarity != RarityType.UNIQUE:
                cost = AffixedItem.GetToNormalCost(currentItem);
                break;

            case CraftingOptionType.LOCK_AFFIX when currentItem.GetRandomAffix() != null || currentItem.Rarity == RarityType.UNIQUE:
                cost = AffixedItem.GetLockCost(currentItem);

                break;

            default:
                DisableButton(button);
                return;
            }

            cost = (int)(cost);

            costText = cost.ToString("N0") + " <sprite=10>";

            if (cost != 0)
            {
                GetComponent <Button>().interactable = cost <= itemFragments;
                if (!GetComponent <Button>().interactable)
                {
                    costText = "<color=#aa0000>" + costText + "</color>";
                }
                GetComponentInChildren <TextMeshProUGUI>().text += "\n" + costText;
            }
        }
    }