示例#1
0
 public void StartGame()
 {
     Playingfield();
     while (!objPlayable.IsFinished())
     {
         int value;
         Console.WriteLine("Enter the number you want to move");
         if (Int32.TryParse(Console.ReadLine(), out value))
         {
             if (value >= 0)
             {
                 objPlayable.Shift(value);
                 Playingfield();
             }
             else
             {
                 Console.WriteLine("This number is less than zero");
             }
         }
         else
         {
             Console.WriteLine("Can not read line, try again");
         }
     }
     Console.WriteLine("Congratulations, the game is over");
 }
示例#2
0
        public void StartGame()
        {
            int step = 0;

            while (!play.IsFinished())
            {
                Console.Clear();
                PrintBoard();

                int shiftValue = ReadShiftValue();

                try
                {
                    play.Shift(shiftValue);
                    step++;
                }
                catch (ArgumentException ex)
                {
                    Console.WriteLine("{0}", ex.Message);
                    Console.ReadLine();
                }
            }

            Console.Clear();
            PrintBoard();

            Console.WriteLine("Игра завершена за {0} шагов! Поздравляю!", step);
            Console.ReadLine();
        }
示例#3
0
        public void Play()
        {
            int  EnterFromUser, AmountStepsOfGame;
            bool ControlMenu = false;

            do
            {
                Console.Clear();
                Console.WriteLine("Enter the number which you want to move.\n");
                Console.WriteLine("Enter -1 to shake values.\n");
                //Console.WriteLine("Enter -2 to see history.\n");
                //Console.WriteLine("Enter -3 to FlashBack.\n");
                Console.WriteLine("Enter 0 to leave.\n");
                OutPutMatrix();
                if (Iplayable.IsFinished())
                {
                    Console.WriteLine("You WIN!!!");
                }

                EnterFromUser = int.Parse(Console.ReadLine());
                switch (EnterFromUser)
                {
                case 0:
                    ControlMenu = true;
                    Console.Beep();
                    break;

                case -1:
                    Iplayable.Randomize();
                    break;

                /*case -2:
                 *  for (int i = 0; i < FieldOfGame.GetHistory.Count; i++)
                 *  {
                 *      Console.WriteLine("Value " + FieldOfGame.GetHistory[i].value +
                 *          " we moved on " + FieldOfGame.GetHistory[i].valueX + " " + FieldOfGame.GetHistory[i].valueY);
                 *  }
                 *  Console.WriteLine("Enter any key to continue.");
                 *  Console.ReadKey();
                 *  break;
                 *
                 * case -3:
                 *  Console.WriteLine("How many steps you want roll back?");
                 *  AmountStepsOfGame = int.Parse(Console.ReadLine());
                 *  FieldOfGame.FlashBackOnStep(AmountStepsOfGame);
                 *  break;*/

                default:
                    Iplayable.Shift(EnterFromUser);
                    Console.Beep();
                    break;
                }
            } while (!ControlMenu);
        }
示例#4
0
        public void StartGame()
        {
            int value = 0;

            while (!objectIPlayable.IsFinished(objectIPlayable as Game))
            {
                Console.WriteLine("Поле перед ходом.");
                Print();
                Console.WriteLine("Введите число, которое хотите передвинуть.");
                value = Convert.ToInt32(Console.ReadLine());
                if ((value < 1) & (value > objectIPlayable.SizeOfField))
                {
                    throw new ArgumentException("Нет такого числа");
                }
                objectIPlayable.Shift(value);
                Console.WriteLine("Поле после хода.");
                Print();
            }
            Console.WriteLine("Поздравляю, Вы выйграли.");
        }