Ejemplo n.º 1
0
        internal void RaiseOnCollisionCallbacks()
        {
            var collisionEventsNum = CoreObject.GetCollisionEventsNum();

            Collisions2DInfo.Clear();

            for (int index = 0; index < collisionEventsNum; index++)
            {
                var collisionEvent = CoreObject.GetCollisionEvent(index);
                var collision      = collisionEvent.GetCollision();

                var colliderA = asd.Particular.Dictionary.Get(Layer.CollidersMap, collision.GetColliderA().GetCreationId());
                var colliderB = asd.Particular.Dictionary.Get(Layer.CollidersMap, collision.GetColliderB().GetCreationId());

                Collider2D myCollider    = null;
                Collider2D theirCollider = null;

                if (myColliders.Contains(colliderA))
                {
                    myCollider    = colliderA;
                    theirCollider = colliderB;
                }
                else
                {
                    myCollider    = colliderB;
                    theirCollider = colliderA;
                }

                var collisionType = collisionEvent.GetCollisionType();

                var collisionInfo = new Collision2DInfo(myCollider, theirCollider, (CollisionType)collisionType);

                if (collisionType == swig.CollisionType.Enter)
                {
                    OnCollisionEnter(collisionInfo);
                }
                else if (collisionType == swig.CollisionType.Stay)
                {
                    OnCollisionStay(collisionInfo);
                }
                else if (collisionType == swig.CollisionType.Exit)
                {
                    OnCollisionExit(collisionInfo);
                }

                Collisions2DInfo.Add(collisionInfo);
            }
        }