예제 #1
0
    public bool Drop(CollectableProperties properties)
    {
        if (OnDrop(properties))
        {
            if (collectedItems.Remove(properties))
            {
                return(true);
            }
        }

        return(false);
    }
예제 #2
0
    protected override bool OnCollect(CollectableProperties properties)
    {
        int index = Find(properties.type);

        if (index != -1)
        {
            if (properties.limitModifier)
            {
                if (attributes[index].max == attributes[index].limitMax)
                {
                    //don't collect
                    return(false);
                }

                if ((attributes[index].limitMax - attributes[index].max) > properties.value)
                {
                    attributes[index].max += properties.value;
                }
                else
                {
                    attributes[index].max = attributes[index].limitMax;
                }
            }
            else
            {
                if (attributes[index].value == attributes[index].max)
                {
                    //don't collect
                    return(false);
                }

                if ((attributes[index].max - attributes[index].value) > properties.value)
                {
                    attributes[index].value += properties.value;
                }
                else
                {
                    attributes[index].value = attributes[index].max;
                }
            }
            //trigger event
            TriggerEvent(attributes[index]);

            //inform clients
            SerializeDataStream();

            //collect
            return(true);
        }

        //unknown item - don't collect
        return(false);
    }
예제 #3
0
    public bool Collect(CollectableProperties properties)
    {
        if (OnCollect(properties))
        {
            if (!properties.singleUsage)
            {
                collectedItems.Add(properties);
            }
            return(true);
        }

        return(false);
    }
예제 #4
0
 protected virtual bool OnCollect(CollectableProperties properties)
 {
     Debug.Log(this.name + ": OnCollect not implemented.");
     return(true);
 }
예제 #5
0
 protected override bool OnDrop(CollectableProperties properties)
 {
     //TODO: implementation :)
     return(true);
 }