Beispiel #1
0
 public bool addMaterial(MaterialId id, int count)
 {
     if (materialHolded == null)
     {
         materialHolded = new MaterialHolder(id, count);
     }
     else if (materialHolded.getMaterialId() == id)
     {
         materialHolded.Add(count);
         return(true);
     }
     return(false);
 }
Beispiel #2
0
 public MaterialHolder takeMaterial(MaterialHolder holded, int grabCount)
 {
     if (materialHolded != null && (holded == null || holded.getMaterialId() == materialHolded.getMaterialId()))
     {
         int        maxPossible = materialHolded.Substract(grabCount);
         MaterialId mid         = materialHolded.getMaterialId();
         if (maxPossible != grabCount)
         {
             materialHolded = null;
         }
         return(new MaterialHolder(mid, maxPossible));
     }
     return(null);
 }
Beispiel #3
0
 public MaterialHolder(MaterialId materialId, int count)
 {
     this.materialId = materialId;
     this.count      = count;
 }