public MovingObject(Game game, String assetName, LightSource _light) : base(game, assetName, _light) { velocity = Vector3.Zero; acceleration = Vector3.Zero; accelerationBit = 0.25f; playArea = new BoundingBox(); hasPlayArea = false; }
public Player(Game game, String assetName, LightSource light) : base(game, assetName, light) { thrust = gameOptions.Thrust; gravity = gameOptions.Gravity; particleLibrary = null; deathTimer = 50; lifeCounter = 1; }
public Map(Game _game, Vector3 coordinates, LightSource light, int totalPeeps) { game = _game; playAreaCeiling = (coordinates.Y * blockDimensions.Y) * 1.4f; layout = new int[(int)coordinates.Z, (int)coordinates.X]; playerStart = Vector3.Zero; peeps = new Person[totalPeeps]; powerups = new Base3DObject[2]; GenerateMap((int)coordinates.Y, light); }
public Scene(Game game) { Camera = new GameCamera(50.0f, new Vector3[] { new Vector3(-200.0f, -1050.0f, -520.0f), new Vector3(1350.0f, -150.0f, -430.0f) }, new Vector3[] { new Vector3(-320.0f, 430.0f, 570.0f), new Vector3(1230.0f, 1230.0f, 1180.0f) }, game.GraphicsDevice.Viewport.AspectRatio, 10.0f, 10000.0f, new Vector3(-320.0f, 680.0f, 1180.0f), new Vector3(1350.0f, -400.0f, -520.0f)); Light = new LightSource(new Vector3(-0.3f, 500.0f, 0.5f), Camera); ShadowRenderTarget = new RenderTarget2D(game.GraphicsDevice, 2048, 2048, false, SurfaceFormat.Single, DepthFormat.Depth24); }
public Person(Game game, String assetName, LightSource _light) : base(game, assetName, _light) { meshWorldMatrices = new Matrix[6]; meshWorldMatrices[0] = Matrix.CreateTranslation(new Vector3(0, 0, 0)); meshWorldMatrices[1] = Matrix.CreateTranslation(new Vector3(0, 0, 0)); meshWorldMatrices[2] = Matrix.CreateTranslation(new Vector3(0, 0, 0)); meshWorldMatrices[3] = Matrix.CreateTranslation(new Vector3(0, 0, 0)); //left arm meshWorldMatrices[4] = Matrix.CreateTranslation(new Vector3(0, 0, 0)); //right arm meshWorldMatrices[5] = Matrix.CreateTranslation(new Vector3(0, 0, 0)); }
public Base3DObject(Game game, String modelAssetName, LightSource _light) : base(game) { Position = Vector3.Zero; Scale = Vector3.One; Rotation = Vector3.Zero; modelName = modelAssetName; light = _light; firstPassCollision = false; Active = true; elementsWorldMatrix = new Matrix[0]; hasBounds = false; }
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); }