public void Buy() { //can afford if (Money.value >= cost) { //can have multiple if (item is Usable_Amount_Item) { Usable_Amount_Item it = item as Usable_Amount_Item; //Has Max if (it.amount.value >= it.amount.maxVal) { Debug.Log("Max"); AtMaxEvent.Invoke(); } //Not at Max else { Bought(); } } else if (item is Non_Usable_Amount_Item) { Non_Usable_Amount_Item it = item as Non_Usable_Amount_Item; if (it.amount.value >= it.amount.maxVal) { Debug.Log("Max"); AtMaxEvent.Invoke(); } else { Bought(); } } //single only else { //already have one if (collectedItems.items.Contains(item)) { Debug.Log("Has"); HasItemEvent.Invoke(); } //does not have one else { Bought(); } } } //cannot afford else { Debug.Log("Can't Afford"); CannotAffordEvent.Invoke(); } }
private void SetSprites() { for (int i = 0; i < 4; i++) { SlotText[i].SetActive(false); if (equippedItems.items[i] != null) { organizedImages[0][i].GetComponent <Image>().sprite = equippedItems.items[i].sprite; if (equippedItems.items[i] is Usable_Amount_Item) { SlotText[i].SetActive(true); Usable_Amount_Item temp = equippedItems.items[i] as Usable_Amount_Item; SlotText[i].GetComponent <AmountUpdate>().amount = temp.amount; } organizedImages[0][i].GetComponent <Image>().color = Color.white; } else { organizedImages[0][i].GetComponent <Image>().sprite = null; organizedImages[0][i].GetComponent <Image>().color = Color.clear; } } for (int j = 4; j < organizedItems[0].Count; j++) { organizedImages[0][j].SetActive(false); if (currentItems.items.Contains(organizedItems[0][j])) { organizedImages[0][j].SetActive(true); } } for (int i = 1; i < organizedItems.Count; i++) { for (int j = 0; j < organizedItems[i].Count; j++) { organizedImages[i][j].SetActive(false); if (currentItems.items.Contains(organizedItems[i][j])) { organizedImages[i][j].SetActive(true); if (equippedItems.items.Contains(organizedItems[i][j] as Usable_Item_Base)) { organizedImages[i][j].SetActive(false); } } } } }
private void SetSprites() { numtimesthrough = 0; rightIndex = GetRight(equipped.CurrentEquip); numtimesthrough = 0; leftIndex = GetLeft(equipped.CurrentEquip); if (equipped.items[rightIndex] != null) { right.sprite = equipped.items[rightIndex].sprite; right.color = corners; if (equipped.items[rightIndex] is Usable_Amount_Item) { rightAmount.gameObject.SetActive(true); Usable_Amount_Item temp = equipped.items[rightIndex] as Usable_Amount_Item; rightAmount.text = temp.amount.value.ToString(); } else { rightAmount.gameObject.SetActive(false); } } else { rightAmount.gameObject.SetActive(false); right.color = Color.clear; } if (equipped.items[leftIndex] != null) { left.sprite = equipped.items[leftIndex].sprite; left.color = corners; if (equipped.items[leftIndex] is Usable_Amount_Item) { leftAmount.gameObject.SetActive(true); Usable_Amount_Item temp = equipped.items[leftIndex] as Usable_Amount_Item; leftAmount.text = temp.amount.value.ToString(); } else { leftAmount.gameObject.SetActive(false); } } else { left.color = Color.clear; leftAmount.gameObject.SetActive(false); } if (equipped.CurrentItem() != null) { current.sprite = equipped.CurrentItem().sprite; current.color = center; if (equipped.CurrentItem() is Usable_Amount_Item) { currentAmount.gameObject.SetActive(true); Usable_Amount_Item temp = equipped.CurrentItem() as Usable_Amount_Item; currentAmount.text = temp.amount.value.ToString(); } else { currentAmount.gameObject.SetActive(false); } } else { currentAmount.gameObject.SetActive(false); current.color = Color.clear; } }