private void BuildItemInteractables() { StartConversationScreen scs = (StartConversationScreen)GetScreen(ScreenID.StartConversation); foreach (Item item in items) { GameObject clone = Instantiate(itemPrefab, item.position, Quaternion.identity); ItemClone itemClone = clone.GetComponent <ItemClone>(); itemClone.Init(item); itemPooler.SetPoolable(clone); clone.SetActive(true); playerController.RegisterItemEvents(item); scs.RegisterItem(item); } }
//Player Interaction Controller TO:DO void OnTriggerEnter(Collider other) { //check players inventory activeNPC = other.gameObject.GetComponentInParent <NPC>(); if (activeNPC != null && activeNPC.conversationIndex > -1) { activeNPC.CheckInventoryForTriggers(inventory); } if (activeNPC != null) { return; } activeItem = other.gameObject.GetComponentInParent <ItemClone>(); if (activeItem != null) { activeItem.Inspect(); } }
public Item GetValorItem() { return(ItemClone.Clone(ValorItemInfo, false)); }
//Purchasing items: public void PurchaseItem(Transform ItemSelected) { Item SelectedItemScript = ItemSelected.GetComponent <Item>(); //Getting the item script. bool HasCurrency = true; bool HasAmount = true; bool InvSpace = true; for (int i = 0; i < InvManager.Riches.Length; i++) //Starting a loop in the currencies types: { if (InvManager.Items < InvManager.MaxItems) //If we still have room for new item: { if (InvManager.Riches[i].Name == SelectedItemScript.Currency) //If the required currency type for this item exists in the inventory. { if (InvManager.Riches[i].Amount >= SelectedItemScript.CurrencyAmount) //And if the amount is enough { InvManager.RemoveCurrency(SelectedItemScript.Currency, SelectedItemScript.CurrencyAmount); //Reduce the amount of this currency. Transform ItemClone; ItemClone = Instantiate(ItemSelected, ItemSelected.transform.position, ItemSelected.transform.rotation) as Transform; GetComponent <AudioSource>().PlayOneShot(ItemSold); if (SelectedItemScript.ItemType == 0) { InvManager.AddItem(ItemClone); //Add this item to the bag } if (SelectedItemScript.ItemType == 1) { InvManager.AddCurrency(ItemClone); //Add this currency to the inventory } HasCurrency = true; HasAmount = true; InvSpace = true; CustomEvents.OnPlayerBuyItem(ItemClone.GetComponent <Item>()); return; } else { HasAmount = false; } } else { HasCurrency = false; } } else { InvSpace = false; } } if (InvSpace == false) //If there isn't room for the new item: { if (MsgUI != null) { MsgUI.SendMsg("Inventory is full!"); } } else if (HasCurrency == false) //If we don't have the required type of currency. { if (MsgUI != null) { MsgUI.SendMsg("You don't have " + SelectedItemScript.Currency + "."); } } else if (HasAmount == false) //If we don't have the enough amount of currency. { if (MsgUI != null) { MsgUI.SendMsg("You don't have enough " + SelectedItemScript.Currency + "."); } if (InvManager.AudioSC) { InvManager.AudioSC.PlayOneShot(CantAfford); } } }