// Non-flexible implemantation, replaced. //public static Maze CreateMaze() //{ // Maze maze = new Maze(); // Room room1 = new Room(1); // Room room2 = new Room(2); // Door door = new Door(room1, room2); // maze.AddRoom(room1); // maze.AddRoom(room2); // room1.SetSide(Direction.North, new Wall()); // room1.SetSide(Direction.East, door); // room1.SetSide(Direction.South, new Wall()); // room1.SetSide(Direction.West, new Wall()); // room2.SetSide(Direction.North, new Wall()); // room2.SetSide(Direction.East, new Wall()); // room2.SetSide(Direction.South, new Wall()); // room2.SetSide(Direction.West, door); // return maze; //} public static Maze CreateMaze(MazeFactory factory) { Maze maze = factory.MakeMaze(); Room room1 = factory.MakeRoom(1); Room room2 = factory.MakeRoom(2); Door door = factory.MakeDoor(room1, room2); maze.AddRoom(room1); maze.AddRoom(room2); ConnectFromEastToWest(room1, room2, door); return(maze); }
public Maze CreateMaze(MazeFactory factory) { Maze aMaze = factory.MakeMaze(); Room r1 = factory.MakeRoom(1); Room r2 = factory.MakeRoom(2); Door theDoor = factory.MakeDoor(r1,r2); aMaze.AddRoom(r1); aMaze.AddRoom(r2); r1.SetSide(Direction.North, factory.MakeWall()); r1.SetSide(Direction.East, theDoor); r1.SetSide(Direction.South, factory.MakeWall()); r1.SetSide(Direction.West, factory.MakeWall()); r2.SetSide(Direction.North, factory.MakeWall()); r2.SetSide(Direction.East, factory.MakeWall()); r2.SetSide(Direction.South, factory.MakeWall()); r2.SetSide(Direction.West, theDoor); return aMaze; }
public Maze CreateMaze(MazeFactory factory) { Maze aMaze = factory.MakeMaze(); Room r1 = factory.MakeRoom(1); Room r2 = factory.MakeRoom(2); Door theDoor = factory.MakeDoor(r1, r2); aMaze.AddRoom(r1); aMaze.AddRoom(r2); r1.SetSide(Direction.North, factory.MakeWall()); r1.SetSide(Direction.East, theDoor); r1.SetSide(Direction.South, factory.MakeWall()); r1.SetSide(Direction.West, factory.MakeWall()); r2.SetSide(Direction.North, factory.MakeWall()); r2.SetSide(Direction.East, factory.MakeWall()); r2.SetSide(Direction.South, factory.MakeWall()); r2.SetSide(Direction.West, theDoor); return(aMaze); }
// 使用工厂来初始化room和外墙 public void InitialRooms(MazeFactory factory) { for (int x = 0; x < _gameSizeH; x++) { for (int y = 0; y < _gameSizeW; y++) { Room newRoom = factory.MakeRoom(new Location(x, y)); if (x == 0) { new Wall(newRoom, Direction.North); } else { Room northRoom = GetRoom(x - 1, y); northRoom.SetSite(Direction.South, newRoom); newRoom.SetSite(Direction.North, northRoom); if (x == _gameSizeH - 1) { new Wall(newRoom, Direction.South); } } if (y == 0) { new Wall(newRoom, Direction.West); } else { Room westRoom = GetRoom(x, y - 1); westRoom.SetSite(Direction.East, newRoom); newRoom.SetSite(Direction.West, westRoom); if (y == _gameSizeW - 1) { new Wall(newRoom, Direction.East); } } _rooms[x * _gameSizeW + y] = newRoom; } } }