/// <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); } // 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.N) && !oldKeyboardState.IsKeyDown(Keys.N)) { npAgent.treasureSearch = true; } // 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; } oldKeyboardState = keyboardState; // Update saved state. base.Update(gameTime); // update all GameComponents and DrawableGameComponents currentCamera.updateViewMatrix(); }
/// <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); inspector.setTreasureInformation(AGProject1.CustomItems.NumTreasuresLeft, AGProject1.CustomItems.numTreasures - AGProject1.CustomItems.NumTreasuresLeft - AGProject1.CustomItems.NPCNumTreasuresLeft, AGProject1.CustomItems.NPCNumTreasuresLeft); inspector.setPackingInfo(pack.flockLevel); } // 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); } // 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; } else if (keyboardState.IsKeyDown(Keys.P) && !oldKeyboardState.IsKeyDown(Keys.P)) { packing++; if (packing >= 4) { packing = 0; } pack.flockLevel = packing; } // toggle update speed between FixedStep and ! FixedStep else if (keyboardState.IsKeyDown(Keys.T) && !oldKeyboardState.IsKeyDown(Keys.T)) { FixedStepRendering = !FixedStepRendering; } // CUSTOM KEY BINDS ******************************************************************************* // Keybind to activate/deactivate lerping else if (keyboardState.IsKeyDown(Keys.L) && !oldKeyboardState.IsKeyDown(Keys.L)) { AGProject1.CustomItems.Lerping = !AGProject1.CustomItems.Lerping; } // Keybind to trigger treasure-seeking mode for the NPAgent else if (keyboardState.IsKeyDown(Keys.N) && !oldKeyboardState.IsKeyDown(Keys.N)) { AGProject1.CustomItems.TreasureMode = !AGProject1.CustomItems.TreasureMode; } oldKeyboardState = keyboardState; // Update saved state. base.Update(gameTime); // update all GameComponents and DrawableGameComponents currentCamera.updateViewMatrix(); }
/// <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 lines 13 and 14 can be used to describe player and npAgent's status inspector.setMatrices("player", "npAgent", player.AgentObject.Orientation, npAgent.AgentObject.Orientation); } // moved from timer to reflect real-time gameplay inspector.setInfo(11, agentLocation(player)); inspector.setInfo(12, agentLocation(npAgent)); //percentage of packing display: DLP inspector.setInfo(13, "Percentage packing: " + packing[percentPacking] + "%"); // 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); } // 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; } //Crank up the lerp. DLP else if (keyboardState.IsKeyDown(Keys.L) && !oldKeyboardState.IsKeyDown(Keys.L)) { lerpToggle = !lerpToggle; } //Cycle flocking percentages. DLP else if (keyboardState.IsKeyDown(Keys.P) && !oldKeyboardState.IsKeyDown(Keys.P)) { if (percentPacking == 3)//Wrap index. { percentPacking = 0; } else { percentPacking++;//Increment pack percentage. } } // toggle update speed between FixedStep and ! FixedStep else if (keyboardState.IsKeyDown(Keys.T) && !oldKeyboardState.IsKeyDown(Keys.T)) { FixedStepRendering = !FixedStepRendering; } oldKeyboardState = keyboardState; // Update saved state. base.Update(gameTime); // update all GameComponents and DrawableGameComponents currentCamera.updateViewMatrix(); }
/// <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); } // 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.Z) && !oldKeyboardState.IsKeyDown(Keys.Z)) { DrawSensors = !DrawSensors; } // 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; } // Lerp key event handler else if (keyboardState.IsKeyDown(Keys.L) && !oldKeyboardState.IsKeyDown(Keys.L)) { player.ToggleLerp(); npAgent.ToggleLerp(); // Set a display string to show if lerp is active if (player.GetLerp()) { inspector.setInfo(20, "Lerp is currently active"); } else { inspector.setInfo(20, "Lerp is currently not active"); } } // Treasure finder mode else if (keyboardState.IsKeyDown(Keys.N) && !oldKeyboardState.IsKeyDown(Keys.N)) { npAgent.FindTreasure(); } // Adjust packing else if (keyboardState.IsKeyDown(Keys.P) && !oldKeyboardState.IsKeyDown(Keys.P)) { PackingAmount++; } // Update the inspector for treasures String pTagged = "Player Tagged Treasures: "; String npTagged = "NPAgent Tagged Treasures: "; String untagged = "Untagged Treasures: "; bool anyPTagged = false; bool anyNPTagged = false; bool allTagged = true; foreach (Treasure t in treasures) { if (t.IsTagged()) { if (t.GetTaggedName() == player.Name) { pTagged += t.Name; pTagged += " "; anyPTagged = true; } else if (t.GetTaggedName() == npAgent.Name) { npTagged += t.Name; npTagged += " "; anyNPTagged = true; } } else { untagged += t.Name; untagged += " "; allTagged = false; } } if (anyPTagged) { pTagged += "Total Found: "; } if (anyNPTagged) { npTagged += "Total Found: "; } pTagged += player.TreasuresFound; npTagged += npAgent.TreasuresFound; if (allTagged) { setInfo(24, "All Treasures Tagged."); } else { setInfo(24, untagged); } setInfo(22, pTagged); setInfo(23, npTagged); oldKeyboardState = keyboardState; // Update saved state. base.Update(gameTime); // update all GameComponents and DrawableGameComponents currentCamera.updateViewMatrix(); }
/// <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) { steps++; Vector3 sensorPos1 = npAgent.AgentObject.Translation + (npAgent.AgentObject.Forward * 450) + (npAgent.AgentObject.Right * 100); sensorPos1.Y = terrain.surfaceHeight((int)(sensorPos1.X / spacing), (int)(sensorPos1.Z / spacing)); sensor1.AgentObject.Translation = sensorPos1; Vector3 sensorPos2 = npAgent.AgentObject.Translation + (npAgent.AgentObject.Forward * 450) + (npAgent.AgentObject.Left * 100); sensorPos2.Y = terrain.surfaceHeight((int)(sensorPos2.X / spacing), (int)(sensorPos2.Z / spacing)); sensor2.AgentObject.Translation = sensorPos2; //inspector.setInfo(11, "sensor right: " + sensor1.Collision); //inspector.setInfo(12, "sensor left: " + sensor2.Collision); if (sensor1.Collision || sensor2.Collision) { if (sensor1.Collision) { npAgent.AgentObject.Yaw = npAgent.AgentObject.Yaw + 0.2f; } else if (sensor2.Collision) { npAgent.AgentObject.Yaw = npAgent.AgentObject.Yaw + -0.2f; } } // 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); } // 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); } // 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; } oldKeyboardState = keyboardState; // Update saved state. base.Update(gameTime); // update all GameComponents and DrawableGameComponents currentCamera.updateViewMatrix(); }