예제 #1
0
파일: Game1.cs 프로젝트: bburhans/vtank
        private void InputHandler()
        {
            renderer.ActiveScene.CurrentCamera.TranslateRelativly(Vector3.Forward * (Mouse.GetState().ScrollWheelValue - scrollWheelValue) * .1f);
            scrollWheelValue = Mouse.GetState().ScrollWheelValue;
            renderer.ActiveScene.CurrentCamera.LockRotation = true;

            if (Mouse.GetState().RightButton == Microsoft.Xna.Framework.Input.ButtonState.Released)
            {
                WorldMouse.Update();
                mouseReferencePosition.X = WorldMouse.Position.X;
                mouseReferencePosition.Y = WorldMouse.Position.Y;
            }

            if (Mouse.GetState().RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed)
            {
                Vector3 translation;
                WorldMouse.Update();
                translation.X            = mouseReferencePosition.X - WorldMouse.Position.X;
                translation.Y            = mouseReferencePosition.Y - WorldMouse.Position.Y;
                mouseReferencePosition.X = WorldMouse.Position.X;
                mouseReferencePosition.Y = WorldMouse.Position.Y;
                translation.Z            = 0;
                renderer.ActiveScene.CurrentCamera.Translate(translation / 100);
            }

            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.E))
            {
                if (!exploding)
                {
                    exploding = true;
                }
            }
            if (Keyboard.GetState().IsKeyDown(Keys.F))
            {
                exploding = false;
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Right))
            {
                renderer.ActiveScene.Access(mod1).Translate(Vector3.Right);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Left))
            {
                renderer.ActiveScene.Access(mod1).Translate(Vector3.Left);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.Up))
            {
                renderer.ActiveScene.Access(mod1).Translate(Vector3.Up);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Down))
            {
                renderer.ActiveScene.Access(mod1).Translate(Vector3.Down);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.F))
            {
                renderer.ActiveScene.Access(mod).Translate(Vector3.Forward);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.B))
            {
                renderer.ActiveScene.Access(mod).Translate(Vector3.Backward);
            }

            if (Keyboard.GetState().IsKeyDown(Keys.X))
            {
                renderer.ActiveScene.Access(mod).RotateZ(.1f); //No Longer used
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Y))
            {
                renderer.ActiveScene.Access(mod).RotateY(.1f);// No Longer used
            }
            if (Keyboard.GetState().IsKeyDown(Keys.Z))
            {
                renderer.ActiveScene.Access(mod).Aim(renderer.ActiveScene.Access(mod).Right, .1f);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.D))
            {
                renderer.ActiveScene.Access(mod).TranslateRelativly(Vector3.Right);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.S))
            {
                renderer.ActiveScene.Access(mod).TranslateRelativly(Vector3.Down);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.W))
            {
                renderer.ActiveScene.Access(mod).TranslateRelativly(Vector3.Up);
            }
            if (Keyboard.GetState().IsKeyDown(Keys.A))
            {
                renderer.ActiveScene.Access(mod).TranslateRelativly(Vector3.Left);
            }

            //if (Keyboard.GetState().IsKeyDown(Keys.A))
            // {
            //    renderer.ActiveScene.Access3D(tur).Attach(renderer.ActiveScene.Access3D(mod), "Mount");
            //     renderer.ActiveScene.Access3D(tur1).Attach(renderer.ActiveScene.Access3D(mod1), "Mount");
            // }
            if (Keyboard.GetState().IsKeyDown(Keys.T))
            {
                renderer.ActiveScene.Access3D(tur).TrackToCursor();
                renderer.ActiveScene.Access3D(tur1).TrackToCursor();
            }
            if (Keyboard.GetState().IsKeyDown(Keys.P))
            {
                renderer.ActiveScene.Access3D(tur).Animate(animations.GetAnimation("Cannon0_Fire"));
            }
            if (Keyboard.GetState().IsKeyDown(Keys.O))
            {
                renderer.ActiveScene.Access3D(tur).Animate(animations.GetAnimation("Cannon0_Cooldown"));
            }


            if (Keyboard.GetState().IsKeyDown(Keys.L))
            {
                System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog();

                // Default to the directory which contains our content files.
                string assemblyLocation = System.Reflection.Assembly.GetExecutingAssembly().Location;
                string relativePath     = System.IO.Path.Combine(assemblyLocation, "../../../../Content");
                string contentPath      = System.IO.Path.GetFullPath(relativePath);

                fileDialog.InitialDirectory = contentPath;

                fileDialog.Title = "Load Model";

                fileDialog.Filter = "Model Files (*.fbx;*.x)|*.fbx;*.x|" +
                                    "FBX Files (*.fbx)|*.fbx|" +
                                    "X Files (*.x)|*.x|" +
                                    "All Files (*.*)|*.*";

                if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    LoadModel(fileDialog.FileName);
                }
            }
        }
예제 #2
0
 /// <summary>
 /// Calls Update on the active scene
 /// </summary>
 public void Update()
 {
     WorldMouse.Update();
     activeScene.Update();
 }