Beispiel #1
0
 public void RainSpawn(Cell c, List<GameEntity> nearby)
 {
     if (c.shouldSpawn(nearby) && cells.Count < limit){
     List<int> offspringTypes = c.OffspringTypes(nearby);
     int typeCounter = 0;
     for(int i = 0; i < c.newOffspringCount(nearby); i++){
       if(offspringTypes.Count == 0) break;
       SpawnCell(new Vector2 (c.sprite.Position.X+rng.Next(-20,20), c.sprite.Position.Y+rng.Next(-20,20)), offspringTypes[typeCounter]);
       if(typeCounter < offspringTypes.Count - 1){
     typeCounter++;
       } else{
     typeCounter = 0;
       }
     }
     c.hasReproduced = true;
       }
 }
Beispiel #2
0
 public void NotRainingUpdate(Cell c, List<GameEntity> nearby)
 {
     if(c.watered){
     Console.WriteLine("not raining update");
     if(!c.hasReproduced){
       for(int j = 0; j < nearby.Count; j++){
     Cell e = (Cell)nearby[j];
     if(e.watered){
       Console.WriteLine("watered " + c.type);
       List<int> offspringTypes = c.OffspringTypes(nearby);
       if(offspringTypes.Count == 0) break;
       SpawnCell(new Vector2 (c.sprite.Position.X+rng.Next(-20,20), c.sprite.Position.Y+rng.Next(-20,20)), offspringTypes[0]);
       c.hasReproduced = true;
       c.watered = false;
       break;
     }
       }
     } else {
       //Console.WriteLine("has birthd babby");
     }
       }
 }