static void Main(string[] args)
        {
            //change factory, change kind of maze.
            MazeFactory mazeFactory = new MazeFactory();
            MazeGame    game        = new MazeGame();
            Maze        maze        = game.CreateMase(mazeFactory);

            maze.RoomNo(1).Enter();

            EnchantedMazeFactory enchante = new EnchantedMazeFactory();
            Maze enchantedMaze            = game.CreateMase(enchante);

            enchantedMaze.RoomNo(1).Enter();
        }
Beispiel #2
0
        static void Main(string[] args)
        {
            // Regular factory
            var mazeFactory = new MazeFactory();
            var maze        = mazeFactory.CreateMaze();

            // Factory methods
            var factoryWithFactoryMethods = new BombedMazeGameFactoryMethod();
            var bombedMaze = factoryWithFactoryMethods.CreateMaze();

            // Prototype factory
            var prototypeFactory = new MazePrototypeFactory(new Maze(), new BombedWall(), new Door(), new RoomWithBomb(1));
            var wiredMaze        = prototypeFactory.CreateMaze();
        }
        public Maze CreateMase(MazeFactory mazeFactory)
        {
            Maze aMaze   = mazeFactory.MakeMaze();
            Room r1      = mazeFactory.MakeRoom(1);
            Room r2      = mazeFactory.MakeRoom(2);
            Door theDoor = mazeFactory.MakeDoor(r1, r2);

            aMaze.AddRoom(r1);
            aMaze.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(aMaze);
        }
Beispiel #4
0
        static Maze CreateMaze(MazeFactory factory)
        {
            var maze  = factory.MakeMaze();
            var room1 = factory.MakeRoom(1);
            var room2 = factory.MakeRoom(2);

            var door = factory.MakeDoor(room1, room2);


            maze.AddRoom(room1);
            maze.AddRoom(room2);

            room1.SetSide(Direction.North, factory.MakeWall());
            room1.SetSide(Direction.East, door);
            room1.SetSide(Direction.South, factory.MakeWall());
            room1.SetSide(Direction.West, factory.MakeWall());

            room2.SetSide(Direction.North, factory.MakeWall());
            room2.SetSide(Direction.East, factory.MakeWall());
            room2.SetSide(Direction.South, factory.MakeWall());
            room2.SetSide(Direction.West, door);

            return(maze);
        }