Пример #1
0
        /// <summary>
        /// Show Reference
        /// </summary>
        /// <param name="tb">User Table</param>
        /// <param name="playingField">Program Table</param>
        /// <returns>Program state</returns>
        private static ProgramSate Reference(ref ViewTable tb, ref Table playingField)
        {
            Action action;

            Console.Clear();
            Console.WriteLine(strReference);
            Console.SetCursorPosition(0, 0);

            action = UserActions.GetUserAction();
            while (action != Action.Exit)
            {
                action = UserActions.GetUserAction();
            }
            return(ProgramSate.Menu);
        }
Пример #2
0
        /// <summary>
        /// If user wins game
        /// </summary>
        /// <param name="tb">User Table</param>
        /// <param name="playingField">Program Table</param>
        /// <returns>Program state</returns>
        private static ProgramSate WinGame(ref ViewTable tb, ref Table playingField)
        {
            ProgramSate ps = ProgramSate.Game;
            Action      action;

            Console.Clear();
            Console.Write(strWin);
            playingField.MoveYesNo(tb, 0);
            Console.SetCursorPosition(38, 12);
            Console.WriteLine(playingField.shots);
            Console.SetCursorPosition(35, 15);
            Console.WriteLine((Environment.TickCount - playingField.start) / 1000);

            bool ch = true;

            while (ch)
            {
                action = UserActions.GetUserAction();
                switch (action)
                {
                case Action.Left:
                    playingField.MoveYesNo(tb, -1);
                    break;

                case Action.Right:
                    playingField.MoveYesNo(tb, 1);
                    break;

                case Action.Enter:
                    ch = false;
                    if (playingField.cursorYesNo == 0)
                    {
                        ps = ProgramSate.GameSetUp;
                    }
                    else
                    {
                        ps = ProgramSate.Menu;
                    }
                    break;
                }
            }
            return(ps);
        }
Пример #3
0
        /// <summary>
        /// Move by Menu
        /// </summary>
        /// <param name="tb">User Table</param>
        /// <param name="playingField">Program Table</param>
        /// <returns>Program state</returns>
        public static ProgramSate Menu(ref ViewTable tb, ref Table playingField)
        {
            Console.Clear();
            Console.Write(strMenu); // draw menu
            ProgramSate ps = ProgramSate.Menu;

            Console.CursorVisible = false;

            Action action;

            playingField.MoveMenu(tb, 0);

            action = UserActions.GetUserAction();
            switch (action)
            {
            case Action.Bottom:
                playingField.MoveMenu(tb, 1);
                break;

            case Action.Top:
                playingField.MoveMenu(tb, -1);
                break;

            case Action.Enter:
                switch (playingField.cursorMenu)
                {
                case 0:
                    ps = ProgramSate.GameSetUp;
                    break;

                case 1:
                    ps = ProgramSate.Reference;
                    break;

                case 2:
                    ps = ProgramSate.Exit;
                    break;
                }
                break;
            }
            Console.CursorVisible = true;
            return(ps);
        }
Пример #4
0
        /// <summary>
        /// Exit from game
        /// </summary>
        /// <param name="tb">User Table</param>
        /// <param name="playingField">Program Table</param>
        /// <returns>Program state</returns>
        private static ProgramSate GameExit(ref ViewTable tb, ref Table playingField)
        {
            ProgramSate ps = ProgramSate.Game;
            Action      action;

            Console.Clear();
            Console.WriteLine(strExit);
            playingField.MoveYesNoExit(tb, 0);
            bool bl = true;

            while (bl)
            {
                action = UserActions.GetUserAction();
                switch (action)
                {
                case Action.Left:
                    playingField.MoveYesNoExit(tb, -1);
                    break;

                case Action.Right:
                    playingField.MoveYesNoExit(tb, 1);
                    break;

                case Action.Enter:

                    if (playingField.cursorYesNoExit == 0)
                    {
                        bl = false;
                        ps = ProgramSate.Menu;
                    }
                    else
                    {
                        bl = false;
                        ps = ProgramSate.Game;
                    }
                    break;
                }
            }
            return(ps);
        }
Пример #5
0
        /// <summary>
        /// Game, move by table, shot ...
        /// </summary>
        /// <param name="tb">User Table</param>
        /// <param name="playingField">Program Table</param>
        /// <returns>Program state</returns>
        public static ProgramSate Game(ref ViewTable tb, ref Table playingField)
        {
            ProgramSate ps     = ProgramSate.Game;
            Action      action = Action.NoAction;

            Console.Clear();
            tb.DrawField(playingField);
            playingField.MoveGameCursore(0, 0, tb);

            Console.CursorVisible = true;

            if (showPeleng)
            {
                Console.Clear();
                tb.DrawField(playingField);
                go = playingField.EnterFoxes(tb);
                if (go == 2)
                {
                    ps = WinGame(ref tb, ref playingField);
                }
                else
                {
                    GameInfo(tb, playingField, go);
                    Console.CursorVisible = false;

                    action = UserActions.GetUserAction();
                }
            }
            else
            {
                action = UserActions.GetUserAction();
            }

            switch (action)
            {
            case Action.Left:
                showPeleng = false;
                playingField.MoveGameCursore(-1, 0, tb);
                break;

            case Action.Right:
                showPeleng = false;
                playingField.MoveGameCursore(1, 0, tb);
                break;

            case Action.Top:
                showPeleng = false;
                playingField.MoveGameCursore(0, -1, tb);
                break;

            case Action.Bottom:
                showPeleng = false;
                playingField.MoveGameCursore(0, 1, tb);
                break;

            case Action.Enter:
                showPeleng = !showPeleng;
                break;

            case Action.Exit:
                ps = GameExit(ref tb, ref playingField);
                break;
            }
            return(ps);
        }