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 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 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; } } }