Example #1
0
        /// <summary>
        /// Loads data from file.
        /// </summary>
        public static void LoadData()
        {
            try
            {
                StreamReader reader = new StreamReader(@"../../score.ttn");

                using (reader)
                {
                    // load type of game (PL1vsPL2 or PL1vsPC)
                    string[] line = reader.ReadLine().Split(' ');
                    MenuSettings.gameType = line[1];

                    line = reader.ReadLine().Split(' ');
                    MenuSettings.gameSpeed = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    MenuSettings.racketLength = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    MenuSettings.probability = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Ball.ballPositionX = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Ball.ballPositionY = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Ball.ballCurrentDirectionX = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Ball.ballCurrentDirectionY = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Ball.ballDirection = line[1];

                    line = reader.ReadLine().Split(' ');
                    Rackets.firtsRacketY = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Rackets.secondRacketY = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Table.firstPlayerPoints = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Table.firstPlayerSetsWon = byte.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Table.secondPlayerPoints = int.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Table.secondPlayerSetsWon = byte.Parse(line[1]);

                    line = reader.ReadLine().Split(' ');
                    Rackets.firstPlayerService = bool.Parse(line[1]);
                }
            }
            catch (Exception)
            {
                // if file is missing
                FileNotFound();
            }

            // Rackets.NewService();
            Table.DrawTable();
            Table.PrintResult();
            MainProgram.Engine();
        }