Exemplo n.º 1
0
        /// <summary>
        /// Uses an Inspector to display update and display information to player.
        /// All user input that affects rendering of the stage is processed either
        /// from the gamepad or keyboard.
        /// See Player.Update(...) for handling of user events that affect the player.
        /// The current camera's place is updated after all other GameComponents have
        /// been updated.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // set info pane values
            time       = gameTime.TotalGameTime;
            fpsSecond += gameTime.ElapsedGameTime.TotalSeconds;
            updates++;
            if (fpsSecond >= 1.0)
            {
                inspector.setInfo(10,
                                  String.Format("{0} camera    Game time {1:D2}::{2:D2}::{3:D2}    {4:D} Updates/Seconds {5:D} Draws/Seconds",
                                                currentCamera.Name, time.Hours, time.Minutes, time.Seconds, updates.ToString(), draws.ToString()));
                draws     = updates = 0;
                fpsSecond = 0.0;
                inspector.setInfo(11, agentLocation(player));
                inspector.setInfo(12, agentLocation(npAgent));
                inspector.setInfo(13, string.Format("Flocking Propability: {0}      Number of Dogs: {1}",
                                                    pack.Probability, pack.NumberOfDogs));
                // inspector lines 13 and 14 can be used to describe player and npAgent's status
                inspector.setMatrices("player", "npAgent", player.AgentObject.Orientation, npAgent.AgentObject.Orientation);
            }
            // Process user keyboard events that relate to the render state of the the stage
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            else if (keyboardState.IsKeyDown(Keys.B) && !oldKeyboardState.IsKeyDown(Keys.B))
            {
                DrawBoundingSpheres = !DrawBoundingSpheres;
            }
            else if (keyboardState.IsKeyDown(Keys.C) && !oldKeyboardState.IsKeyDown(Keys.C))
            {
                setCamera(1);
            }
            else if (keyboardState.IsKeyDown(Keys.X) && !oldKeyboardState.IsKeyDown(Keys.X))
            {
                setCamera(-1);
            }
            else if (keyboardState.IsKeyDown(Keys.F) && !oldKeyboardState.IsKeyDown(Keys.F))
            {
                Fog = !Fog;
            }
            // key event handlers needed for Inspector
            // set help display on
            else if (keyboardState.IsKeyDown(Keys.H) && !oldKeyboardState.IsKeyDown(Keys.H))
            {
                inspector.ShowHelp     = !inspector.ShowHelp;
                inspector.ShowMatrices = false;
            }
            // set info display on
            else if (keyboardState.IsKeyDown(Keys.I) && !oldKeyboardState.IsKeyDown(Keys.I))
            {
                inspector.showInfo();
            }
            // set miscellaneous display on
            else if (keyboardState.IsKeyDown(Keys.M) && !oldKeyboardState.IsKeyDown(Keys.M))
            {
                inspector.ShowMatrices = !inspector.ShowMatrices;
                inspector.ShowHelp     = false;
            }
            // toggle update speed between FixedStep and ! FixedStep
            else if (keyboardState.IsKeyDown(Keys.T) && !oldKeyboardState.IsKeyDown(Keys.T))
            {
                FixedStepRendering = !FixedStepRendering;
            }
            else if (keyboardState.IsKeyDown(Keys.Y) && !oldKeyboardState.IsKeyDown(Keys.Y))
            {
                YonFlag = !YonFlag; // toggle Yon clipping value.
            }
            //Adding a boolian to turn off and on lerping
            else if (keyboardState.IsKeyDown(Keys.L) && !oldKeyboardState.IsKeyDown(Keys.L))
            {
                if (lerping == false)
                {
                    lerping = true;
                }

                else if (lerping == true)
                {
                    lerping = false;
                }
            }
            else if (keyboardState.IsKeyDown(Keys.N) && !oldKeyboardState.IsKeyDown(Keys.N))
            {
            }
            else if (keyboardState.IsKeyDown(Keys.P) && !oldKeyboardState.IsKeyDown(Keys.P))
            {
                pack.Level = pack.Level + 1;
            }

            oldKeyboardState = keyboardState; // Update saved state.
            base.Update(gameTime);            // update all GameComponents and DrawableGameComponents
            currentCamera.updateViewMatrix();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Uses an Inspector to display update and display information to player.
        /// All user input that affects rendering of the stage is processed either
        /// from the gamepad or keyboard.
        /// See Player.Update(...) for handling of user events that affect the player.
        /// The current camera's place is updated after all other GameComponents have
        /// been updated.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // set info pane values
            time       = gameTime.TotalGameTime;
            fpsSecond += gameTime.ElapsedGameTime.TotalSeconds;
            updates++;
            if (fpsSecond >= 1.0)
            {
                inspector.setInfo(10,
                                  String.Format("{0} camera    Game time {1:D2}::{2:D2}::{3:D2}    {4:D} Updates/Seconds {5:D} Draws/Seconds",
                                                currentCamera.Name, time.Hours, time.Minutes, time.Seconds, updates.ToString(), draws.ToString()));
                draws     = updates = 0;
                fpsSecond = 0.0;
                inspector.setInfo(11, agentLocation(player));
                inspector.setInfo(12, agentLocation(npAgent));
                // inspector lines 13 and 14 can be used to describe player and npAgent's status
                inspector.setMatrices("player", "npAgent", player.AgentObject.Orientation, npAgent.AgentObject.Orientation);
//				Console.WriteLine ("test");
                inspector.setScoreBoard(npAgent.Score, player.Score, Winner);         // Update the treasure score board in inspector - by David Kopp
            }
            // Process user keyboard events that relate to the render state of the the stage (The inspector key presses will always work properly if you go from the help screen first) (David Kopp)
            KeyboardState keyboardState = Keyboard.GetState();

            if (keyboardState.IsKeyDown(Keys.Escape))
            {
                Exit();
            }
            else if (keyboardState.IsKeyDown(Keys.B) && !oldKeyboardState.IsKeyDown(Keys.B))
            {
                DrawBoundingSpheres = !DrawBoundingSpheres;
            }
            else if (keyboardState.IsKeyDown(Keys.C) && !oldKeyboardState.IsKeyDown(Keys.C))
            {
                setCamera(1);
            }
            else if (keyboardState.IsKeyDown(Keys.X) && !oldKeyboardState.IsKeyDown(Keys.X))
            {
                setCamera(-1);
            }
            else if (keyboardState.IsKeyDown(Keys.F) && !oldKeyboardState.IsKeyDown(Keys.F))
            {
                Fog = !Fog;
            }
            // key event handlers needed for Inspector
            // set help display on
            else if (keyboardState.IsKeyDown(Keys.H) && !oldKeyboardState.IsKeyDown(Keys.H))
            {
                inspector.ShowHelp          = true;
                inspector.ShowTreasureBoard = false;                 // Disable treasure score board - added by David Kopp
            }
            // set info display on
            else if (keyboardState.IsKeyDown(Keys.I) && !oldKeyboardState.IsKeyDown(Keys.I))
            {
                inspector.showInfo();
            }
            // set miscellaneous display on
            else if (keyboardState.IsKeyDown(Keys.M) && !oldKeyboardState.IsKeyDown(Keys.M))
            {
                inspector.ShowMatrices      = !inspector.ShowMatrices;
                inspector.ShowHelp          = false;        // Changed possibly by David Kopp
                inspector.ShowTreasureBoard = false;        // Disable treasure score board - added by David Kopp
            }
            // toggle update speed between FixedStep and ! FixedStep (This does not work on Macs - by David Kopp)
            else if (keyboardState.IsKeyDown(Keys.T) && !oldKeyboardState.IsKeyDown(Keys.T))
            {
                FixedStepRendering = !FixedStepRendering;
            }
            else if (keyboardState.IsKeyDown(Keys.Y) && !oldKeyboardState.IsKeyDown(Keys.Y))
            {
                YonFlag = !YonFlag;                  // toggle Yon clipping value.
            }
            // toggle Lerp on or off by hitting L - by David Kopp
            else if (keyboardState.IsKeyDown(Keys.L) && !oldKeyboardState.IsKeyDown(Keys.L))
            {
                LerpFlag = !LerpFlag;
            }
            else if (keyboardState.IsKeyDown(Keys.N) && !oldKeyboardState.IsKeyDown(Keys.N) && !treasure.GameOver) // Enable Treasure Mode for the NPAgent by hitting N (As long as treasure game is not over) - by David Kopp
            {
                npAgent.TreasureMode        = true;                                                                // If you want a toggle use !npAgent.TreasureMode;
                player.TreasureMode         = true;                                                                // If you want a toggle use !player.TreasureMode;
                inspector.ShowTreasureBoard = true;                                                                // Show treasure score board in inspector pane - by David Kopp
                inspector.ShowHelp          = false;                                                               // Disable help in inspector pane - by David Kopp
            }
            else if (keyboardState.IsKeyDown(Keys.S) && !oldKeyboardState.IsKeyDown(Keys.S))                       // Enables the treasure score board to be shown in inspector pane - by David Kopp
            {
                inspector.ShowTreasureBoard = !inspector.ShowTreasureBoard;                                        // Toggles the showing of the reasure score board in inspector pane - by David Kopp
                inspector.ShowHelp          = !inspector.ShowHelp;                                                 // Toggles the help pane in inspector - by David Kopp
            }
            oldKeyboardState = keyboardState;                                                                      // Update saved state.
            base.Update(gameTime);                                                                                 // update all GameComponents and DrawableGameComponents
            currentCamera.updateViewMatrix();
        }