Esempio n. 1
0
        public void Draw(GameTime time, Camera cam)
        {
            Matrix[] transforms = new Matrix[tripod.Bones.Count];
            tripod.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in tripod.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.Projection = cam.projection;
                    effect.View = cam.view;
                    effect.World = mesh.ParentBone.Transform * Matrix.CreateRotationX(-(float)Math.PI/2) * this.tripodPosition;
                }

                mesh.Draw();
            }

            transforms = new Matrix[armature.Bones.Count];
            armature.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in armature.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.Projection = cam.projection;
                    effect.View = cam.view;
                    effect.World = mesh.ParentBone.Transform * Matrix.CreateRotationX(-(float)Math.PI / 2) * armRotation * this.armPosition;
                }

                mesh.Draw();
            }
        }
 /// <summary>
 /// Create new ModelManager
 /// </summary>
 /// <param name="game">Game to manage models</param>
 public TargetManager(Camera camera, Game game)
     : base(game)
 {
     this.camera = camera;
     this.game = game;
     flatTargets = new List<FlatTarget>();
 }
        public PigeonManager(Camera cam, Game game)
            : base(game)
        {
            pigeons = new List<Pigeon>();
            launcher = new Launcher(game.Content);

            this.game = game;

            pigeonLevel = new PigeonLevel();
            font = game.Content.Load<SpriteFont>(@"Fonts\GameText");

            Enabled = false;
            Visible = false;
        }
Esempio n. 4
0
 /// <summary>
 /// Redraw this model
 /// </summary>
 /// <param name="camera">Object for the user perspective</param>
 public void Draw(Camera camera)
 {
     Matrix[] transforms = new Matrix[model.Bones.Count];
     model.CopyAbsoluteBoneTransformsTo(transforms);
     foreach (ModelMesh mesh in model.Meshes)
     {
         foreach (BasicEffect be in mesh.Effects)
         {
             be.EnableDefaultLighting();
             be.Projection = camera.projection;
             be.View = camera.view;
             be.World = GetWorld() * mesh.ParentBone.Transform;
         }
         mesh.Draw();
     }
 }
Esempio n. 5
0
        public void Draw(GameTime time, Camera cam)
        {
            Matrix[] transforms = new Matrix[model.Bones.Count];
            model.CopyAbsoluteBoneTransformsTo(transforms);

            foreach (ModelMesh mesh in model.Meshes)
            {
                foreach (BasicEffect effect in mesh.Effects)
                {
                    effect.EnableDefaultLighting();
                    effect.Projection = cam.projection;
                    effect.View = cam.view;
                    effect.World = mesh.ParentBone.Transform * Matrix.CreateScale(0.5f) * Matrix.CreateRotationX(-(float)Math.PI / 2) * this.world;
                }

                mesh.Draw();
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Initialize camera
            camera = new Camera(this,
                                new Vector3(0, 0, 100),
                                Vector3.Zero,
                                Vector3.Up);
            Components.Add(camera);

            // initialize models
            shotgunManager = new ShotgunManager(camera, this);
            pigeonManager = new PigeonManager(camera, this);
            targetManager = new TargetManager(camera, this);
            Components.Add(targetManager);
            Components.Add(pigeonManager);
            Components.Add(shotgunManager);

            splashScreen = new SplashScreen(Content);

            // load the first person components
            crosshairTexture = Content.Load<Texture2D>(@"Images\crosshair");
            mainMenu = Content.Load<Texture2D>(@"Images\targetprac");// (@"Images\MainMenu");
            gameOver = Content.Load<Texture2D>(@"Images\GameOver");
            indoorInstructions = Content.Load<Texture2D>(@"Images\IndoorInstructions");
            outdoorInstructions = Content.Load<Texture2D>(@"Images\skeet-inst");
            pigeonGameOver = Content.Load<Texture2D>(@"Images\skeet-score");

            #region OUTDOOR_BACKGROUND
            // initialize the background for the skeet level
            // Initialize left for background
            leftBackgroundVerts = new VertexPositionTexture[4];
            leftBackgroundVerts[0] = new VertexPositionTexture(new Vector3(-150, 100, 150), new Vector2(0, 0));     // top left
            leftBackgroundVerts[2] = new VertexPositionTexture(new Vector3(-150, -6, 150), new Vector2(0, 1));    // bottom left
            leftBackgroundVerts[1] = new VertexPositionTexture(new Vector3(-100, 100, -150), new Vector2(1, 0));      // top right
            leftBackgroundVerts[3] = new VertexPositionTexture(new Vector3(-100, -6, -150), new Vector2(1, 1));     // bottom right

            // Initialize middle background
            middleBackgroundVerts = new VertexPositionTexture[4];
            middleBackgroundVerts[0] = new VertexPositionTexture(new Vector3(-100, 100, -150), new Vector2(0, 0));   // top left
            middleBackgroundVerts[1] = new VertexPositionTexture(new Vector3(100, 100, -150), new Vector2(1, 0));    // top right
            middleBackgroundVerts[2] = new VertexPositionTexture(new Vector3(-100, -6, -150), new Vector2(0, 1));  // bottom left
            middleBackgroundVerts[3] = new VertexPositionTexture(new Vector3(100, -6, -150), new Vector2(1, 1));   // bottom right

            // Initialize right background
            rightBackgroundVerts = new VertexPositionTexture[4];
            rightBackgroundVerts[0] = new VertexPositionTexture(new Vector3(100, 100, -150), new Vector2(0, 0));    // top left
            rightBackgroundVerts[1] = new VertexPositionTexture(new Vector3(150, 100, 150), new Vector2(1, 0));   // top right
            rightBackgroundVerts[2] = new VertexPositionTexture(new Vector3(100, -6, -150), new Vector2(0, 1));    // bottom left
            rightBackgroundVerts[3] = new VertexPositionTexture(new Vector3(150, -6, 150), new Vector2(1, 1));   // bottom right

            // Initialize ground background
            groundBackgroundVerts = new VertexPositionTexture[4];
            groundBackgroundVerts[0] = new VertexPositionTexture(new Vector3(-100, -6, -150), new Vector2(0, 0));   // top left
            groundBackgroundVerts[1] = new VertexPositionTexture(new Vector3(100, -6, -150), new Vector2(1, 0));    // top right
            groundBackgroundVerts[2] = new VertexPositionTexture(new Vector3(-150, -6, 150), new Vector2(0, 1));  // bottom left
            groundBackgroundVerts[3] = new VertexPositionTexture(new Vector3(150, -6, 150), new Vector2(1, 1));   // bottom right

            // Initialize sky background
            skyBackgroundVerts = new VertexPositionTexture[4];
            skyBackgroundVerts[0] = new VertexPositionTexture(new Vector3(-150, 100, 150), new Vector2(0, 0));   // top left
            skyBackgroundVerts[1] = new VertexPositionTexture(new Vector3(150, 100, 150), new Vector2(1, 0));    // top right
            skyBackgroundVerts[2] = new VertexPositionTexture(new Vector3(-100, 100, -150), new Vector2(0, 1));  // bottom left
            skyBackgroundVerts[3] = new VertexPositionTexture(new Vector3(100, 100, -150), new Vector2(1, 1));   // bottom right

            #endregion

            #region INDOOR_BACKGROUND
            // initialize the background for the indoor level

            // left
            rangeLeftVerts = new VertexPositionTexture[4];
            rangeLeftVerts[0] = new VertexPositionTexture(new Vector3(-150, 50, 0), new Vector2(0, 0));     // top left
            rangeLeftVerts[2] = new VertexPositionTexture(new Vector3(-150, -50, 0), new Vector2(0, 1));    // bottom left
            rangeLeftVerts[1] = new VertexPositionTexture(new Vector3(-100, 50, -500), new Vector2(1, 0));      // top right
            rangeLeftVerts[3] = new VertexPositionTexture(new Vector3(-100, -50, -500), new Vector2(1, 1));     // bottom right

            // back
            rangeBackVerts = new VertexPositionTexture[4];
            rangeBackVerts[0] = new VertexPositionTexture(new Vector3(-100, 50, -500), new Vector2(0, 0));   // top left
            rangeBackVerts[1] = new VertexPositionTexture(new Vector3(100, 50, -500), new Vector2(1, 0));    // top right
            rangeBackVerts[2] = new VertexPositionTexture(new Vector3(-100, -50, -500), new Vector2(0, 1));  // bottom left
            rangeBackVerts[3] = new VertexPositionTexture(new Vector3(100, -50, -500), new Vector2(1, 1));   // bottom right

            // right
            rangeRightVerts = new VertexPositionTexture[4];
            rangeRightVerts[0] = new VertexPositionTexture(new Vector3(100, 50, -500), new Vector2(0, 0));    // top left
            rangeRightVerts[1] = new VertexPositionTexture(new Vector3(150, 50, 0), new Vector2(1, 0));   // top right
            rangeRightVerts[2] = new VertexPositionTexture(new Vector3(100, -50, -500), new Vector2(0, 1));    // bottom left
            rangeRightVerts[3] = new VertexPositionTexture(new Vector3(150, -50, 0), new Vector2(1, 1));   // bottom right
            #endregion

            #region GUARD_STAND

            // INITIALIZE STAND FOR FLAT LEVEL

            // front
            standFrontVerts = new VertexPositionTexture[4];
            standFrontVerts[0] = new VertexPositionTexture(new Vector3(-50, -15, -50), new Vector2(0, 0));   // top left
            standFrontVerts[1] = new VertexPositionTexture(new Vector3(50, -15, -50), new Vector2(1, 0));    // top right
            standFrontVerts[2] = new VertexPositionTexture(new Vector3(-50, -50, -50), new Vector2(0, 1));  // bottom left
            standFrontVerts[3] = new VertexPositionTexture(new Vector3(50, -50, -50), new Vector2(1, 1));   // bottom right

            // top
            standTopVerts = new VertexPositionTexture[4];
            standTopVerts[0] = new VertexPositionTexture(new Vector3(-50, -15, -350), new Vector2(0, 0));   // back left
            standTopVerts[1] = new VertexPositionTexture(new Vector3(50, -15, -350), new Vector2(1, 0));    // back right
            standTopVerts[2] = new VertexPositionTexture(new Vector3(-50, -15, -50), new Vector2(0, 1));  // front left
            standTopVerts[3] = new VertexPositionTexture(new Vector3(50, -15, -50), new Vector2(1, 1));   // front right

            // INITIALIZE GUARD FOR FLAT LEVEL
            guardVerts = new VertexPositionTexture[4];
            guardVerts[0] = new VertexPositionTexture(new Vector3(-50, -15, 20), new Vector2(0, 0));   // top left
            guardVerts[1] = new VertexPositionTexture(new Vector3(50, -15, 20), new Vector2(1, 0));    // top right
            guardVerts[2] = new VertexPositionTexture(new Vector3(-50, -50, 20), new Vector2(0, 1));  // bottom left
            guardVerts[3] = new VertexPositionTexture(new Vector3(50, -50, 20), new Vector2(1, 1));   // bottom right
            #endregion

            gameTimer = 0;
            gameStart = 0;
            totalGameTime = 0;

            base.Initialize();
        }
 public ShotgunManager(Camera cam, Game game)
     : base(game)
 {
     this.game = game;
     shotgunWorld = Matrix.CreateRotationZ(-(float)Math.PI / 1.8f) * Matrix.CreateRotationX(-(float)Math.PI / 2) * Matrix.CreateTranslation(0.0f, -0.5f, 47.0f) * Matrix.CreateScale(2.0f) * ((Game1)game).camera.view;
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="camera"></param>
        public void Draw(Camera camera)
        {
            graphicsDevice.SetVertexBuffer(particleVertexBuffer);
            // Only draw if there are live particles
            if (endOfLiveParticlesIndex - endOfDeadParticlesIndex > 0)
            {
                for (int i = endOfDeadParticlesIndex; i < endOfLiveParticlesIndex; ++i)
                {
                    particleEffect.Parameters["WorldViewProjection"].SetValue(
                        camera.view * camera.projection);
                    particleEffect.Parameters["particleColor"].SetValue(
                        vertexColorArray[i].ToVector4());

                    // Draw particles
                    foreach (EffectPass pass in particleEffect.CurrentTechnique.Passes)
                    {
                        pass.Apply();
                        graphicsDevice.DrawUserPrimitives<VertexPositionTexture>(
                        PrimitiveType.TriangleStrip,
                        verts, i * 4, 2);
                    }
                }
            }
        }
Esempio n. 9
0
        public void Draw(Camera camera)
        {
            graphicsDevice.SetVertexBuffer(vertexBuffer);
            effect.Texture = texture;
            effect.TextureEnabled = true;
            effect.View = camera.view;
            effect.Projection = camera.projection;

            // Begin effect and draw for each pass left background
            foreach (EffectPass pass in effect.CurrentTechnique.Passes)
            {
                pass.Apply();
                graphicsDevice.DrawUserPrimitives<VertexPositionTexture>
                                    (PrimitiveType.TriangleStrip, verts, 0, 2);

            }
        }