示例#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 StartGame()
        {
            while (!gmb.IsFinished)
            {
                Console.Write("Какое значение двигаем? ");
                int val = int.Parse(Console.ReadLine());

                try
                {
                    if (val > 0)
                    {
                        gmb.Shift(val);
                        this.Print();
                    }
                    else
                    {
                        Console.WriteLine("Неверный ввод. Повторите.");
                    }
                }
                catch (Exception ex)
                {
                    Console.WriteLine(string.Format("Неправильный ход! {0}", ex.Message));
                }
            }
            Console.WriteLine("Поздравляем! Игра завершена!");
        }
示例#4
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);
        }
示例#5
0
        public void MakeStep()
        {
            int puzzle = 0;

            Console.WriteLine("Какую цифру Вы хотите передвинуть?");
            puzzle = Convert.ToInt32(Console.ReadLine());
            if (puzzle > this.Count)
            {
                Console.WriteLine("Такой цифры нету в игре!");
            }
            else
            {
                Obj.Shift(puzzle);
                this.RedrawConsole();
            }
        }
示例#6
0
        public void Moves()
        {
            int value = Convert.ToInt32(Console.ReadLine());

            try
            {
                Interface.Shift(value);
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Неверное значение");
                Moves();
            }

            Console.Clear();
            Write();
        }
示例#7
0
        public void Move()
        {
            int value = Convert.ToInt32(Console.ReadLine());

            try
            {
                GameInterface.Shift(value);
            }
            catch (ArgumentException)
            {
                Console.WriteLine("Невозможно передвинуть");
                Move();
            }

            Console.Clear();
            Print();
        }
示例#8
0
        public ConsoleGameUI(IPlayable iPlayable)
        {
            this.iPlayable = iPlayable;

            while (true)
            {
                reDraw();
                if (iPlayable.IsFinished)
                {
                    Console.WriteLine("YOU WIN");
                }
                Console.Write("Shift: ");
                int command = Convert.ToInt32(Console.ReadLine());
                if (command == 0)
                {
                    break;
                }
                iPlayable.Shift(command);
            }
        }
示例#9
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("Поздравляю, Вы выйграли.");
        }
示例#10
0
        public void Play()
        {
            PrintMenu();
            PrintBoard();
            while (!game.IsCompleted())
            {
                try
                {
                    bool   tempFlag = true;
                    string s        = Console.ReadLine();
                    switch (s)
                    {
                    case "q":
                        tempFlag = false;
                        break;

                    case "r":
                        game.Randomize();
                        RefreshScreen();
                        break;

                    default:
                        game.Shift(int.Parse(s));
                        RefreshScreen();
                        break;
                    }

                    if (tempFlag == false)
                    {
                        break;
                    }
                }

                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
示例#11
0
 public void Shift()
 {
     IPLAY.Shift(Convert.ToInt32(Console.ReadLine()));
 }
示例#12
0
文件: UI.cs 项目: Gelarie/15game
 public void Input()
 {
     int value = Convert.ToInt32(Console.ReadLine());
     Game.Shift(value);
 }