示例#1
0
文件: MazeGame.cs 项目: Helen1987/edu
 public Maze CreateMaze(MazeFactory mazeFActory)
 {
     Maze maze = mazeFActory.MakeMaze();
     Room r1 = mazeFActory.MakeRoom(1);
     Room r2 = mazeFActory.MakeRoom(2);
     Door theDoor = mazeFActory.MakeDoor(r1, r2);
     maze.AddRoom(r1);
     maze.AddRoom(r2);
     r1.SetSide(Direction.North, mazeFActory.MakeWall());
     r1.SetSide(Direction.East, theDoor);
     r1.SetSide(Direction.South, mazeFActory.MakeWall());
     r1.SetSide(Direction.West, mazeFActory.MakeWall());
     r2.SetSide(Direction.North, mazeFActory.MakeWall());
     r2.SetSide(Direction.East, mazeFActory.MakeWall());
     r2.SetSide(Direction.South, mazeFActory.MakeWall());
     r2.SetSide(Direction.West, theDoor);
     return maze;
 }
示例#2
0
 public static MazeFactory Instance()
 {
     if (currentFactory == null)
     {
         if (Environment.GetEnvironmentVariable("tempV") == "bomb")
         {
             currentFactory = new BombedFactory();
         }
         else if (Environment.GetEnvironmentVariable("tempV") == "ench")
         {
             currentFactory = new EnchantedMazeFactory();
         }
         else
         {
             currentFactory = new MazeFactory();
         }
     }
     return currentFactory;
 }