Example #1
0
        private void CollisionDetected(RigidBody body1, RigidBody body2, Contact c, string callbackName)
        {
            GameObject b1 = gameObjectMap[body1];
            GameObject b2 = gameObjectMap[body2];

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

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

            TrueSyncManager.UpdateCoroutines();
        }
        private void CollisionDetected(Physics2D.Body body1, Physics2D.Body body2, TrueSync.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);

            TrueSyncManager.UpdateCoroutines();
        }
Example #3
0
        private void CollisionDetected(RigidBody body1, RigidBody body2, Contact c, string callbackName)
        {
            if (!gameObjectMap.ContainsKey(body1) || !gameObjectMap.ContainsKey(body2))
            {
                return;
            }

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

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

            TSCollision collision = null;
            HashList <TrueSyncBehaviour> b1Behaviours = behavioursMap[body1];

            collision = GetCollisionInfo(body1, body2, c);
            for (int i = 0, count = b1Behaviours.Count; i < count; i++)
            {
                if (String.Equals(callbackName, "OnSyncedCollisionEnter", StringComparison.InvariantCultureIgnoreCase))
                {
                    b1Behaviours[i].OnSyncedCollisionEnter(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedCollisionStay", StringComparison.InvariantCultureIgnoreCase))
                {
                    b1Behaviours[i].OnSyncedCollisionStay(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedCollisionExit", StringComparison.InvariantCultureIgnoreCase))
                {
                    b1Behaviours[i].OnSyncedCollisionExit(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedTriggerEnter", StringComparison.InvariantCultureIgnoreCase))
                {
                    b1Behaviours[i].OnSyncedTriggerEnter(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedTriggerStay", StringComparison.InvariantCultureIgnoreCase))
                {
                    b1Behaviours[i].OnSyncedTriggerStay(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedTriggerExit", StringComparison.InvariantCultureIgnoreCase))
                {
                    b1Behaviours[i].OnSyncedTriggerExit(collision);
                }
            }

            HashList <TrueSyncBehaviour> b2Behaviours = behavioursMap[body2];

            collision = GetCollisionInfo(body2, body1, c);
            for (int i = 0, count = b2Behaviours.Count; i < count; i++)
            {
                if (String.Equals(callbackName, "OnSyncedCollisionEnter", StringComparison.InvariantCultureIgnoreCase))
                {
                    b2Behaviours[i].OnSyncedCollisionEnter(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedCollisionStay", StringComparison.InvariantCultureIgnoreCase))
                {
                    b2Behaviours[i].OnSyncedCollisionStay(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedCollisionExit", StringComparison.InvariantCultureIgnoreCase))
                {
                    b2Behaviours[i].OnSyncedCollisionExit(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedTriggerEnter", StringComparison.InvariantCultureIgnoreCase))
                {
                    b2Behaviours[i].OnSyncedTriggerEnter(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedTriggerStay", StringComparison.InvariantCultureIgnoreCase))
                {
                    b2Behaviours[i].OnSyncedTriggerStay(collision);
                }
                else if (String.Equals(callbackName, "OnSyncedTriggerExit", StringComparison.InvariantCultureIgnoreCase))
                {
                    b2Behaviours[i].OnSyncedTriggerExit(collision);
                }
            }

            TrueSyncManager.UpdateCoroutines();
        }