Ejemplo n.º 1
0
    public bool IntersectsWithCircle(ICircle aCircle)
    {
        float testX = aCircle.GetCenterX();
        float testY = aCircle.GetCenterY();

        if (aCircle.GetCenterX() < this.GetX())
        {
            testX = this.GetX();
        }
        else if (aCircle.GetCenterX() > this.GetX() + this.GetWidth())
        {
            testX = this.GetX() + this.GetWidth();
        }
        if (aCircle.GetCenterY() < this.GetY())
        {
            testY = this.GetY();
        }
        else if (aCircle.GetCenterY() > this.GetY() + this.GetHeight())
        {
            testY = this.GetY() + this.GetHeight();
        }

        float distanceX = aCircle.GetCenterX() - testX;
        float distanceY = aCircle.GetCenterY() - testY;
        float distance  = (int)Math.Sqrt((distanceX * distanceX) + (distanceY * distanceY));

        return(distance <= aCircle.GetRadius());
    }
Ejemplo n.º 2
0
    public bool IntersectsWithCircle(ICircle aCircle)
    {
        float distanceX = this.GetCenterX() - aCircle.GetCenterX();
        float distanceY = this.GetCenterY() - aCircle.GetCenterY();
        float distance  = (int)Math.Sqrt(distanceX * distanceX + distanceY * distanceY);

        return(distance <= this.GetRadius() + aCircle.GetRadius());
    }
        private IRectangle CalculateTargetBoundary(IShape aShape)
        {
            IRectangle targetBoundary;

            if (typeof(ICircle).IsAssignableFrom(aShape.GetType()))
            {
                ICircle circleUserObject = (ICircle)aShape;
                float   width            = circleUserObject.GetRadius() * 2;
                targetBoundary = new Rectangle(circleUserObject.GetCenterX() - circleUserObject.GetRadius(), circleUserObject.GetCenterY() - circleUserObject.GetRadius(), width,
                                               width);
            }
            else
            {
                targetBoundary = (IRectangle)aShape;
            }
            return(targetBoundary);
        }
Ejemplo n.º 4
0
 private void DrawCircle(ICircle aCircle)
 {
     UnityEditor.Handles.DrawWireDisc(new Vector3(aCircle.GetCenterX(), aCircle.GetCenterY(), 0), new Vector3(0, 0, 0.1f), aCircle.GetRadius());
 }