internal void Update(GameObject otherGO, Physics2D.Contact c)
        {
            if (this.gameObject == null)
            {
                this.gameObject = otherGO;
                this.collider   = this.gameObject.GetComponent <FPCollider2D>();
                this.rigidbody  = this.gameObject.GetComponent <FPRigidBody2D>();
                this.transform  = this.collider.FPTransform;
            }

            if (c != null)
            {
                if (contacts[0] == null)
                {
                    contacts[0] = new TSContactPoint2D();
                }

                FPVector2 normal;
                Physics2D.FixedArray2 <FPVector2> points;

                c.GetWorldManifold(out normal, out points);

                contacts[0].normal = normal;
                contacts[0].point  = points[0];

                this.relativeVelocity = c.CalculateRelativeVelocity();
            }
        }
Exemplo n.º 2
0
        private void CollisionExit(KBEngine.Physics2D.Contact contact)
        {
            if (contact.FixtureA.IsSensor || contact.FixtureB.IsSensor)
            {
                TriggerExit(contact);
                return;
            }

            CollisionDetected(contact.FixtureA.Body, contact.FixtureB.Body, null, "OnSyncedCollisionExit");
        }
Exemplo n.º 3
0
        private bool CollisionEnter(KBEngine.Physics2D.Contact contact)
        {
            if (contact.FixtureA.IsSensor || contact.FixtureB.IsSensor)
            {
                TriggerEnter(contact);

                return(true);
            }

            CollisionDetected(contact.FixtureA.Body, contact.FixtureB.Body, contact, "OnSyncedCollisionEnter");
            return(true);
        }
Exemplo n.º 4
0
        private void CollisionDetected(Physics2D.Body body1, Physics2D.Body body2, KBEngine.Physics2D.Contact contact, string callbackName)
        {
            if (!gameObjectMap.ContainsKey(body1) || !gameObjectMap.ContainsKey(body2))
            {
                return;
            }

            GameObject b1 = gameObjectMap[body1];
            GameObject b2 = gameObjectMap[body2];

            if (b1 == null || b2 == null)
            {
                return;
            }

            b1.SendMessage(callbackName, GetCollisionInfo(body1, body2, contact), SendMessageOptions.DontRequireReceiver);
            b2.SendMessage(callbackName, GetCollisionInfo(body2, body1, contact), SendMessageOptions.DontRequireReceiver);

//			FrameSyncManager.UpdateCoroutines ();
        }
Exemplo n.º 5
0
        private FPCollision2D GetCollisionInfo(Physics2D.Body body1, Physics2D.Body body2, KBEngine.Physics2D.Contact c)
        {
            if (!collisionInfo.ContainsKey(body1))
            {
                collisionInfo.Add(body1, new Dictionary <Physics2D.Body, FPCollision2D>());
            }

            Dictionary <Physics2D.Body, FPCollision2D> collisionInfoBody1 = collisionInfo[body1];

            FPCollision2D result = null;

            if (collisionInfoBody1.ContainsKey(body2))
            {
                result = collisionInfoBody1[body2];
            }
            else
            {
                result = new FPCollision2D();
                collisionInfoBody1.Add(body2, result);
            }

            result.Update(gameObjectMap[body2], c);

            return(result);
        }
Exemplo n.º 6
0
 private void TriggerExit(KBEngine.Physics2D.Contact contact)
 {
     CollisionDetected(contact.FixtureA.Body, contact.FixtureB.Body, null, "OnSyncedTriggerExit");
 }