예제 #1
0
 public override List <GameFieldPoint> GetPointsUnderAttack(GameFieldPoint point)
 {
     return(GetPointsForStep(point));
 }
예제 #2
0
 public override List <GameFieldPoint> GetPointsUnderAttackFromPoint(GameFieldPoint point)
 {
     return(GetPointsForStepWithFromPoint(point));
 }
예제 #3
0
    public override List <GameFieldPoint> GetPointsForStep(GameFieldPoint point)
    {
        List <GameFieldPoint> pointsForDraw = new List <GameFieldPoint>();
        Vector2Int            newCell       = new Vector2Int(point.j, point.i);

        bool iCanMoveInThisDirection = true;

        while (iCanMoveInThisDirection) //вперёд вправо
        {
            newCell += new Vector2Int(1, 1);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //назад вправо
        {
            newCell += new Vector2Int(1, -1);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //назад влево
        {
            newCell += new Vector2Int(-1, -1);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //вперёд влево
        {
            newCell += new Vector2Int(-1, 1);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //вперёд
        {
            newCell += new Vector2Int(0, 1);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //назад
        {
            newCell += new Vector2Int(0, -1);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //вправо
        {
            newCell += new Vector2Int(1, 0);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }

        newCell = new Vector2Int(point.j, point.i);
        iCanMoveInThisDirection = true;
        while (iCanMoveInThisDirection) //влево
        {
            newCell += new Vector2Int(-1, 0);
            if (OpportunityToMove(newCell))
            {
                pointsForDraw.Add(gameField[newCell.y, newCell.x]);
                if (!IsEmptyCell(newCell))
                {
                    iCanMoveInThisDirection = false;
                }
            }
            else
            {
                iCanMoveInThisDirection = false;
            }
        }
        return(pointsForDraw);
    }