Esempio n. 1
0
        /// <summary>
        ///     Moves the player relatively to a new room if this room connects to that room.
        /// </summary>
        /// <param name="dir"></param>
        public bool MovePlayer(int dir)
        {
            Room currentRoom = Cave.GetRoom(PlayerRoom);

            //if the room in the direction exists
            if (currentRoom.AdjacentRooms[dir] != -1)
            {
                //set our current room to that room
                PlayerRoom = Cave.GetRoom(currentRoom.AdjacentRooms[dir]).RoomID;

                //Wumpus has to move after the player does
                Wumpus.Move();

                // Update player tracking
                ProcessPlayerMove();

                return(true);
            }

            Wumpus.Move();
            return(false);
        }
Esempio n. 2
0
 /// <summary>
 /// Returns the neighbor rooms of a room.
 /// </summary>
 /// <param name="center"></param>
 /// <param name="cave"></param>
 /// <returns></returns>
 private static IEnumerable <AStarNode> getNeighbors(AStarNode center, Cave cave)
 {
     return(center.node.AdjacentRooms.Where(i => i != -1).Select(roomIndex => new AStarNode(cave.GetRoom(roomIndex), center)));
 }