예제 #1
0
        bool OnContact(Contact contact)
        {
            bool collisionAllowed = AllowCollisionsBetweenGroups(((FarActor)contact.FixtureA.Body.UserData).CollisionGroup, ((FarActor)contact.FixtureB.Body.UserData).CollisionGroup);
            bool eitherEntity = IsEntityGroup(((FarActor)contact.FixtureA.Body.UserData).CollisionGroup) || IsEntityGroup(((FarActor)contact.FixtureB.Body.UserData).CollisionGroup);

            if (!collisionAllowed && !eitherEntity)
            {
                return false;
            }

            if (null != BeginContact)
            {
                Collision collision = new Collision();
                collision.actor1 = (contact.FixtureA.Body.UserData as JabActor);
                collision.actor2 = (contact.FixtureB.Body.UserData as JabActor);

                BeginContact.Invoke(collision);
            }

            CollisionEvent ev = new CollisionEvent();
            ev.contactType = CollisionEvent.ContactType.ONCONTACT;
            ev._Actor1 = (contact.FixtureA.Body.UserData as JabActor);
            ev._Actor2 = (contact.FixtureB.Body.UserData as JabActor);

            Jabber.Util.EventManager.Get.SendEvent(ev);

            collisionAllowed = AllowCollisionsBetweenGroups(((FarActor)contact.FixtureA.Body.UserData).CollisionGroup, ((FarActor)contact.FixtureB.Body.UserData).CollisionGroup);
            if (eitherEntity || !collisionAllowed)
            {
                return false;
            }
            return true;
        }
예제 #2
0
        void ContactOver(Contact contact)
        {
            if (null != EndContact)
            {
                Collision collision = new Collision();
                collision.actor1 = (contact.FixtureA.Body.UserData as JabActor);
                collision.actor2 = (contact.FixtureB.Body.UserData as JabActor);
                base.EndContact.Invoke(collision);
                /*
                CollisionEvent ev = new CollisionEvent();
                ev.contactType = CollisionEvent.ContactType.AFTERCONTACT;
                ev._Actor1 = collision.actor1;
                ev._Actor2 = collision.actor2;

                Jabber.Util.EventManager.Get.SendEvent(ev);*/
            }

            CollisionEvent ev = new CollisionEvent();
            ev.contactType = CollisionEvent.ContactType.AFTERCONTACT;
            ev._Actor1 = (contact.FixtureA.Body.UserData as JabActor);
            ev._Actor2 = (contact.FixtureB.Body.UserData as JabActor);

            Jabber.Util.EventManager.Get.SendEvent(ev);
        }