public void AddValue(Resource value) { var existing = Available.SingleOrDefault(c => c.GetType() == value.GetType()); if (existing != null) existing.Value += value.Value; else Available.Add(value); OnResourcesAdded(new ResourceEventArgs()); }
public bool SubtractValue(Resource value) { var existing = Available.SingleOrDefault(c => c.GetType() == value.GetType()); if (existing != null && existing.Value >= value.Value) { existing.Value -= value.Value; OnResourcesSubtracted(new ResourceEventArgs()); return true; } else return false; }