예제 #1
0
 /// <summary>
 ///     For each tile it will attempt to visit NESW neighbor and change its Path to true
 ///     Can move to adjacent tile if it is not an environment tile, if it hasn't already been visited and if it not null
 /// </summary>
 /// <param name="envTile">Tile which the path starts from</param>
 public void GetPath(IEnvTile envTile)
 {
     envTile.OnPath = true;
     foreach (var direction in Enum.GetValues(typeof(Direction)).Cast <Direction>())
     {
         if (!envTile.AdjacentTile[direction].HasEnv & !envTile.AdjacentTile[direction].OnPath &
             !(envTile.AdjacentTile[direction] is null))
         {
             GetPath(envTile.AdjacentTile[direction]);
         }
     }
 }
예제 #2
0
        /// <summary>
        ///     Produces matrix of tiles
        /// </summary>
        /// <param name="gridMapSize">max height/width from centre of outermost tile</param>
        /// <param name="planeCentre">centre of the target plane</param>
        /// <returns></returns>
        private IEnvTile[,] CreateTilesMatrix(int gridMapSize, Vector3 planeCentre)
        {
            var tiles = new IEnvTile[gridMapSize + 1, gridMapSize + 1];
            var x     = -gridMapSize;

            for (var i = 0; i < gridMapSize + 1; i++)
            {
                var z = -gridMapSize;
                for (var j = 0; j < gridMapSize + 1; j++)
                {
                    tiles[i, j] =
                        new EnvTile(
                            planeCentre + new Vector3(x, 0.5f, z),
                            (i, j)
                            );
                    z += 2;
                }

                x += 2;
            }

            return(tiles);
        }
예제 #3
0
 private IEnvTile GetDirectionTile(Direction d, IEnvTile inputEnvTile, IEnvTile[,] tileMatrix, int matrixSize)
 {
     if (d == Direction.N)
     {
         return(inputEnvTile.Coords.y == matrixSize
             ? null
             : tileMatrix[inputEnvTile.Coords.x, inputEnvTile.Coords.y + 1]);
     }
     if (d == Direction.E)
     {
         return(inputEnvTile.Coords.x == matrixSize
             ? null
             : tileMatrix[inputEnvTile.Coords.x + 1, inputEnvTile.Coords.y]);
     }
     if (d == Direction.S)
     {
         return(inputEnvTile.Coords.y == 0 ? null : tileMatrix[inputEnvTile.Coords.x, inputEnvTile.Coords.y - 1]);
     }
     if (d == Direction.W)
     {
         return(inputEnvTile.Coords.x == 0 ? null : tileMatrix[inputEnvTile.Coords.x - 1, inputEnvTile.Coords.y]);
     }
     throw new Exception("No direction given in TileMatrix.GetDirectionTile");
 }
예제 #4
0
 /// <summary>
 ///     Checks if a tile can be used as an environment tile to increase difficulty
 /// </summary>
 /// <param name="envTile">Tile to check</param>
 /// <param name="matrixSize">Size of matrix</param>
 /// <returns>true if appropriate tile</returns>
 private static bool CanPlaceEnvDifficulty(IEnvTile envTile, int matrixSize)
 {
     return(!envTile.IsExit & !envTile.HasEnv & !envTile.HasGuard & !envTile.HasSpy &
            !CanPlacePerimeter(envTile, matrixSize) & !CanPlaceMiddle(envTile, matrixSize));
 }
예제 #5
0
 /// <summary>
 /// Returns true if tiles are adjacent to each other
 /// </summary>
 /// <param name="envTileOne"></param>
 /// <param name="envTileTwo"></param>
 /// <returns></returns>
 private static bool TilesAreAdjacent(IEnvTile envTileOne, IEnvTile envTileTwo)
 {
     return(envTileOne == envTileTwo.AdjacentTile[Direction.W]);
 }
예제 #6
0
 /// <summary>
 ///     Checks if tile is in the guard spawn area (1 row if mapScale less than 3, else 3 rows)
 /// </summary>
 /// <param name="envTile">Tile to Check</param>
 /// <param name="mapScale">Size of the map corresponding to scale of plane</param>
 /// <param name="matrixSize">Size of tile matrix</param>
 /// <returns>True if tile is in the guard spawn area </returns>
 private static bool InGuardSpawnAreaY(IEnvTile envTile, int mapScale, int matrixSize)
 {
     return((mapScale >= 1) & (mapScale <= 3) & (envTile.Coords.y == matrixSize - 1) ||
            (mapScale > 3) & (envTile.Coords.y <= matrixSize - 1) & (envTile.Coords.y >= matrixSize - 3));
 }