/// <summary> /// Constructor /// </summary> public PrisonGame() { // XNA startup graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; // Create objects for the parts of the ship for(int i=1; i<=6; i++) { phibesModel.Add(new PrisonModel(this, i)); } // Create a player object player = new Player(this); // Some basic setup for the display window this.IsMouseVisible = true; this.Window.AllowUserResizing = true; this.graphics.PreferredBackBufferWidth = 1024; this.graphics.PreferredBackBufferHeight = 728; // Basic camera settings camera = new Camera(graphics); camera.FieldOfView = MathHelper.ToRadians(60); camera.Eye = new Vector3(800, 180, 1053); camera.Center = new Vector3(275, 90, 1053); lineDraw = new PSLineDraw(this, Camera); this.Components.Add(lineDraw); }
public Player(PrisonGame game, Camera inCamera) { this.game = game; this.camera = inCamera; dalek = new AnimatedModel(game, "dalek"); SetPlayerTransform(); playerCollision = new BoundingCylinder(game, location); }
private void DrawModel(GraphicsDeviceManager graphics, Model model, Matrix world, GameTime gameTime, Camera inCamera) { Matrix[] transforms = new Matrix[model.Bones.Count]; model.CopyAbsoluteBoneTransformsTo(transforms); foreach (ModelMesh mesh in model.Meshes) { foreach (BasicEffect effect in mesh.Effects) { effect.World = transforms[mesh.ParentBone.Index] * world; effect.View = inCamera.View; effect.Projection = inCamera.Projection; } mesh.Draw(); } }
/// <summary> /// overriden from DrawableGameComponent, Draw will use ParticleSampleGame's /// sprite batch to render all of the active particles. /// </summary> public void Draw(GraphicsDevice device, Camera camera) { effect.Parameters["View"].SetValue(camera.View); effect.Parameters["Projection"].SetValue(camera.Projection); effect.Parameters["Texture"].SetValue(texture); Matrix invView = camera.View; invView.Translation = Vector3.Zero; invView = Matrix.Invert(invView); BlendState blendState = new BlendState(); blendState.ColorBlendFunction = BlendFunction.Add; blendState.ColorSourceBlend = Blend.SourceAlpha; if (blended) { // Smoke is often alpha blended blendState.ColorDestinationBlend = Blend.InverseSourceAlpha; } else { // Explosions are often additive blendState.ColorDestinationBlend = Blend.One; } device.BlendState = blendState; device.DepthStencilState = DepthStencilState.DepthRead; foreach (Particle3d p in liveParticles) { // Life time as a value from 0 to 1 float normalizedLifetime = p.Age / p.Lifetime; float alpha = 4 * normalizedLifetime * (1 - normalizedLifetime); // make particles grow as they age. they'll start at 75% of their size, // and increase to 100% once they're finished. float scale = p.Scale * (.75f + .25f * normalizedLifetime); Matrix world = Matrix.CreateScale(scale) * Matrix.CreateRotationZ(p.Orientation) * invView * Matrix.CreateTranslation(p.Position); effect.Parameters["World"].SetValue(world); effect.Parameters["Alpha"].SetValue(alpha); foreach (EffectPass pass in effect.CurrentTechnique.Passes) { pass.Apply(); device.DrawUserIndexedPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, vertices, 0, vertices.Length, indices, 0, indices.Length / 3); } } device.BlendState = BlendState.Opaque; device.DepthStencilState = DepthStencilState.Default; }
/// <summary> /// This function is called to draw the player. /// </summary> /// <param name="graphics"></param> /// <param name="gameTime"></param> public void Draw(GraphicsDeviceManager graphics, GameTime gameTime, Camera inCamera) { Matrix transform = Matrix.CreateRotationY(horizontalOrientation); transform.Translation = location; dalek.Draw(graphics, gameTime, transform, inCamera.View, inCamera.Projection); }
public void Draw(GraphicsDeviceManager graphics, GameTime gameTime, Camera inCamera) { DrawModel(graphics, model, Matrix.CreateTranslation(position), gameTime, inCamera); }
public void DrawGame(GameTime gameTime, Camera inCamera) { GraphicsDevice.BlendState = BlendState.Opaque; GraphicsDevice.DepthStencilState = DepthStencilState.Default; ground.Draw(graphics, gameTime, inCamera); player.Draw(graphics, gameTime, inCamera); player2.Draw(graphics, gameTime, inCamera); smokePlume.Draw(GraphicsDevice, inCamera); skybox.Draw(graphics, gameTime, inCamera); GraphicsDevice.BlendState = BlendState.AlphaBlend; GraphicsDevice.BlendState = BlendState.Opaque; base.Draw(gameTime); //Show score and pies in bazooka spriteBatch.Begin(); spriteBatch.DrawString(UIFont, "Pies: " + (10 - totalPiesFired).ToString(), new Vector2(10, 10), Color.White); spriteBatch.DrawString(UIFont, "Score: " + score.ToString(), new Vector2(10, 25), Color.White); spriteBatch.End(); GraphicsDevice.DepthStencilState = DepthStencilState.Default; }
/// <summary> /// Constructor /// </summary> public PrisonGame() { // XNA startup graphics = new GraphicsDeviceManager(this); Content.RootDirectory = "Content"; skybox = new Skybox(this); // Camera settings camera1 = new Camera(graphics); camera1.Eye = new Vector3(800, 180, 1053); camera1.Center = new Vector3(275, 90, 1053); camera1.FieldOfView = MathHelper.ToRadians(42); camera2 = new Camera(graphics); camera1.Eye = new Vector3(800, 180, 1053); camera1.Center = new Vector3(275, 90, 1053); camera1.FieldOfView = MathHelper.ToRadians(42); ground = new Ground(this); // Create a player object player = new Player(this, camera1); player2.Location = new Vector3(0, 0, 0); player2 = new Player(this, camera2); player2.Location = new Vector3(0,0, 100); //Particle system smokePlume = new SmokeParticleSystem3d(9); // Some basic setup for the display window this.IsMouseVisible = true; //this.Window.AllowUserResizing = true; this.graphics.PreferredBackBufferWidth = 1024; this.graphics.PreferredBackBufferHeight = 768; lineDraw = new PSLineDraw(this, Camera); this.Components.Add(lineDraw); }
/// <summary> /// Constructor. /// </summary> /// <param name="game">XNA game class</param> /// <param name="camera">Camera class used by the game. Indicates /// where the camera is in the 3D space the line is drawn in.</param> public PSLineDraw(Game game, Camera camera) : base(game) { this.camera = camera; this.DrawOrder = 1000; // Should be last... }