Exemple #1
0
        public void Restart()
        {
            _paddingLeft = BoardFactory.GetCells();
            _paddingTop  = BoardFactory.GetCells() / 2;

            _game.InitNewGame();
        }
Exemple #2
0
        /// <summary>
        /// Print board on console
        /// </summary>
        /// <param name="board">board which need print</param>
        /// <param name="padding">padding from left edge console</param>
        private void PrintBorder(Board board, int padding = 0)
        {
            Console.ForegroundColor = ConsoleColor.White;
            for (int i = 0; i < BoardFactory.GetCells(); i++)
            {
                Console.SetCursorPosition(padding, i);

                for (int j = 0; j < BoardFactory.GetCells(); j++)
                {
                    string cell_Symbol = GetSymbolByCellType(board[i, j].Type);
                    Console.Write(cell_Symbol);

                    Console.ForegroundColor = ConsoleColor.White;
                }
                Console.WriteLine();
            }
        }
Exemple #3
0
        private void MoveCursor(Movement move)
        {
            ClearCurrentCursor();

            switch (move)
            {
            case Movement.Left:
                if (!(_paddingLeft - 2 < 1))
                {
                    _paddingLeft -= 2;
                }
                break;

            case Movement.Rigth:
                if (!(_paddingLeft + 2 >= BoardFactory.GetCells() * 2 - 2))
                {
                    _paddingLeft += 2;
                }
                break;

            case Movement.Up:
                if (!(_paddingTop - 1 < 1))
                {
                    _paddingTop -= 1;
                }
                break;

            case Movement.Down:
                if (!(_paddingTop + 1 >= BoardFactory.GetCells() - 1))
                {
                    _paddingTop += 1;
                }
                break;
            }

            SetPosCustumCursor();
        }
Exemple #4
0
 internal void OnSerializingMethod(StreamingContext context)
 {
     _cells = new Cell[BoardFactory.GetCells(), BoardFactory.GetCells()];
     Size   = BoardFactory.GetCells();
 }
Exemple #5
0
 public void PrintComputerBoard()
 {
     PrintBorder(_game.ComputerShipBoard, BoardFactory.GetCells() * 4);
 }
Exemple #6
0
 public void PrintUserBoard()
 {
     PrintBorder(_game.UserShipBoard, BoardFactory.GetCells() * 2);
 }