/*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 GetData() { Debug.Log("Saving player data"); levelCounter++; //Save player health BarController player = GameObject.Find("Captain").GetComponent <BarController>(); playerHealth = player.GetHealth(); //Get Coins playerCoins = player.GetCoins(); //Get Resources playerResources = player.GetResources(); //Get Score playerScore = player.GetScore(); //Get Crafting Cost playerCraftingCost = player.craftingCost; //Gey Key playerKey = player.foundKey; //Get Player Revived State playerRevived = player.GetPlayerRevived(); //Get Extra Stats playerUpgradedAttack = player.upgradedDamage; playerUpgradedDefence = player.upgradedDefence; playerUpgradedHealth = player.upgradedHealth; playerUpgradedSpeed = player.upgradedSpeed; //Get Challenge counter playerChallengeCounter = player.challengeCounters; //Get Inventory PlayerInventory inventoryScript = GameObject.Find("Captain").GetComponent <PlayerInventory>(); playerInventory = inventoryScript.slotID; this.slotID = inventoryScript.slotID; this.slotValue = inventoryScript.slotValue; this.slotName = inventoryScript.slotName; this.slotDesc = inventoryScript.slotDesc; this.slotSprite = inventoryScript.slotSprite; this.slotType = inventoryScript.slotType; this.slotStack = inventoryScript.slotStack; this.slotIcon = inventoryScript.slotIcon; //Get Villager villageState = GameObject.Find("PickUpRange").GetComponent <PlayerInteract>().UnlockedVillagers; }