예제 #1
0
 public void AddToInventory(InventoryLink newLink)
 {
     if (!listOfLinks.Contains(newLink))
     {
         listOfLinks.Add(newLink);
     }
 }
예제 #2
0
        // Upon being enabled, this event will grant the player the specific object
        public override void EventOutcome()
        {
            if (itemToGive is ItemData)
            {
                // We add the new item to the player inventory.
                // Depending on the amount of said item, we will increment or decrement from the player's inventory.
                InventoryItem newItem = new InventoryItem((ItemData)itemToGive, quantity);
                if (Mathf.Sign(quantity) < 0)
                {
                    Debug.Log("Took away " + newItem.SpecifiedItem.itemName + " from player.");
                    playerInventory.RemoveItemFromInventory(newItem, quantity);
                }
                else
                {
                    Debug.Log("Gave player " + newItem.SpecifiedItem.itemName);
                    playerInventory.AddToInventory(newItem);
                }
                isFinished = true;
            }
            else if (itemToGive is GearData)
            {
                // We add the new gear to the inventory
                // Depending on the amount of said item, we will increment or decrement from the player's inventory.
                InventoryGear newGear = new InventoryGear((GearData)itemToGive, quantity);
                if (Mathf.Sign(quantity) < 0)
                {
                    Debug.Log("Took away " + newGear.SpecifiedGear.gearName + " from player.");
                    playerInventory.RemoveGearFromInventory(newGear, quantity);
                }
                else
                {
                    Debug.Log("Gave player " + newGear.SpecifiedGear.gearName);
                    playerInventory.AddToInventory(newGear);
                }
                isFinished = true;
            }
            else if (itemToGive is CharacterData)
            {
                // We add the new party member to the player's inventory
                InventoryParty newCharacter = new InventoryParty((CharacterData)itemToGive);
                Debug.Log("Added " + newCharacter.SpecifiedCharacter.characterName + " to party.");
                playerInventory.AddToInventory(newCharacter);
                isFinished = true;
            }
            else if (itemToGive is LinkData)
            {
                // We add the new link to the player's inventory
                InventoryLink newLink = new InventoryLink((LinkData)itemToGive);
                Debug.Log("Added " + newLink.SpecifiedLink.linkName + " to inventory.");
                playerInventory.AddToInventory(newLink);
                isFinished = true;
            }

            if (canResetItself == true)
            {
                Invoke("ResetEvent", 0.5f);
            }
        }