/*public void RestoreItems(int[] restoredSlotID, int[] restoredValue, int[] restoredName){ * slotID [indexID] = item.itemID; * slotValue [indexID] = item.itemValue; * slotName [indexID] = item.itemName; * slotDesc [indexID] = item.itemDesc; * slotSprite [indexID] = item.itemSprite; * slotType [indexID] = item.itemType; * slotIcon[indexID].sprite = item.itemSprite; * slotStack [indexID]++; * EnableItem(ID); * }*/ public void PurchaseItem(int ID) //This method allows the player to purchase an item based on value of given item ID { BarController coinScript = this.gameObject.GetComponent <BarController>(); if (InventoryFull() == false) { Debug.Log(coinScript.GetCoins()); Item item = ItemDatabase.GetItem(storeItems[ID]); Debug.Log(item.itemValue); if (coinScript.GetCoins() >= item.itemValue) { //Subtract the correct amount of coins coinScript.SetCoins(coinScript.GetCoins() - item.itemValue); ItemClicked(storeItems[ID]); coinScript.InvokeSound(coinScript.craftSound); StartCoroutine(coinScript.InvokeMessage("+ITEM!", 1f)); } else { //YOU DONT HAVE ENOUGH COINS coinScript.InvokeSound(coinScript.errorSound); StartCoroutine(coinScript.InvokeMessage("NOT ENOUGH COINS!", 1f)); } } else { coinScript.InvokeSound(coinScript.errorSound); StartCoroutine(coinScript.InvokeMessage("INVENTORY FULL!", 1f)); } }
public void UseItemClicked() { if (slotStack [clickedSlotID] > 0) { //USE THE ITEM then YOU USED ITEM X slotStack[clickedSlotID]--; //Magic Barries heal if (slotID[clickedSlotID] == 2) { this.gameObject.GetComponent <BarController>().MagicBarriesHeal(); } if (slotID[clickedSlotID] == 17) { this.gameObject.GetComponent <BarController>().ToilAndTrouble(); } if (slotID[clickedSlotID] == 18) { this.gameObject.GetComponent <BarController>().Dice(); } if (slotID[clickedSlotID] == 21) { this.gameObject.GetComponent <BarController>().Apple(); } if (slotID[clickedSlotID] == 22) { this.gameObject.GetComponent <BarController>().Marmalade(); } if (slotID[clickedSlotID] == 23) { this.gameObject.GetComponent <BarController>().CraftingScroll(); } if (slotID[clickedSlotID] == 27) { this.gameObject.GetComponent <BarController>().ResourceSack(); } BarController player = this.gameObject.GetComponent <BarController>(); player.InvokeSound(player.powerUpSound); if (slotStack [clickedSlotID] <= 0) { //CLEAR ITEM FROM SLOT slotID [clickedSlotID] = 0; slotValue [clickedSlotID] = 0; slotName [clickedSlotID] = ""; slotDesc [clickedSlotID] = ""; slotSprite [clickedSlotID] = null; slotType [clickedSlotID] = 0; slotIcon[clickedSlotID].sprite = emptySlotSprite; DisableItem(selectedItemID); } } }
public void PromptPlayer() { BarController barController = GameObject.Find("Captain").GetComponent <BarController>(); if (barController.foundKey == true) { //UNLOCK THE NPC IN THE VILLAGE AND NOTIFY THE PLAYER OF THAT FACT Debug.Log("You have unlocked a new villager"); PlayerInteract playerInteract = GameObject.Find("PickUpRange").GetComponent <PlayerInteract>(); playerInteract.UnlockVillager(npcId); barController.foundKey = false; barController.challengeCounters[6]++; barController.InvokeSound(playerInteract.levelCompleteAudio); Destroy(this.gameObject); } else { okPanel.SetActive(true); content.text = "HEYYY YOUUU HELP ME. YOU CAN RELEASE ME IF YOU FIND THE KEY... MEET ME BACK HERE WHEN YOU DO"; okBtn.onClick.AddListener(delegate { Ok(); }); } }