Ejemplo n.º 1
0
 public virtual Vector2 CheckColCircle(ColCircle other)
 {
     return(Vector2.Zero);
 }
Ejemplo n.º 2
0
        public override Vector2 CheckColCircle(ColCircle other)
        {
            if (CheckColBounds(other))
            {
                if (other.Center.X > this.TL.X &&
                    other.Center.X < this.BR.X)
                {
                    if (other.Center.Y > this.Center.Y)
                    {
                        return(new Vector2(0.0f, other.Center.Y - other.Rad - this.TL.Y));
                    }
                    if (other.Center.Y < this.Center.Y)
                    {
                        return(new Vector2(0.0f, other.Center.Y + other.Rad - this.BR.Y));
                    }
                }
                if (other.Center.Y < this.BR.Y + leeway && other.Center.Y > this.TL.Y - leeway)
                {
                    if (other.Center.X > this.Center.X)
                    {
                        return(new Vector2(other.Center.X - other.Rad - this.TL.X, 0.0f));
                    }
                    if (other.Center.X < this.Center.X)
                    {
                        return(new Vector2(other.Center.X + other.Rad - this.BR.X, 0.0f));
                    }
                }

                Vector2 dist;
                dist = new Vector2(TL.X + leeway, BR.Y + leeway) - other.Center;
                float mag = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }

                dist = new Vector2(BR.X - leeway, BR.Y + leeway) - other.Center;
                mag  = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }

                dist = new Vector2(TL.X + leeway, TL.Y - leeway) - other.Center;
                mag  = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }

                dist = new Vector2(BR.X - leeway, TL.Y - leeway) - other.Center;
                mag  = dist.Length();
                dist.Normalize();
                if (mag < other.Rad)
                {
                    return(-dist * (other.Rad - mag));
                }
            }

            return(Vector2.Zero);
        }