示例#1
0
        private void MoveTo(int i = 0, int j = 0)
        {
            if (i > 0)
            {
                if (InCell.I + i >= _board.Cells.GetLength(0))
                {
                    return;
                }
            }
            if (j > 0)
            {
                if (InCell.J + j >= _board.Cells.GetLength(1))
                {
                    return;
                }
            }

            if (i < 0)
            {
                if (InCell.I + i < 0)
                {
                    return;
                }
            }
            if (j < 0)
            {
                if (InCell.J + j < 0)
                {
                    return;
                }
            }

            AvalableCellsForMove.Add(_board.Cells[InCell.I + i, InCell.J + j]);
        }
示例#2
0
        public override void GetAvalableCellsForMove(IBoard board)
        {
            if (this._board == null)
            {
                this._board = board;
            }

            if (InCell == null)
            {
                return;
            }

            AvalableCellsForMove.Clear();

//          Поиск ходов по прямой
            MoveTo(1, 0);
            MoveTo(-1, 0);
            MoveTo(0, 1);
            MoveTo(0, -1);

//          Поиск ходов по диагонали
            MoveTo(1, 1);
            MoveTo(-1, -1);
            MoveTo(-1, 1);
            MoveTo(1, -1);
        }
示例#3
0
        private void MoveTo(int i = 0, int j = 0)
        {
            _isFirstStep = false;

            if (InCell.I + i >= _board.Cells.GetLength(0) || InCell.I + i < 0)
            {
                return;
            }
            if (InCell.J + j >= _board.Cells.GetLength(1) || InCell.J + j < 0)
            {
                return;
            }

            if (i == j || i == -j)
            {
                if (!_board.Cells[InCell.I + i, InCell.J + j].IsFree())
                {
                    AvalableCellsForMove.Add(_board.Cells[InCell.I + i, InCell.J + j]);
                }
            }
            else
            {
                if (_board.Cells[InCell.I + i, InCell.J + j].IsFree())
                {
                    AvalableCellsForMove.Add(_board.Cells[InCell.I + i, InCell.J + j]);
                }
            }
        }
示例#4
0
        public override void GetAvalableCellsForMove(IBoard board)
        {
            if (this._board == null)
            {
                this._board = board;
            }

            AvalableCellsForMove.Clear();

            switch (FigureColor)
            {
            case FigureColor.WHITE:
                MoveTo(0, _isFirstStep ? 2 : 1);
                MoveTo(0, 1);
                break;

            case FigureColor.BLACK:
                MoveTo(0, _isFirstStep ? -2 : -1);
                MoveTo(0, -1);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            MoveTo(1, -1);
            MoveTo(-1, 1);
            MoveTo(1, 1);
            MoveTo(-1, -1);
        }
示例#5
0
        private void MoveTo(int i = 0, int j = 0)
        {
            _isFirstStep = false;

            if (InCell.I + i >= _board.Cells.GetLength(0) || InCell.I + i < 0)
            {
                return;
            }
            if (InCell.J + j >= _board.Cells.GetLength(1) || InCell.J + j < 0)
            {
                return;
            }

            AvalableCellsForMove.Add(_board.Cells[InCell.I + i, InCell.J + j]);
        }
示例#6
0
        public override void GetAvalableCellsForMove(IBoard board)
        {
            if (this._board == null)
            {
                this._board = board;
            }

            if (InCell == null)
            {
                return;
            }

            AvalableCellsForMove.Clear();

            MoveTo(1, 0);
            MoveTo(-1, 0);
            MoveTo(0, 1);
            MoveTo(0, -1);
        }
示例#7
0
        private void MoveTo(int i, int j)
        {
            if (InCell.I + i >= _board.Cells.GetLength(0) || InCell.I + i < 0)
            {
                return;
            }
            if (InCell.J + j >= _board.Cells.GetLength(1) || InCell.J + j < 0)
            {
                return;
            }

            for (int _i = InCell.I + i, _j = InCell.J + j;
                 0 < _i && _i < _board.Cells.GetLength(0) && 0 < _j && _j < _board.Cells.GetLength(0);
                 _i += i, _j += j)
            {
                AvalableCellsForMove.Add(_board.Cells[_i, _j]);
                if (!_board.Cells[_i, _j].IsFree())
                {
                    break;
                }
            }
        }