Пример #1
0
    public bool within_arc(Vector2 current_grid_location, Vector2 grid_location)
    {
        var los = new LineOfSight(current_grid_location, grid_location, map);

        if (los.blocked())
        {
            return(false);
        }

        var dist = Mathf.Abs(current_grid_location.x - grid_location.x) + Mathf.Abs(current_grid_location.y - grid_location.y);

        if (dist > range)
        {
            return(false);
        }
        var distance = grid_location - current_grid_location;

        if (_direction == UP)
        {
            return(distance.y > 0 && Mathf.Abs(distance.x) <= Mathf.Abs(distance.y));
        }
        else if (_direction == DOWN)
        {
            return(distance.y < 0 && Mathf.Abs(distance.x) <= Mathf.Abs(distance.y));
        }
        else if (_direction == LEFT)
        {
            return(distance.x < 0 && Mathf.Abs(distance.y) <= Mathf.Abs(distance.x));
        }
        else
        {
            return(distance.x > 0 && Mathf.Abs(distance.y) <= Mathf.Abs(distance.x));
        }
    }