Exemplo n.º 1
0
        //private string AbroadChessboardException = "direction не входит в список" +
        //           "координат клеток, доступных для действий. Рекомендуеться использовать координаты из списков CellsForAttacks ии CellsForWalks";



        /// <summary>
        /// Формулирует список координат клеток, с которыми возможно взаимодействие: атака, ход.
        /// </summary>
        /// <returns></returns>
        protected override void FormulatedAvailableActions()
        {
            this.CellsForAttacks.Clear();
            this.CellsForWalks.Clear();
            PointV2 tmpCoordinate;

            for (int i = 1; i <= CountStep; i++)
            {
                tmpCoordinate = new PointV2(this.position.x, this.position.y + i);
                if (GetStatusCell(tmpCoordinate) == CellStatus.VoidCell)
                {
                    CellsForWalks.Add(tmpCoordinate);
                }
                else
                {
                    break;
                }
            }

            tmpCoordinate = position + 1;
            if (isCellForAttack(tmpCoordinate))
            {
                CellsForAttacks.Add(tmpCoordinate);
                CellsForWalks.Add(tmpCoordinate);
            }

            tmpCoordinate = new PointV2(position.x - 1, position.y + 1);
            if (isCellForAttack(tmpCoordinate))
            {
                CellsForAttacks.Add(tmpCoordinate);
                CellsForWalks.Add(tmpCoordinate);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Формирует список доступных клеток для "Коня".
        /// </summary>
        protected override void FormulatedAvailableActions()
        {
            this.CellsForAttacks.Clear();
            this.CellsForWalks.Clear();
            PointV2[] dirList  = { PointV2.down, PointV2.left, PointV2.up, PointV2.right };
            PointV2   tmpPoint = new PointV2(this.position.x + 2, this.position.y + 2);

            foreach (var itemDirList in dirList)
            {
                for (int i = 1; i < 5; i++)
                {
                    tmpPoint += itemDirList;
                    if (i % 2 == 1 && GameBoard.Instance.isOnTheChessboard(tmpPoint))
                    {
                        if (GetStatusCell(tmpPoint) != side)
                        {
                            CellsForWalks.Add(tmpPoint);
                        }
                        if (base.isCellForAttack(tmpPoint))
                        {
                            CellsForAttacks.Add(tmpPoint);
                        }
                    }
                }
            }
        }