コード例 #1
0
        public bool Body_OnCollision(Fixture fixtureA, Fixture fixtureB, FarseerPhysics.Dynamics.Contacts.Contact contact)
        {
            SceneItem dataA = ((SceneItem)fixtureA.Body.UserData);
            SceneItem dataB = ((SceneItem)fixtureB.Body.UserData);

            if (HaveTheseCollided(dataA, dataB))
            {
                return(false);
            }

            CollisionComponent collisionComponentA = dataA.GetComponent <CollisionComponent>();
            CollisionComponent collisionComponentB = dataB.GetComponent <CollisionComponent>();

            if (collisionComponentA != null)
            {
                CollisionEventArgs eventArgs = new CollisionEventArgs();
                eventArgs.CollidedSceneItemA = dataB;
                eventArgs.CollidedSceneItemB = dataA;
                collisionComponentA.OnCollision(eventArgs);
            }
            if (collisionComponentB != null)
            {
                CollisionEventArgs eventArgs = new CollisionEventArgs();
                eventArgs.CollidedSceneItemA = dataA;
                eventArgs.CollidedSceneItemB = dataB;
                collisionComponentB.OnCollision(eventArgs);
            }

            OnScreenStats.AddStat(string.Format("BODY! {0} {1}", dataA.Name, dataB.Name));
            return(false);
        }