예제 #1
0
 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());
 }
예제 #2
0
 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;
        
 }