private void SetupMap() { randomGenerator = new Random(seed); InitRooms(); //generate random ints for player starting pos, superbats, pits, and wumpus List <int> RandomRooms = new List <int>(); while (RandomRooms.Count < NUMBATS + NUMPITS + 2) { int rand = randomGenerator.Next(1, 20); if (!RandomRooms.Contains(rand)) { RandomRooms.Add(rand); } } player = new Player(RandomRooms[0]); wump = new Wumpus(RandomRooms[1]); Bats = new int[NUMBATS] { RandomRooms[2], RandomRooms[3] }; Pits = new int[NUMPITS] { RandomRooms[4], RandomRooms[5] }; }
public Map(Game game, int seed) { this.game = game; // Seeding allows us to play the same map random = new Random(seed); // Create list of rooms and their adjacent rooms // Start at index 1 to make life easy Rooms = new int[21][] { new int [] { -1, -1, -1 }, // 0 not an actual room new int [] { 2, 5, 8 }, new int [] { 1, 3, 10 }, new int [] { 2, 4, 12 }, new int [] { 3, 5, 14 }, new int [] { 1, 4, 6 }, new int [] { 5, 7, 15 }, new int [] { 6, 8, 17 }, new int [] { 1, 7, 9 }, new int [] { 8, 10, 18 }, new int [] { 2, 9, 11 }, new int [] { 10, 12, 19 }, new int [] { 3, 11, 13 }, new int [] { 12, 14, 20 }, new int [] { 4, 13, 15 }, new int [] { 6, 14, 16 }, new int [] { 15, 17, 20 }, new int [] { 7, 16, 18 }, new int [] { 9, 17, 19 }, new int [] { 11, 18, 20 }, new int [] { 13, 16, 19 } }; Entities = new List <Entity>(); // Generate a list of random rooms by shuffling // a list of numbers from 1 to number of rooms // We skip room 1 because that's for the Player var randomRooms = new int[19]; for (int k = 2; k <= 20; k++) { randomRooms[k - 2] = k; } randomRooms = randomRooms.OrderBy(x => random.Next()).ToArray(); // Create all the entities reading off the random positions one by one // This makes sure nothing is initially in the same room int randCount = 0; for (int k = 0; k < NumBats; k++) { Entities.Add(new Bat(this, randomRooms[randCount++])); } for (int k = 0; k < NumPits; k++) { Entities.Add(new Pit(this, randomRooms[randCount++])); } // Wumpus and Player are special, so they're not in the entity list Wumpus = new Wumpus(this, randomRooms[randCount++]); Player = new Player(this, 1); arrowPath = new List <int>(); lastFiredPath = new List <int>(); playing = true; currentState = GameState.INIT; currentKeyboardState = Keyboard.GetState(); camera = new Camera(game, Player.PositionCoords + cameraPositionOffset, Player.PositionCoords, Vector3.UnitY); facingRoom = 8; }