public static Tile FullTile(int row, int col) { Tile t = new Tile(row, col); t.LeftWall = WallState.Sealed; t.RightWall = WallState.Sealed; t.UpWall = WallState.Sealed; t.DownWall = WallState.Sealed; return t; }
public static Tile RandomTile(int row, int col, Random random) { Tile t = new Tile(row, col); int rand = random.Next(0, 2); t.LeftWall = rand == 0 ? WallState.Sealed : WallState.None; rand = random.Next(0, 2); t.RightWall = rand == 0 ? WallState.Sealed : WallState.None; rand = random.Next(0, 2); t.UpWall = rand == 0 ? WallState.Sealed : WallState.None; rand = random.Next(0, 2); t.DownWall = rand == 0 ? WallState.Sealed : WallState.None; return t; }
public static Tile[,] GenerateMaze(int row, int col, int seed) { Random rng = new Random(seed); Tile[,] tiles = new Tile[row, col]; for (int r = 0; r < row; r++) { for (int c = 0; c < col; c++) { if (r < 1 || r >= (row - 1) || c < 1 || c >= (col - 1)) { tiles[r, c] = ExitTile(r, c); } else { tiles[r, c] = RandomTile(r, c, rng); } } } return tiles; }
public static WallState GetBackWallOf(Tile tile, Direction facingDirection) { if (facingDirection == Direction.Up) { return tile.DownWall; } else if (facingDirection == Direction.Down) { return tile.UpWall; } else if (facingDirection == Direction.Left) { return tile.RightWall; } else if (facingDirection == Direction.Right) { return tile.LeftWall; } else // None { return WallState.None; } }
public void PlaceTile(Tile NextTile, Grid g) { NextTile.CurrentGrid = g; Tiles[g.Row, g.Col] = NextTile; }
public Maze(Tile[,] tiles) { this.Tiles = tiles; Humans = new List<Unit>(); rng = new Random(); }
public static Tile ExitTile(int row, int col) { Tile t = new Tile(row, col); t.IsExit = true; return t; }
public void RandomNext() { NextTile = MazeGenerator.RandomTile(0,0,new Random()); NextTile.CurrentGrid = new Grid(-1, -1); }
public static void GetBackWallPair(Tile currTile, Tile targetTile, Direction facingDirection, out WallState currWall, out WallState targetWall) { currWall = GetBackWallOf(currTile, facingDirection); targetWall = GetFrontWallOf(targetTile, facingDirection); }