예제 #1
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static List<Entity> All(Collider a, List<Entity> b, List<Entity> into, Vector2 aPos)
 {
     Vector2 old = a.Position;
     a.Position = aPos;
     List<Entity> ret = All(a, b, into);
     a.Position = old;
     return ret;
 }
예제 #2
0
파일: Collide.cs 프로젝트: saint11/oldskull
        public static List<Entity> All(Collider a, List<Entity> b, List<Entity> into)
        {
            foreach (var e in b)
            {
                if (a.Collide(e))
                    into.Add(e);
            }

            return into;
        }
예제 #3
0
        private void DisplayBounds(Collider c, int bx, int by, int bw, int bh, Color color)
        {
            Rectangle rect;

            rect.Width  = 1;
            rect.Height = 1;
            for (int x = bx; x < bx + bw; x++)
            {
                rect.X = x;
                for (int y = by; y < by + bh; y++)
                {
                    rect.Y = y;
                    if (c.Collide(rect))
                    {
                        Draw.SpriteBatch.Draw(Draw.Pixel.Texture.Texture, rect, Draw.Pixel.ClipRect, color);
                        break;
                    }
                }
                for (int y = by + bh - 1; y >= by; y--)
                {
                    rect.Y = y;
                    if (c.Collide(rect))
                    {
                        Draw.SpriteBatch.Draw(Draw.Pixel.Texture.Texture, rect, Draw.Pixel.ClipRect, color);
                        break;
                    }
                }
            }
            for (int y = by; y < by + bh; y++)
            {
                rect.Y = y;
                for (int x = bx; x < bx + bw; x++)
                {
                    rect.X = x;
                    if (c.Collide(rect))
                    {
                        Draw.SpriteBatch.Draw(Draw.Pixel.Texture.Texture, rect, Draw.Pixel.ClipRect, color);
                        break;
                    }
                }
                for (int x = bx + bw - 1; x > bx; x--)
                {
                    rect.X = x;
                    if (c.Collide(rect))
                    {
                        Draw.SpriteBatch.Draw(Draw.Pixel.Texture.Texture, rect, Draw.Pixel.ClipRect, color);
                        break;
                    }
                }
            }
        }
예제 #4
0
        public override void Update()
        {
            base.Update();

            //if ((this.sprite.CurrentAnimID == "normal") && (hasArrow))
            //	this.sprite.Play("happy", false);

            if (this.Collidable)
            {
                Monocle.Collider collider = base.Collider;
                base.Collider = collider;
                base.Collider = this.arrowPickupHitbox;
                Monocle.Entity entity = base.CollideFirst(Monocle.GameTags.Arrow);
                if ((entity != null) && (entity as Arrow))
                {
                    ((MyArrow)entity).OnGhostCollect(this, false);
                }
                base.Collider = collider;
            }
        }
예제 #5
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static List<Entity> All(Collider a, List<Entity> b, Vector2 aPos)
 {
     return All(a, b, new List<Entity>(), aPos);
 }
예제 #6
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static List<Entity> All(Collider a, List<Entity> b)
 {
     return All(a, b, new List<Entity>());
 }
예제 #7
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static List<Entity> All(Collider a, List<Entity> b, List<Entity> into, float aX, float aY)
 {
     return All(a, b, into, new Vector2(aX, aY));
 }
예제 #8
0
        public override Collider Clone()
        {
            Collider[] clones = new Collider[colliders.Length];
            for (int i = 0; i < colliders.Length; i++)
                clones[i] = colliders[i].Clone();

            return new ColliderList(clones);
        }
예제 #9
0
 public bool Collide(Collider collider)
 {
     if (collider is Hitbox)
     {
         return Collide(collider as Hitbox);
     }
     else if (collider is Grid)
     {
         return Collide(collider as Grid);
     }
     else if (collider is ColliderList)
     {
         return Collide(collider as ColliderList);
     }
     else if (collider is Circle)
     {
         return Collide(collider as Circle);
     }
     else
         throw new Exception("Collisions against the collider type are not implemented!");
 }
예제 #10
0
파일: Collide.cs 프로젝트: saint11/oldskull
        public static Entity First(Collider a, List<Entity> b)
        {
            foreach (var e in b)
            {
                if (a.Collide(e))
                    return e;
            }

            return null;
        }
예제 #11
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static bool Check(Collider a, List<Entity> b, float aX, float aY)
 {
     return Check(a, b, new Vector2(aX, aY));
 }
예제 #12
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static bool Check(Collider a, List<Entity> b, Vector2 aPos)
 {
     Vector2 old = a.Position;
     a.Position = aPos;
     bool ret = Check(a, b);
     a.Position = old;
     return ret;
 }
예제 #13
0
파일: Collide.cs 프로젝트: saint11/oldskull
        public static bool Check(Collider a, List<Entity> b)
        {
            foreach (var e in b)
            {
                if (a.Collide(e))
                    return true;
            }

            return false;
        }
예제 #14
0
        public void Remove(params Collider[] toRemove)
        {
            #if DEBUG
            foreach (var c in toRemove)
            {
                if (!colliders.Contains(c))
                    throw new Exception("Removing a Collider from a ColliderList that does not contain it!");
                else if (c == null)
                    throw new Exception("Cannot remove a null Collider from a ColliderList.");
            }
            #endif

            Collider[] newColliders = new Collider[colliders.Length - toRemove.Length];
            int at = 0;
            foreach (var c in colliders)
            {
                if (!toRemove.Contains(c))
                {
                    newColliders[at] = c;
                    at++;
                }
            }
            colliders = newColliders;
        }
예제 #15
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static List<Entity> All(Collider a, List<Entity> b, float aX, float aY)
 {
     return All(a, b, new List<Entity>(), aX, aY);
 }
예제 #16
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static Entity First(Collider a, List<Entity> b, Vector2 aPos)
 {
     Vector2 old = a.Position;
     a.Position = aPos;
     Entity ret = First(a, b);
     a.Position = old;
     return ret;
 }
예제 #17
0
파일: Collide.cs 프로젝트: saint11/oldskull
 public static Entity First(Collider a, List<Entity> b, float aX, float aY)
 {
     return First(a, b, new Vector2(aX, aY));
 }
예제 #18
0
 public static void Rect(Collider collider, Color color)
 {
     Rect(collider.AbsoluteLeft, collider.AbsoluteTop, collider.Width, collider.Height, color);
 }
예제 #19
0
        public void Add(params Collider[] toAdd)
        {
            #if DEBUG
            foreach (var c in toAdd)
            {
                if (colliders.Contains(c))
                    throw new Exception("Adding a Collider to a ColliderList that already contains it!");
                else if (c == null)
                    throw new Exception("Cannot add a null Collider to a ColliderList.");
            }
            #endif

            Collider[] newColliders = new Collider[colliders.Length + toAdd.Length];
            for (int i = 0; i < colliders.Length; i++)
                newColliders[i] = colliders[i];
            for (int i = 0; i < toAdd.Length; i++)
            {
                newColliders[i + colliders.Length] = toAdd[i];
                toAdd[i].Added(Entity);
            }
            colliders = newColliders;
        }