Esempio n. 1
0
        public virtual bool Intersects(Actor other)
        {
            int thisBounds1;

            if (this.image == null)
            {
                if (other.image != null)
                {
                    thisBounds1 = this.gameLayer.GetCellSize();
                    return(other.ContainsPoint(location.X() * thisBounds1
                                               + thisBounds1 / 2, location.Y() * thisBounds1
                                               + thisBounds1 / 2));
                }
                else
                {
                    return(location.x == other.location.x &&
                           location.y == other.location.y);
                }
            }
            else if (other.image == null)
            {
                thisBounds1 = this.gameLayer.GetCellSize();
                return(this.ContainsPoint(other.location.X() * thisBounds1
                                          + thisBounds1 / 2, other.location.Y() * thisBounds1
                                          + thisBounds1 / 2));
            }
            else
            {
                RectBox thisBounds  = this.GetBoundingRect();
                RectBox otherBounds = other.GetBoundingRect();
                if (this.rotation == 0 && other.rotation == 0)
                {
                    return(thisBounds.Intersects(otherBounds));
                }
                else if (!thisBounds.Intersects(otherBounds))
                {
                    return(false);
                }
                else
                {
                    float[] myX    = this.xs;
                    float[] myY    = this.ys;
                    float[] otherX = other.xs;
                    float[] otherY = other.ys;
                    return((CheckOutside(myX, myY, otherX, otherY)) ? false
                        : !CheckOutside(otherX, otherY, myX, myY));
                }
            }
        }
Esempio n. 2
0
 public virtual bool Intersects(Actor other)
 {
     int thisBounds1;
     if (this.image == null)
     {
         if (other.image != null)
         {
             thisBounds1 = this.gameLayer.GetCellSize();
             return other.ContainsPoint(location.X() * thisBounds1
                     + thisBounds1 / 2, location.Y() * thisBounds1
                     + thisBounds1 / 2);
         }
         else
         {
             return location.x == other.location.x
                     && location.y == other.location.y;
         }
     }
     else if (other.image == null)
     {
         thisBounds1 = this.gameLayer.GetCellSize();
         return this.ContainsPoint(other.location.X() * thisBounds1
                 + thisBounds1 / 2, other.location.Y() * thisBounds1
                 + thisBounds1 / 2);
     }
     else
     {
         RectBox thisBounds = this.GetBoundingRect();
         RectBox otherBounds = other.GetBoundingRect();
         if (this.rotation == 0 && other.rotation == 0)
         {
             return thisBounds.Intersects(otherBounds);
         }
         else if (!thisBounds.Intersects(otherBounds))
         {
             return false;
         }
         else
         {
             float[] myX = this.xs;
             float[] myY = this.ys;
             float[] otherX = other.xs;
             float[] otherY = other.ys;
             return (CheckOutside(myX, myY, otherX, otherY)) ? false
                     : !CheckOutside(otherX, otherY, myX, myY);
         }
     }
 }
Esempio n. 3
0
 public bool CheckCollision(Actor actor)
 {
     return (this.cls != null && !this.cls.IsInstanceOfType(actor)) ? false : actor
             .ContainsPoint(this.x, this.y);
 }
Esempio n. 4
0
 public bool CheckCollision(Actor actor)
 {
     return((this.cls != null && !this.cls.IsInstanceOfType(actor)) ? false : actor
            .ContainsPoint(this.x, this.y));
 }