Пример #1
0
        // An Inner Tile Impact checks for an additional, inner collision based on a designated rectangle.
        public static DirCardinal RunInnerImpact(GameObject actor, int x1, int x2, int y1, int y2)
        {
            // Check Overlap with Altered Border
            if (!CollideRect.IsTouchingRect(actor, x1, x2, y1, y2))
            {
                return(DirCardinal.None);
            }

            DirCardinal newDir = CollideRect.GetDirectionOfCollision(actor, x1, x2, y1, y2);

            if (newDir == DirCardinal.Down)
            {
                actor.CollidePosDown(y1 - actor.bounds.Bottom);
            }
            else if (newDir == DirCardinal.Right)
            {
                actor.CollidePosRight(x1 - actor.bounds.Right);
            }
            else if (newDir == DirCardinal.Left)
            {
                actor.CollidePosLeft(x2 - actor.bounds.Left);
            }
            else if (newDir == DirCardinal.Up)
            {
                actor.CollidePosUp(y2 - actor.bounds.Top);
            }

            return(newDir);
        }
Пример #2
0
 // Identical to RunInnerImpact, except it doesn't collide.
 public static DirCardinal RunOverlapTest(GameObject actor, int x1, int x2, int y1, int y2)
 {
     if (!CollideRect.IsTouchingRect(actor, x1, x2, y1, y2))
     {
         return(DirCardinal.None);
     }
     return(CollideRect.GetDirectionOfCollision(actor, x1, x2, y1, y2));
 }