예제 #1
0
        public bool Collision(Vector2 pos, Obj obj)
        {
            Rectangle newArea = new Rectangle(area.X, area.Y, area.Width, area.Height);
            newArea.X += (int)pos.X;
            newArea.Y += (int)pos.Y;

            for (int i = 0; i < ObjList.objList.Count; i++)
                if (ObjList.objList[i].GetType() == obj.GetType() && ObjList.objList[i].Solid)
                    if (ObjList.objList[i].area.Intersects(newArea))
                        return true;

            return false;
        }
예제 #2
0
        public Obj Collision(Obj obj)
        {
            for (int i = 0; i < ObjList.objList.Count; i++)
                if (ObjList.objList[i].GetType() == obj.GetType() && ObjList.objList[i].alive)
                    if (ObjList.objList[i].area.Intersects(area))
                        return ObjList.objList[i];

            for (int i = 0; i < EnemySpawner.Enemies.Count; i++)
                if (EnemySpawner.Enemies[i].GetType() == obj.GetType() && EnemySpawner.Enemies[i].alive)
                    if (EnemySpawner.Enemies[i].area.Intersects(area))
                        return EnemySpawner.Enemies[i];

            return new Obj(Vector2.Zero);
        }