Beispiel #1
0
        public void RandomizeRoom(char p)
        {
            Room temp;

            Room[] myAdjacentRooms;
            Random r = MyMap.r;
            int    count;

            do
            {
                count           = 0;
                temp            = new Room(MyMap.getRandomRoom());
                myAdjacentRooms = MyCave.getConnectedRooms(temp.getDecimalForm());

                if (MyMap.randomizeCharacterRoom(temp.getIntegerForm(), myAdjacentRooms, p))
                {
                    count++;
                }
            } while (MyMap.isRoomNotOkay(temp, p));

            if (p == 'p')
            {
                MyMap.setPlayerRoom(temp);
            }
            else if (p == 'w')
            {
                MyMap.setWumpusRoom(temp.getIntegerForm());
            }
        }
Beispiel #2
0
        private void RandomizeRoom(char p)
        {
            Room temp;

            Room[] myAdjacentRooms;
            Random r = MyMap.r;
            int    count;

            do
            {
                count           = 0;
                temp            = new Room(MyMap.getRandomRoom());
                myAdjacentRooms = MyCave.loadCaveandRoom(temp.getDecimalForm());

                if (MyMap.randomizeCharacterRoom(temp.getIntegerForm(), myAdjacentRooms, p))
                {
                    count++;
                }
            } while (MyMap.isRoomOkay(temp, p));

            MyMap.setPlayerRoom(temp);
            MyMap.addToExplored(temp);
        }
Beispiel #3
0
        public Room moveInDirection(Direction d)
        {
            Room adjacentRoom = new Room(0, 0);

            if (GameState == Gstate.Menu)
            {
                // The user is in-menu.
                //Console.Out.WriteLine("");
            }
            else if (GameState == Gstate.Game)
            {
                // The user is in-game.
                // Call map to see what room and chamber player is in.
                Room MyRoom = MyMap.getPlayerRoom();
                // Call map to set adjacent rooms
                MyMap.setAdjacentRooms(MyCave.loadCaveandRoom(MyRoom.getDecimalForm()));
                // Call cave to see what room is adjacent, in given direction.
                adjacentRoom = MyMap.getAdjacentRooms()[(int)d]; /*c.getConnectedExteralRoom(1, room);*/;

                // Call map to see if the room in given direction is hazardous.
                //      If is pitted:
                if (adjacentRoom.isRoomPitted())
                {
                    EncounterPit();
                }
                //      If it contains Wumpus:
                if (adjacentRoom == MyMap.getWumpusRoom())
                {
                    EncounterWumpus();
                }
                // Actually move to the room.
                if (adjacentRoom != null)
                {
                    MyMap.setPlayerRoom(adjacentRoom);
                    // Returns player to center:
                    ////MyPlayer.Position = new Vector2(RoomSize.Center.X, RoomSize.Center.Y);
                    // OR, more realistically, the opposite side:
                    MyPlayer.Position = getEntryLocationFrom((Direction)((((int)d + 1) % 4) + 1), MyPlayer.Position);
                }
            }

            return(adjacentRoom);
        }