Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="adjRoom"></param>
        /// <param name="d"></param>
        /// <returns>True if batted.</returns>
        public bool moveTo(Room adjRoom, Direction d)
        {
            MoveWumpus(false);
            //adjacentRoom.LoadContent(theContentManager);
            // Call map to see if the room in given direction is hazardous.
            //roomType AdjacentRoomType = MyMap.getPlayerInRoomWith(MyRoom);
            //MyMap.GiveWarnings(chamber);

            //updateGold(adjRoom);

            MyPlayer.setTurns(MyPlayer.getTurns() + 1);
            //      If is pitted:
            if (isRoomPitted(adjRoom))
            {
                EncounterPit();
            }
            //      If it contains Wumpus:
            if (adjRoom.Equals(new Room(MyMap.getWumpusRoom())))
            {
                EncounterWumpus();
            }
            //      If is batted (=D)
            if (isRoomBatted(adjRoom))
            {
                adjRoom = EncounterBat();
            }
            // Actually move to the room.
            MyMap.setPlayerRoom(adjRoom);
            MyMap.moves++;
            MyPlayer.setTurns(MyMap.moves);
            // Move Wumpus around
            // 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(isRoomBatted(adjRoom));
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        public void MoveWumpus(bool trivia)
        {
            // Get stuff from Map
            Room   WumpusRoom = new Room(MyMap.getWumpusRoom());
            Random myR        = MyMap.r;
            Room   NewRoom    = WumpusRoom;

            // Get adj rooms
            Room[] wAdjRooms = MyCave.loadCaveandRoom(WumpusRoom.getDecimalForm());
            // obtain number of rooms to move per turn from Wumpus
            // CHECK TRIVIA
            int n = MyWumpus.Move(false);

            // loop
            for (int i = 0; i < n; i++)
            {
                // (get all adjacent rooms
                wAdjRooms = MyCave.loadCaveandRoom(WumpusRoom.getDecimalForm());
                // Eliminate all chambers from wAdjRooms
                for (int k = 1; k < wAdjRooms.Length; k++)
                {
                    if (wAdjRooms[k] != null)
                    {
                        if (i != n - 1)
                        {
                            if (wAdjRooms[k].RoomNumber == 0)
                            {
                                wAdjRooms[k] = null;
                            }
                        }
                    }
                }
                // loop: choose randomly one of the rooms and check to make sure it is valid
                int j;
                do
                {
                    j       = myR.Next(wAdjRooms.Length - 1) + 1;
                    NewRoom = wAdjRooms[j];
                } while (MyMap.isRoomNotOkay(NewRoom, 'w'));
                // set wumpus room to the new room)
                MyMap.setWumpusRoom(NewRoom.getIntegerForm());
            }
        }