Пример #1
0
        private void GetVerticalKeyboard(int startingX)
        {
            noteDict = new Dictionary <string, MusicNote>();
            MusicNote noteZ = new MusicNote('Z', "C4", startingX); // Y position is 1.

            noteDict.Add(noteZ.noteID, noteZ);

            MusicNote noteX = new MusicNote('X', "Cs4", startingX);// Y position is 2, and so on...

            noteDict.Add(noteX.noteID, noteX);

            MusicNote noteC = new MusicNote('C', "D4", startingX);

            noteDict.Add(noteC.noteID, noteC);

            MusicNote noteV = new MusicNote('V', "Ds4", startingX);

            noteDict.Add(noteV.noteID, noteV);

            MusicNote noteB = new MusicNote('B', "E4", startingX);

            noteDict.Add(noteB.noteID, noteB);

            MusicNote noteN = new MusicNote('N', "F4", startingX);

            noteDict.Add(noteN.noteID, noteN);

            MusicNote noteM = new MusicNote('M', "Fs4", startingX);

            noteDict.Add(noteM.noteID, noteM);

            MusicNote noteA = new MusicNote('A', "G4", startingX);

            noteDict.Add(noteA.noteID, noteA);

            MusicNote noteS = new MusicNote('S', "Gs4", startingX);

            noteDict.Add(noteS.noteID, noteS);

            MusicNote noteD = new MusicNote('D', "A4", startingX);

            noteDict.Add(noteD.noteID, noteD);

            MusicNote noteF = new MusicNote('F', "As4", startingX);

            noteDict.Add(noteF.noteID, noteF);

            MusicNote noteG = new MusicNote('G', "B4", startingX);

            noteDict.Add(noteG.noteID, noteG);

            MusicNote noteH = new MusicNote('H', "C5", startingX);

            noteDict.Add(noteH.noteID, noteH);

            MusicNote noteJ = new MusicNote('J', "Cs5", startingX);

            noteDict.Add(noteJ.noteID, noteJ);

            MusicNote noteK = new MusicNote('K', "D5", startingX);

            noteDict.Add(noteK.noteID, noteK);

            MusicNote noteL = new MusicNote('L', "Ds5", startingX);

            noteDict.Add(noteL.noteID, noteL);

            MusicNote noteQ = new MusicNote('Q', "E5", startingX);

            noteDict.Add(noteQ.noteID, noteQ);

            MusicNote noteW = new MusicNote('W', "F5", startingX);

            noteDict.Add(noteW.noteID, noteW);
        }
Пример #2
0
        public (string, MusicNote[], int[], int[]) ChooseSong(CharacterGrid positionGrid)
        {
            string song = "";

            Console.WriteLine("          Choose your song:");
            Console.WriteLine("1) Twinkle Twinkle Little Star (Easy)");
            Console.WriteLine("2) The Entertainer (Medium)");
            Console.WriteLine("3) In the Hall of the Mountain King (Hard)");
            ConsoleKey choiceNumber = Console.ReadKey(true).Key;

            bool proceed = false;

            while (!proceed)
            {
                try
                {
                    if (choiceNumber == ConsoleKey.D1 || choiceNumber == ConsoleKey.D2 || choiceNumber == ConsoleKey.D3)
                    {
                        //goodPick = true;
                        proceed = true;
                        switch (choiceNumber)
                        {
                        case (ConsoleKey.D1): song += "TwinkleTwinkleLittleStar2.txt"; break;

                        case (ConsoleKey.D2): song += "Entertainer3.txt"; break;

                        case (ConsoleKey.D3): song += "MountainKing2.txt"; break;
                        }
                    }
                    else
                    {
                        Console.CursorLeft = 0;
                        Console.Write("Please press a valid number to choose your song...");
                        choiceNumber = Console.ReadKey(true).Key;
                    }
                }
                catch
                {
                    Console.Write("Please press a valid number to choose your song...");
                    choiceNumber = Console.ReadKey(true).Key;
                }
            }

            string songTitle = "";
            string fileLine;

            MusicNote[] noteArray;
            int[]       durationArray;
            int[]       timeToNextArray;

            using (StreamReader sf = File.OpenText(songDirectory + song))
            {
                songTitle = sf.ReadLine();
                int numberOfLines = Convert.ToInt32(sf.ReadLine());
                noteArray       = new MusicNote[numberOfLines];
                durationArray   = new int[numberOfLines];
                timeToNextArray = new int[numberOfLines];
                int index1 = 0;

                while ((fileLine = sf.ReadLine()) != null && fileLine != "")
                {
                    string[] noteinfo = fileLine.Split(',');

                    noteArray[index1]       = positionGrid.noteDict[noteinfo[0]];
                    durationArray[index1]   = Convert.ToInt32(noteinfo[1]);
                    timeToNextArray[index1] = Convert.ToInt32(noteinfo[2]);
                    index1++;
                }
            }
            Console.SetCursorPosition(0, 0);
            return(songTitle, noteArray, durationArray, timeToNextArray);
        }