public FeedbackScreen(TDatabase inDatabase, TValidation inFeedback, Composition inTSong, Game1 inGame) { InitializeComponent(); Database = inDatabase; Feedback = inFeedback; TSong = inTSong; Game = inGame; IsSaved = false; TryAgain = false; }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { _PriorKey = _CurrentKey; _CurrentKey = Keyboard.GetState(); PriorButton = CurrentButton; CurrentButton = Mouse.GetState(); NoteFunction(); OctaveToggle(); bool DifficultyUp = _CurrentKey.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Right) && _PriorKey.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Right); bool DifficultyDown = _CurrentKey.IsKeyDown(Microsoft.Xna.Framework.Input.Keys.Left) && _PriorKey.IsKeyUp(Microsoft.Xna.Framework.Input.Keys.Left); int XBar, OctaveIndex; SongString = TSong.Song; OctaveIndex = (int)_OctaveVariation; PlayNote.OctaveIndex = OctaveIndex.ToString()[0]; Note.TNote KeyToScreen = Note.TNote.C; Rectangle SliderRectangle = new Rectangle(400 - (50 * (int)TSong.Difficulty), 14, 15, 25); bool ButtonPressed = CurrentButton.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed && PriorButton.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released; bool ButtonUnpressed = CurrentButton.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released && PriorButton.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed; for (int i = 1; i < 9; i++) //Prints Keyboard { KeyToScreen = (Note.TNote)((int)KeyToScreen % 8); if (KeyToScreen == 0) { KeyToScreen++; } Value = KeyToScreen.ToString(); CurrentKeyImage[i] = new PlayNote(Value[0], i); KeyToScreen++; } GraphicsDevice.Clear(Color.White); // TODO: Add your drawing code here spriteBatch.Begin(); if (PressedNotes == "") { if (DifficultyUp && TSong.Difficulty != Composition.TDifficulty.Hard) { TSong.Difficulty--; } if (DifficultyDown && TSong.Difficulty != Composition.TDifficulty.SuperEasy) { TSong.Difficulty++; } } ToBePlayed = TSong.DifficultyModification(SongString, TSong.Difficulty); if (Index != ToBePlayed.Length) { if (ButtonPressed && PauseButtonRec.Contains(CurrentButton.X, CurrentButton.Y)) { Pause = true; PauseScreen(); } spriteBatch.Draw(Image, StaveRec, Color.White); spriteBatch.Draw(PauseButton, PauseButtonRec, Color.Red); spriteBatch.DrawString(spriteFont, "Current Octave Index:" + PlayNote.OctaveIndex, new Vector2(500, 210), Color.Blue); spriteBatch.Draw(DifficultyBar, new Vector2(150, 20), Color.Red); spriteBatch.Draw(DifficultySlider, SliderRectangle, Color.Black); spriteBatch.Draw(UpArrow, UpArrowRec, Color.White); spriteBatch.Draw(DownArrow, DownArrowRec, Color.White); spriteBatch.DrawString(spriteFont, TSong.TimeSignature.Numerator.ToString(), new Vector2(150, 45), Color.Black); spriteBatch.DrawString(spriteFont, TSong.TimeSignature.Numerator.ToString(), new Vector2(150, 125), Color.Black); spriteBatch.DrawString(spriteFont, TSong.TimeSignature.Denominator.ToString(), new Vector2(150, 73), Color.Black); spriteBatch.DrawString(spriteFont, TSong.TimeSignature.Denominator.ToString(), new Vector2(150, 153), Color.Black); int MaxNotesOnScreen = (20 / (int)TSong.Difficulty); if (TSong.Difficulty == Composition.TDifficulty.Medium) { MaxNotesOnScreen++; } if (Index / 2 < MaxNotesOnScreen) { if (ToBePlayed.Length / 2 == MaxNotesOnScreen) { XBar = Composition.NotesToScreen.ElementAt(LastNoteIndex()).XValue + 30; spriteBatch.Draw(Bar, new Vector2(XBar, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar + 5, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar, 125), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar + 5, 125), Color.Black); } if (ToBePlayed.Length / 2 >= MaxNotesOnScreen) { for (int i = 0; i < MaxNotesOnScreen; i++)//Creates a bar { Temp = i * (int)TSong.Difficulty; spriteBatch.Draw(Composition.NotesToScreen.ElementAt(Temp).NoteImage, Composition.NotesToScreen.ElementAt(Temp).Coordinates, Color.White); BoxCoords = new Vector2(Composition.NotesToScreen.ElementAt(Temp).XValue, Composition.NotesToScreen.ElementAt(Temp).YValue - 20); if (TSong.IsBar(i) == true && i + 1 < Composition.NotesToScreen.Count) { XBar = Composition.NotesToScreen.ElementAt(Temp).XValue + 30; spriteBatch.Draw(Bar, new Vector2(XBar, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar, 125), Color.Black); } if (Index / 2 == i) { spriteBatch.Draw(CurrentNoteBox, BoxCoords, Color.White); } } } else { for (int i = 0; i < ToBePlayed.Length / 2; i++)//Creates a bar { Temp = i * (int)TSong.Difficulty; spriteBatch.Draw(Composition.NotesToScreen.ElementAt(Temp).NoteImage, Composition.NotesToScreen.ElementAt(Temp).Coordinates, Color.White); BoxCoords = new Vector2(Composition.NotesToScreen.ElementAt(Temp).XValue, Composition.NotesToScreen.ElementAt(Temp).YValue - 20); if (TSong.IsBar(i) == true && i + 1 < Composition.NotesToScreen.Count) { XBar = Composition.NotesToScreen.ElementAt(Temp).XValue + 30; spriteBatch.Draw(Bar, new Vector2(XBar, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar, 125), Color.Black); } if (Index / 2 == i) { spriteBatch.Draw(CurrentNoteBox, BoxCoords, Color.White); } XBar = Composition.NotesToScreen.ElementAt(LastNoteIndex()).XValue + 30; spriteBatch.Draw(Bar, new Vector2(XBar, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar + 5, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar, 125), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar + 5, 125), Color.Black); } } } else { for (int i = MaxNotesOnScreen; i < ToBePlayed.Length / 2; i++)//Adds Note { Temp = i * (int)TSong.Difficulty; spriteBatch.Draw(Composition.NotesToScreen.ElementAt(Temp).NoteImage, Composition.NotesToScreen.ElementAt(Temp).Coordinates, Color.White); BoxCoords = new Vector2(Composition.NotesToScreen.ElementAt(Temp).XValue, Composition.NotesToScreen.ElementAt(Temp).YValue - 20); if (Index / 2 == i) { spriteBatch.Draw(CurrentNoteBox, BoxCoords, Color.White); } if (TSong.IsBar(i) == true && i + 1 < ToBePlayed.Length / 2) { XBar = Composition.NotesToScreen.ElementAt(i).XValue + 30; spriteBatch.Draw(Bar, new Vector2(XBar, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar, 125), Color.Black); } XBar = Composition.NotesToScreen.ElementAt((ToBePlayed.Length / 2) - 1).XValue + 30; spriteBatch.Draw(Bar, new Vector2(XBar, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar + 5, 48), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar, 125), Color.Black); spriteBatch.Draw(Bar, new Vector2(XBar + 5, 125), Color.Black); } } for (int i = 1; i < 9; i++)//Adds Piano Keys { if (i == 6) { PlayNote.OctaveIndex++; } else if (i == 0) { PlayNote.OctaveIndex--; } PlayNote Temp = _KeyList.ElementAt(i - 1); spriteBatch.Draw(CurrentKeyImage[i].ReturnCurrentTexture, CurrentKeyImage[i].ReturnCurrentKey, CurrentKeyImage[i].ToBePressed(ref ToBePlayed, ref Index, Temp, false)); NotesInput(ref PressedNotes, Temp); Temp.IsPressed = false; CurrentKeyImage[i].IsPressed = false; } if (Counter > TSong.TimeBetweenBeats - 10 || Counter < 10) { spriteBatch.Draw(Ticker, Metronome, Color.Red); if (Counter == TSong.TimeBetweenBeats) { Counter = 0; } } } else { Validation = new TValidation(ToBePlayed, PressedNotes); Validation.Feedback(); FormLoad(); } spriteBatch.End(); base.Draw(gameTime); }