예제 #1
0
파일: Tile.cs 프로젝트: OCox1991/Genome
 /// <summary>
 /// Clears the tile, sets all the variables for tile contents to null, sets isBlocked to false.
 /// </summary>
 public void clearTile()
 {
     creature = null;
     plant = null;
     remains = null;
     obstacle = null;
     isBlocked = false;
 }
예제 #2
0
 /// <summary>
 /// Populates the world by adding plants and obstacles
 /// </summary>
 private void populateWorld()
 {
     for (int plantNum = 0; plantNum < Simulation.getPlantPopulation(); plantNum++)
     {
         int[] xy = getRandomClearTile();
         if (xy[0] == -1 && xy[1] == -1)
         {
             throw new Exception("World is full, cannot add any further content");
         }
         else
         {
             Tile t = getTile(xy[1], xy[0]);
             Plant p = new Plant(randomNumberGenerator);
             p.setLocation(xy[0], xy[1]);
             plantList.Add(p);
             t.addPlant(p);
         }
     }
     for (int obstNum = 0; obstNum < Simulation.getNumObstacles(); obstNum++)
     {
         int[] xy = getRandomClearTile();
         if (xy[0] == -1 && xy[1] == -1)
         {
             throw new Exception("World is full, cannot add any further content");
         }
         else
         {
             Tile t = getTile(xy[1], xy[0]);
             Obstacle o = new Obstacle();
             o.setLocation(xy[0], xy[1]);
             t.addObstacle(o);
         }
     }
 }
예제 #3
0
 /// <summary>
 /// Gets a specified tile given a row and column
 /// </summary>
 /// <param name="row">The row of the tile to look at</param>
 /// <param name="col">The column of the tile to look at</param>
 /// <returns>The tile found at the given row and column</returns>
 public Tile getTile(int row, int col)
 {
     Tile t = null;
     if (col < 0 || col > tiles.Length - 1)
     {
         t = new Tile();
         Obstacle o = new Obstacle();
         o.setLocation(col, row);
         t.addObstacle(o);
     }
     else if (row < 0 || row > tiles[col].Length - 1)
     {
         t = new Tile();
         Obstacle o = new Obstacle();
         o.setLocation(col, row);
         t.addObstacle(o);
     }
     else
     {
         t = tiles[col][row];
     }
     return t;
 }
예제 #4
0
파일: Tile.cs 프로젝트: OCox1991/Genome
 /// <summary>
 /// Adds an obstacle to the tile, sets the obstacle variable to the specified obstacle and sets the tile to be blocked
 /// </summary>
 /// <param name="c">The obstacle to add to the tile</param>
 public void addObstacle(Obstacle o)
 {
     obstacle = o;
     isBlocked = true;
 }