/// <summary> /// e.g. for showItem sequence, also for use in dialogue /// </summary> /// <param name="itemObject"></param> public void HandleItemReceive(Script_ItemObject itemObject, Script_Player player) { Script_Item item = itemObject.Item; Debug.Log($"{name} Adding item: {item}"); bool pickUpSuccess = game.AddItem(item); if (!pickUpSuccess) { // handle flow to drop an item in inventory } Script_ItemsEventsManager.ItemPickUp(item.id); // Display item above Player's head. player.SetIsPickingUp(item); player.ItemPickUpEffect(true, item); /// Item theatrics here if (itemObject.pickUpTheatricsPlayer != null) { itemObject.pickUpTheatricsPlayer.Play(); return; } Script_Game.Game.dialogueManager.StartDialogueNode( itemObject.GetComponent <Script_DialogueNode>() ); if (!itemObject.showTyping) { Debug.Log("Skipping typing item initial description on receiving item"); Script_Game.Game.dialogueManager.SkipTypingSentence(); } }
/// <summary> /// Gets the Item Object from the Item Dictionary by Id /// </summary> private bool GetItemObjectById(string itemId, out Script_ItemObject itemToAdd) { if (!GetComponent <Script_ItemDictionary>().myDictionary.TryGetValue(itemId, out itemToAdd)) { Debug.LogError($"Getting item: {itemId} from ItemDictionary failed."); return(false); } return(true); }
private Script_ItemObject InstantiateDrop(Script_ItemObject itemToDrop, Vector3 location, int LB) { // create the object in world space Script_ItemObject itemObj = Instantiate( itemToDrop, location, Quaternion.identity ); // only make persistent if is Special if (itemObj.Item.IsSpecial) { itemObj.transform.SetParent(persistentDropsContainer.transform, true); itemObj.myLevelBehavior = LB; } return(itemObj); }