public void LoadContent(ContentManager content) { skybox.LoadContent(false); skybox.Scale = new Vector3(10.0f, 5.0f, 10.0f); skybox.Rotation = new Vector3(0.0f, MathHelper.ToRadians(180.0f), 0.0f); skybox.Position = new Vector3(700.0f, 0.0f, -1000.0f); playerOne.LoadContent(true); }
protected void GenerateMap(int maxHeight, LightSource light) { int blockCounter = 0; Random random = new Random(); List<int[]> positions = new List<int[]>(); int peepsLeft = 0; int powerupsLeft = 0; for (int d = 0; d < layout.GetLength(0); d++) { for (int w = 0; w < layout.GetLength(1); w++) { if (d == 0 && w == 0) { layout[d, w] = maxHeight; } else { layout[d, w] = random.Next((layout.GetLength(0) - d), maxHeight); } blockCounter += layout[d, w]; int buildingType = random.Next(1, 6); for (int h = 0; h < layout[d, w]; h++) { int[] coords = new int[4] { w, h, d, buildingType }; positions.Add(coords); //this is the top block of the current building if (h == layout[d, w] - 1) { //if this is the first building make it the player start position if (d == 0 && w == 0) { playerStart = new Vector3(w, ((h * blockDimensions.Y) + blockDimensions.Y)+playerSafeZones.Y, d); } //else use the building for a peep or a power up else { bool addedPeep = false; //if running out of room then make sure fill up the 3rd and 4th rows full of peeps if (peepsLeft < peeps.Length && (random.Next(0, 5) == 1 || (d >= layout.GetLength(0) - 3 && d <= layout.GetLength(0) - 2))) { //new peep Person peep = new Person(game, "Models/person", light); peep.LoadContent(true); peep.Position = new Vector3(w * blockDimensions.X, (h * blockDimensions.Y) + blockDimensions.Y, d * blockDimensions.Z); peep.Initialize(); peeps[peepsLeft] = peep; peepsLeft++; addedPeep = true; } //if running out of room then use the last row for power ups if (powerupsLeft < powerups.Length && addedPeep == false && (random.Next(0, 5) == 1 || d >= layout.GetLength(0) - 1)) { Base3DObject powerup = new Base3DObject(game, "Models/powerup_fuel", light); powerup.LoadContent(true); powerup.Position = new Vector3(w * blockDimensions.X, (h * blockDimensions.Y) + blockDimensions.Y, d * blockDimensions.Z); powerup.Initialize(); powerups[powerupsLeft] = powerup; powerupsLeft++; } } } } } } blocks = new Base3DObject[blockCounter]; Vector3 minPlayArea = Vector3.Zero; Vector3 maxPlayArea = Vector3.Zero; for (int c = 0; c < blocks.Length; c++) { int[] coords = (int[])positions[c]; blocks[c] = new Base3DObject(game, "Models/building_"+ coords[3], light); blocks[c].LoadContent(true); blocks[c].Position = CalculatePosition(new Vector3(coords[0], coords[1], coords[2])); blocks[c].Initialize(); //top left if (coords[0] == 0 && coords[1] == 0 && coords[2] == 0) { minPlayArea = blocks[c].Position; } //bottom right if (c == blocks.Length-1) { maxPlayArea = blocks[c].Position; maxPlayArea.Y = playAreaCeiling; } } playArea = new BoundingBox(minPlayArea, maxPlayArea); }
protected void GenerateMap(int maxHeight, LightSource light) { int blockCounter = 0; Random random = new Random(); List <int[]> positions = new List <int[]>(); int peepsLeft = 0; int powerupsLeft = 0; for (int d = 0; d < layout.GetLength(0); d++) { for (int w = 0; w < layout.GetLength(1); w++) { if (d == 0 && w == 0) { layout[d, w] = maxHeight; } else { layout[d, w] = random.Next((layout.GetLength(0) - d), maxHeight); } blockCounter += layout[d, w]; int buildingType = random.Next(1, 6); for (int h = 0; h < layout[d, w]; h++) { int[] coords = new int[4] { w, h, d, buildingType }; positions.Add(coords); //this is the top block of the current building if (h == layout[d, w] - 1) { //if this is the first building make it the player start position if (d == 0 && w == 0) { playerStart = new Vector3(w, ((h * blockDimensions.Y) + blockDimensions.Y) + playerSafeZones.Y, d); } //else use the building for a peep or a power up else { bool addedPeep = false; //if running out of room then make sure fill up the 3rd and 4th rows full of peeps if (peepsLeft < peeps.Length && (random.Next(0, 5) == 1 || (d >= layout.GetLength(0) - 3 && d <= layout.GetLength(0) - 2))) { //new peep Person peep = new Person(game, "Models/person", light); peep.LoadContent(true); peep.Position = new Vector3(w * blockDimensions.X, (h * blockDimensions.Y) + blockDimensions.Y, d * blockDimensions.Z); peep.Initialize(); peeps[peepsLeft] = peep; peepsLeft++; addedPeep = true; } //if running out of room then use the last row for power ups if (powerupsLeft < powerups.Length && addedPeep == false && (random.Next(0, 5) == 1 || d >= layout.GetLength(0) - 1)) { Base3DObject powerup = new Base3DObject(game, "Models/powerup_fuel", light); powerup.LoadContent(true); powerup.Position = new Vector3(w * blockDimensions.X, (h * blockDimensions.Y) + blockDimensions.Y, d * blockDimensions.Z); powerup.Initialize(); powerups[powerupsLeft] = powerup; powerupsLeft++; } } } } } } blocks = new Base3DObject[blockCounter]; Vector3 minPlayArea = Vector3.Zero; Vector3 maxPlayArea = Vector3.Zero; for (int c = 0; c < blocks.Length; c++) { int[] coords = (int[])positions[c]; blocks[c] = new Base3DObject(game, "Models/building_" + coords[3], light); blocks[c].LoadContent(true); blocks[c].Position = CalculatePosition(new Vector3(coords[0], coords[1], coords[2])); blocks[c].Initialize(); //top left if (coords[0] == 0 && coords[1] == 0 && coords[2] == 0) { minPlayArea = blocks[c].Position; } //bottom right if (c == blocks.Length - 1) { maxPlayArea = blocks[c].Position; maxPlayArea.Y = playAreaCeiling; } } playArea = new BoundingBox(minPlayArea, maxPlayArea); }