/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape)) { //Arduino.Close(); Exit(); } // TODO: Add your update logic here keyboardChanges = UltraKeyboard.getChanges(); keyboardState = Keyboard.GetState(); timer.Update(gameTime, soundEffects); soundEffects.Play(); outerWorks.Update(gameTime, keyboardChanges, keyboardState); gearCounter.Update(gameTime, keyboardChanges, keyboardState); endgameCounter.Update(gameTime, keyboardChanges, keyboardState); bool redBreach = outerWorks.redBreach; bool blueBreach = outerWorks.blueBreach; bool redMidCapture = gearCounter.redMidCapture; bool blueMidCapture = gearCounter.blueMidCapture; bool redCapture = gearCounter.redMidCapture && endgameCounter.redAllChallenged; bool blueCapture = gearCounter.blueMidCapture && endgameCounter.blueAllChallenged; int redBreachPoints; int blueBreachPoints; int redCapturePoints; int blueCapturePoints; if (redBreach) { redBreachPoints = 20; } else { redBreachPoints = 0; } if (blueBreach) { blueBreachPoints = 20; } else { blueBreachPoints = 0; } scoreCounter.Update(outerWorks.blueScore + gearCounter.redScore + endgameCounter.redScore + blueBreachPoints, outerWorks.redScore + gearCounter.blueScore + endgameCounter.blueScore + redBreachPoints); rpCounter.Update(blueBreach, redBreach, redMidCapture, blueMidCapture, redCapture, blueCapture); char[] package = outerWorks.package; if (gearCounter.redGears >= 6) { package[6] = '4'; } else { package[6] = '0'; } if (gearCounter.blueGears >= 6) { package[12] = '4'; } else { package[12] = '0'; } Arduino.Send(package); if (keyboardChanges.IsKeyDown(Keys.OemPipe)) { outerWorks.Reset(); gearCounter.Reset(); endgameCounter.Reset(); timer.StartMatch(gameTime); } if ((keyboardChanges.IsKeyDown(Keys.OemOpenBrackets) || keyboardChanges.IsKeyDown(Keys.OemCloseBrackets)) && !timer.InMatch) { outerWorks.Reset(); gearCounter.Reset(); endgameCounter.Reset(); timer.ResetClean(); } if (keyboardChanges.IsKeyDown(Keys.Enter)) { outerWorks.Reset(); gearCounter.Reset(); endgameCounter.Reset(); timer.Reset(soundEffects); } base.Update(gameTime); }