public void LootChest() { openingSound.UnloadAudioData(); currentChestSprite.sprite = openedEmptySprite; AudioSource.PlayClipAtPoint(lootSound, mainCamera.transform.position); chestInteractableScript.enabled = false; dataToPassGameObject.GetComponent <DataToPassBetweenScenes>().openedChestGameObjectNames.Add(this.gameObject.name); if (moneyLoot != 0) { playerInventory.AddCoinAmount(moneyLoot); } if (gameObjectLoot != null) { // Get original name of obj so we dont get (clone) as name when we instantiate string originalItemName = gameObjectLoot.name; GameObject instantiatedObj = Instantiate(gameObjectLoot) as GameObject; instantiatedObj.name = originalItemName; playerInventory.LootItem(instantiatedObj); } }
public void End() { if (questType == Quest.QUESTTYPE.GATHER_ITEMS) { // When a gather items quest is done we want to clear the inventory of said items string itemName = itemToGather.GetComponent <ItemData>().itemName; playerInventory.RemoveCollectedQuestItemsFromInventory(itemName, amountToCollect); } playerInventory.AddCoinAmount(moneyReward); if (gameObjectReward != null) { // To-Do: Check if inventory is full // Get original name of obj so we dont get (clone) when we instantiate string originalItemName = gameObjectReward.name; GameObject instantiatedObj = GameObject.Instantiate(gameObjectReward) as GameObject; instantiatedObj.name = originalItemName; // Add instantiated item to inventory and add text to reward window showing what item we got playerInventory.LootItem(instantiatedObj); } }
void SellItem() { inventory.BuyAndSellItemSound(); inventory.AddCoinAmount(ItemDataGameObject.GetComponent <ItemData>().value); DestroyItem(); }