}                                                  // for serialization
        //[DataMember]
        //public List<int> _compLuckyShotPos { get; set; }

        /// <summary>
        /// Create new game boards and arrange ships
        /// </summary>
        public void InitNewGame()
        {
            UserShootingBoard = BoardFactory.MakeBoard();

            UserShipBoard = BoardFactory.MakeBoard();
            UserShipBoard.ArrangeShips();

            ComputerShipBoard = BoardFactory.MakeBoard();
            ComputerShipBoard.ArrangeShips();

            CompPlayer = new ComputerPlayer();
        }
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);
 }
Exemple #7
0
 private void GetBoard()
 {
     board = BoardFactory.makeBoard();
 }