示例#1
0
    public void Insert()
    {
        if (recipient)
        {
            CollectionData[] cdata = recipient.GetComponents <CollectionData>();
            for (int i = 0; i < cdata.Length; i++)
            {
                CollectionData coldat = cdata[i];

                // find the collection we should insert into, by name
                if (coldat.name == collectionName)
                {
                    coldat.Insert(this);

                    // really, only activate passive aspects if we
                    // successfully inserted into inventory
                    IsPassive pas = GetComponent <IsPassive>();
                    if (pas)
                    {
                        pas.Activate();
                        pas.SetRecipient(this.GetRecipient());
                    }

                    Hide();

                    break;
                }
            }
        }
    }
示例#2
0
    public void Consume()
    {
        if (buffs)
        {
            // late bind recipient
            if (!buffs.GetRecipient())
            {
                buffs.SetRecipient(GetRecipient());
            }

            buffs.Apply();

            // check if item isPassive
            IsPassive passive = gameObject.GetComponent <IsPassive>();
            if (passive == null)
            {
                // if not passive - remove from scene after usage
                Destroy(this.gameObject);
            }
            else
            {
                // do not destroy if passive so temp buffs can be applied that expire over time
                passive.Activate();
                passive.SetRecipient(this.GetRecipient());

                // hide after item is collected
                Hide();
            }
        }
    }