コード例 #1
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);
 }
コード例 #2
0
 public bool getFromNeighbour()
 {
     if (neighbor != null)
     {
         MaterialHolder neighbourPresent = neighbor.takeMaterial(materialHolded, grabCount);
         addMaterial(neighbourPresent.getMaterialId(), neighbourPresent.getCount());
         return(true);
     }
     return(false);
 }