public bool Drop(CollectableProperties properties) { if (OnDrop(properties)) { if (collectedItems.Remove(properties)) { return(true); } } return(false); }
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); }
public bool Collect(CollectableProperties properties) { if (OnCollect(properties)) { if (!properties.singleUsage) { collectedItems.Add(properties); } return(true); } return(false); }
protected virtual bool OnCollect(CollectableProperties properties) { Debug.Log(this.name + ": OnCollect not implemented."); return(true); }
protected override bool OnDrop(CollectableProperties properties) { //TODO: implementation :) return(true); }