public override void Update(GameTime gameTime) { KeyboardState KeyboardState = Keyboard.GetState(); if (KeyboardState.IsKeyDown(Keys.Enter) && !previousKeyboardState.IsKeyDown(Keys.Enter)) { MediaPlayer.IsRepeating = false; MediaPlayer.Stop(); GameStateManager.Instance.ChangeScreen(new TitleScreen(graphicsDevice, game)); } character.Update(); albumart.Update(); if (windowText != null) { windowText.Update(); } previousKeyboardState = KeyboardState; }
public override void Update(GameTime gameTime) { int i; //iterative variable timerOffset++; // Calibrate current frame to be in-time with the position of the song. framecount = Convert.ToUInt64(MediaPlayer.PlayPosition.TotalSeconds * 60); // Beat if (timerOffset >= offset) { if (timerBeat >= framesPerBeat) { if (enableMetronome) { hitsound.Play(); } timerBeat -= framesPerBeat; } timerBeat++; } // Update Overlay overlay.Update(gameTime); // Update Album Art albumart.Update(); // Update Idle Notes for (i = 0; i < listnote.Count; i++) { if (framecount >= listnote[i].spawnframe) { listnote_active.Add(listnote[i]); listnote.RemoveAt(i); } } // Update Active Notes for (i = 0; i < listnote_active.Count; i++) { listnote_active[i].Update(gameTime); // Double Notes if (i + 1 < listnote_active.Count) { if (listnote_active[i].spawnframe == listnote_active[i + 1].spawnframe) { listnote_active[i + 1].Bounds.Y = listnote_active[i].Bounds.Y; i++; } } // Miss if (framecount - listnote_active[i].hitframe > accuOkay + calibNoteTiming && framecount - listnote_active[i].hitframe < 100) { if (Chain > maxChain) { maxChain = Chain; } Chain = 0; chainText = "BREAK"; chainColor = Color.Red; textTimer = 0; countBreak++; listnote_active.RemoveAt(i); break; } } // Checks input to see if the player successfully hits the note CheckInput(); // Update Buttons for (i = 0; i < listbutton.Count; i++) { listbutton[i].Update(gameTime); } // Update Note Hit Effects for (i = 0; i < notehits.Count; i++) { notehits[i].Update(); if (notehits[i].AnimationDone) { notehits.RemoveAt(i); } } // Check if Song ended if (listnote.Count <= 0 && listnote_active.Count <= 0) { if (timerEndGame <= 0) { if (Chain > maxChain) { maxChain = Chain; } MediaPlayer.Stop(); GameStateManager.Instance.ChangeScreen(new RhythmGameResults(graphicsDevice, game, this, albumart)); } else { timerEndGame--; } } }