Beispiel #1
0
 /*
 // Returns random Tile location from anywhere in Board.
 public Tile RandomLocation()
 {
     Room randomRoom = board.rooms[random.Next(board.rooms.Count)];
     Tile randomTile = randomRoom.tiles[random.Next(randomRoom.tiles.Count)];
     return randomTile;
 }
 */
 // Returns random Tile location from anywhere in specified Room.
 public Tile RandomLocation(Room room)
 {
     Tile randomTile = room.tiles[random.Next(room.tiles.Count)];
     return randomTile;
 }
Beispiel #2
0
        public Tile AssignLocation(Room locationRoom)
        {
            // Only assigns location if it is not occupied already.

                Tile bufferLocation = RandomLocation(locationRoom);
                Boolean tileAvailable = true;

                    // Check other locations and reassign bufferLocation until it is an available location.
                    do{
                        // Assume location is initially free.
                        tileAvailable = true;
                        foreach (Character character in locationRoom.occupants)
                        {
                            if (bufferLocation == character.location)
                            {
                                // If location not free, chooose another and check everybody again.
                                bufferLocation = RandomLocation(locationRoom);
                                tileAvailable = false;
                                break;
                            }
                        }
                    } while (!tileAvailable);

                    // bufferLocation is available, so assign it.
                    return bufferLocation;
        }