Пример #1
0
 public void GenerateTreasures()
 {
     for (int i = 0; i < InputHandler.getRandom(5, 100); i++)
     {
         treasures.Add(new Treasure("Treasure", TREASURE.COIN, InputHandler.getRandom(1, roomWidth - 1), InputHandler.getRandom(1, roomHeight - 1)));
     }
 }
Пример #2
0
        //will generate a path of passages from one room to the next, this means
        //all rooms will be reachable
        private void GeneratePassage(int i, Direction prevDir)
        {
            int otherRoom = i + 1;

            if (otherRoom >= rooms.Count)
            {
                otherRoom = 0;
            }

            Direction r1 = prevDir;

            while (r1 == prevDir)
            {
                r1 = (Direction)InputHandler.getRandom(0, 4);
            }

            Direction r2 = (Direction)InputHandler.getRandom(0, 4);

            if (rooms[otherRoom].addPassage(r2, i, r1))
            {
                rooms[i].addPassage(r1, otherRoom, r2);
            }

            if (otherRoom != 0)
            {
                GeneratePassage(otherRoom, r2);
            }
        }
Пример #3
0
        //This will generate extra random passages after a straight path has been added
        private void GenerateExtraPassages()
        {
            for (int i = 0; i < rooms.Count; i++)
            {
                for (int x = 0; x < 2; x++)
                {
                    int otherRoom = i;
                    while (otherRoom == i)
                    {
                        otherRoom = InputHandler.getRandom(0, rooms.Count);
                    }

                    Direction r1 = (Direction)InputHandler.getRandom(0, 4);
                    Direction r2 = (Direction)InputHandler.getRandom(0, 4);

                    if (!rooms[i].doesPassageExist(r1))
                    {
                        if (rooms[otherRoom].addPassage(r2, i, r1))
                        {
                            rooms[i].addPassage(r1, otherRoom, r2);
                        }
                    }
                }
            }
        }
Пример #4
0
        public void GenerateEnemies()
        {
            int num = InputHandler.getRandom(0, 4);

            int x, y;

            for (int i = 0; i < num; i++)
            {
                x = InputHandler.getRandom(1, roomWidth - 1);
                y = InputHandler.getRandom(1, roomHeight - 1);
                enemies.Add(new Enemy($"ENEMY{i}", ENEMY.ENEMY1, x, y));
            }
        }
Пример #5
0
        public RoomViewer()
        {
            floor   = ContentLoader.LoadTexture("Sprites/Room1/Floor.png");
            wall    = ContentLoader.LoadTexture("Sprites/Room1/Wall.png");
            passage = ContentLoader.LoadTexture("Sprites/Room1/Passage.png");

            UIMoney = ContentLoader.LoadTexture("Sprites/Treasures/UI.png");

            maze = new Maze(ConfigSettings.roomCount);
            maze.GenerateTreasures();
            maze.GenerateEnemies();
            room = maze.getRoom(InputHandler.getRandom(0, ConfigSettings.roomCount - 1));
            Console.WriteLine(room.roomID);

            p1 = new Player();
            p1.setPos(room.getEntrancePos(Direction.EAST));

            cam = new Camera(p1.getCameraTransform(zoom), zoom);
        }
Пример #6
0
        public Maze(int roomCount)
        {
            rooms = new List <Room>();


            for (int i = 0; i < roomCount; i++)
            {
                rooms.Add(
                    new Room(
                        InputHandler.getRandom(ConfigSettings.minRoomHeight, ConfigSettings.maxRoomHeight),
                        InputHandler.getRandom(ConfigSettings.minRoomWidth, ConfigSettings.maxRoomWidth))
                    );
            }

            GeneratePassage(0, (Direction)0);

            Console.WriteLine(AddExit(InputHandler.getRandom(0, rooms.Count - 1)) ? "exit added" : "exit not added");

            GenerateExtraPassages();
        }