Пример #1
0
        public void UseMenu()
        {
            Console.Clear();
            int levelsCount = CheckLevelsFiles();
            int chosedLevel;

            try
            {
                chosedLevel = ReadChosedLevel(levelsCount);
            }
            catch
            {
                OnWrongLevelChosed(levelsCount);
                return;
            }
            try
            {
                string path      = string.Format(Environment.CurrentDirectory + "/level_{0}.txt", chosedLevel);
                string levelStr  = File.ReadAllText(path);
                string levelMap  = levelStr.Substring(levelStr.IndexOf('\n'));
                string moveDelay = levelStr.Remove(levelStr.IndexOf('\n'));
                GameFieldManager.moveDelay = Convert.ToInt32(moveDelay);
                gameFieldManager           = new GameFieldManager(levelMap);
                Console.Clear();
                bool gameRes = gameFieldManager.StartGame();
                Console.Clear();
                OnGameResult(gameRes);
            }
            catch (Exception e)
            {
                OnLevelOpenException(e);
            }
        }
Пример #2
0
 void OnGameResult(bool levelCompleted)
 {
     if (levelCompleted)
     {
         Console.WriteLine("You WON, congratulations!");
     }
     else
     {
         Console.WriteLine("We are so sorry for creation so hard level, you can restart if you want to rematch.");
     }
     Console.ReadLine();
     gameFieldManager.Dispose();
     gameFieldManager = null;
     UseMenu();
 }