Beispiel #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));
                }
            }
        }
Beispiel #2
0
 public RectBox GetActorBounds(Actor actor)
 {
     return actor.GetBoundingRect();
 }
Beispiel #3
0
        protected internal override void ProcessTouchDragged()
        {
            int dropX = 0;
            int dropY = 0;

            if (!locked)
            {
                bool moveActor = false;
                if (actorDrag)
                {
                    lock (objects)
                    {
                        dropX = this.input.GetTouchX() - this.GetScreenX();
                        dropY = this.input.GetTouchY() - this.GetScreenY();
                        if (dragActor == null)
                        {
                            dragActor = GetSynchronizedObject(dropX, dropY);
                        }
                        if (dragActor != null && dragActor.IsDrag())
                        {
                            lock (dragActor)
                            {
                                objects.SendToFront(dragActor);
                                RectBox rect = dragActor.GetBoundingRect();
                                int     dx   = (dropX - (rect.width / 2));
                                int     dy   = (dropY - (rect.height / 2));
                                if (dragActor.GetLLayer() != null)
                                {
                                    dragActor.SetLocation(dx, dy);
                                    dragActor.Drag(dropX, dropY);
                                    if (dragActor.actorListener != null)
                                    {
                                        dragActor.actorListener.Drag(dropX, dropY);
                                    }
                                }
                                moveActor = true;
                            }
                        }
                    }
                }
                if (!moveActor)
                {
                    lock (input)
                    {
                        dropX = this.input.GetTouchDX();
                        dropY = this.input.GetTouchDY();
                        if (IsNotMoveInScreen(dropX + this.X(), dropY + this.Y()))
                        {
                            return;
                        }
                        if (GetContainer() != null)
                        {
                            GetContainer().SendToFront(this);
                        }
                        this.Move(dropX, dropY);
                        this.Drag(dropX, dropY);
                    }
                }
            }
            else
            {
                if (!actorDrag)
                {
                    return;
                }
                lock (objects)
                {
                    dropX = this.input.GetTouchX() - this.GetScreenX();
                    dropY = this.input.GetTouchY() - this.GetScreenY();
                    if (dragActor == null)
                    {
                        dragActor = GetSynchronizedObject(dropX, dropY);
                    }
                    if (dragActor != null && dragActor.IsDrag())
                    {
                        lock (dragActor)
                        {
                            objects.SendToFront(dragActor);
                            RectBox rect = dragActor.GetBoundingRect();
                            int     dx   = (dropX - (rect.width / 2));
                            int     dy   = (dropY - (rect.height / 2));
                            if (dragActor.GetLLayer() != null)
                            {
                                dragActor.SetLocation(dx, dy);
                                dragActor.Drag(dropX, dropY);
                                if (dragActor.actorListener != null)
                                {
                                    dragActor.actorListener.Drag(dropX, dropY);
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #4
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);
         }
     }
 }
Beispiel #5
0
 public RectBox GetActorBounds(Actor actor)
 {
     return(actor.GetBoundingRect());
 }