Beispiel #1
0
    bool OnCollisionEvent(Fixture A, Fixture B, Contact contact)
    {
        /*if (contact.IsTouching() && A.Body.UserTag == "Player") {
            A.Body.ApplyLinearImpulse(new FVector2(0, jumpFactor));
            ////Debug.Log("A: " + A.Body.LinearVelocity);

            /* Play jumping sound. *
            Player attachedPlayer = GameObject.FindWithTag("Player").GetComponent<Player>();
            attachedPlayer.sfxPlayer.clip = attachedPlayer.jumpSound;
            attachedPlayer.sfxPlayer.loop = false;
            /* Give some variation to the jump pitch. *
            if (!attachedPlayer.NearVortex()) {
                attachedPlayer.sfxPlayer.pitch = 1.0f + 0.02f*UnityEngine.Random.Range(-11, 6);
            }
            attachedPlayer.sfxPlayer.Play();
        }
        else*/ if (contact.IsTouching() && B.Body.UserTag == "Player") {
            B.Body.ApplyLinearImpulse(new FVector2(0, jumpFactor));
            ////Debug.Log("B: " + B.Body.LinearVelocity);

            /* Play jumping sound. */
            Player attachedPlayer = GameObject.FindWithTag("Player").GetComponent<Player>();
            attachedPlayer.sfxPlayer.clip = attachedPlayer.jumpSound;
            attachedPlayer.sfxPlayer.loop = false;
            /* Give some variation to the jump pitch. */
            if (!attachedPlayer.NearVortex()) {
                attachedPlayer.sfxPlayer.pitch = 1.0f + 0.02f*UnityEngine.Random.Range(-11, 6);
            }
            attachedPlayer.sfxPlayer.Play();
        }

        return true;
    }
Beispiel #2
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            Vector2 movementBefore = body.LinearVelocity;
            body.LinearVelocity = new Vector2(body.LinearVelocity.X, 0);
            Block block=null;
            foreach (Entity e in game.entities)
            {
                if (e is Block)
                {
                    Block b = (Block)e;
                    if(b.fixture.Equals(fixtureB))
                    {
                        block = b;
                    }

                }
            }

            if (contact.IsTouching())
            {
                if (isMagnet(fixtureB))
                    return true;
                Manifold colis = new Manifold();
                contact.GetManifold(out colis);
                Vector2 pColis = colis.LocalNormal;
                if (pColis.X == 0 && pColis.Y == 1)
                {
                    onGround = true;
                    modes = Modes.GROUND;
                    return true;

                }
                if (pColis.X != 0 && pColis.Y == 0)
                {

                    collisionRec = getBlockFromFixture(fixtureB);

                    if (fixtureB.Body.Rotation % 45 != 0)
                    {
                        onGround = true;
                        modes = Modes.GROUND;
                        return false;
                    }
                    if (onGround)
                    {
                        modes = Modes.WALL;
                        return false;
                    }

                    float direction = inputState.GetJoyDirection();
                    float x = (float)Math.Sin(direction);
                    if (pColis.X > 0)
                        isWallOnRight = true;
                    else
                        isWallOnRight = false;

                    float xMomentum = 0;
                    if (movementBefore.Y > 0)
                    {
                        xMomentum = Math.Abs(body.LinearVelocity.X * 0.3f);
                    }
                    else if (movementBefore.Y < 0)
                    {
                        xMomentum = -Math.Abs(body.LinearVelocity.X * 0.8f);
                    }
                    XboxInput xbi = (XboxInput)inputState;
                    if (xbi.getYDirection() < 0 || Keyboard.GetState().IsKeyDown(Keys.Up) || Keyboard.GetState().IsKeyDown(Keys.W))
                        xMomentum += xbi.getYDirection() * 4f;
                    else
                        xMomentum = 0;
                    body.LinearVelocity = new Vector2(0, body.LinearVelocity.Y + xMomentum);
                    //body.IgnoreGravity = true;
                    onGround = true;
                    onGround = true;
                    modes = Modes.WALL;
                    ignoreInput = 2;
                    return false;
                }

            }
            return true;
        }
        internal void Destroy(Contact contact)
        {
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            Body bodyA = fixtureA.Body;
            Body bodyB = fixtureB.Body;

            if (EndContact != null && contact.IsTouching())
            {
                EndContact(contact);
            }

            // Remove from the world.
            if (contact.Prev != null)
            {
                contact.Prev.Next = contact.Next;
            }

            if (contact.Next != null)
            {
                contact.Next.Prev = contact.Prev;
            }

            if (contact == ContactList)
            {
                ContactList = contact.Next;
            }

            // Remove from body 1
            if (contact.NodeA.Prev != null)
            {
                contact.NodeA.Prev.Next = contact.NodeA.Next;
            }

            if (contact.NodeA.Next != null)
            {
                contact.NodeA.Next.Prev = contact.NodeA.Prev;
            }

            if (contact.NodeA == bodyA.ContactList)
            {
                bodyA.ContactList = contact.NodeA.Next;
            }

            // Remove from body 2
            if (contact.NodeB.Prev != null)
            {
                contact.NodeB.Prev.Next = contact.NodeB.Next;
            }

            if (contact.NodeB.Next != null)
            {
                contact.NodeB.Next.Prev = contact.NodeB.Prev;
            }

            if (contact.NodeB == bodyB.ContactList)
            {
                bodyB.ContactList = contact.NodeB.Next;
            }

            contact.Destroy();

            --ContactCount;
        }
Beispiel #4
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (contact.IsTouching())
            {
                LinkedList<PlayableCharacter> players = game.getEntitiesOfType<PlayableCharacter>();
                if (players.Count == 0)
                    return false;
                PlayableCharacter player = players.First();
                if (fixtureB == player.fixture)
                {
                    Vector2 magneticForce;
                    if(!isFan)
                        magneticForce=magnetPulse * game.magValue;
                    else
                        magneticForce=magnetPulse;
                    if (magneticForce.X != 0)
                    {
                        player.body.LinearVelocity = new Vector2(magneticForce.X, player.body.LinearVelocity.Y);

                    }
                    else
                    {
                        player.body.LinearVelocity = new Vector2(player.body.LinearVelocity.X, magneticForce.Y);

                    }
                    if (!isInMagnet)
                    {
                        /*
                        if(magnetPulse.X!=0)
                            player.body.LinearVelocity = new Vector2(0, body.LinearVelocity.Y);
                        else
                            player.body.LinearVelocity = new Vector2(body.LinearVelocity.X, 0);
                        isInMagnet = true;
                         * */

                    }
                    //player.body.IgnoreGravity = true;
                    return !isMagnet;
                }
            }
            return true;
        }
        /// <summary>
        /// Called when a collision with the platform occurs.
        /// </summary>
        /// <param name="fixtureA">The first fixture that has collided.</param>
        /// <param name="fixtureB">The second fixture that has collided.</param>
        /// <param name="contact">The Contact object that contains information about the collision.</param>
        /// <returns>Whether the collision should still happen.</returns>
        private bool HandleCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            // Check if one of the Fixtures belongs to a ball.
              bool causedByBall = (string)fixtureA.Body.UserData == "ball" || (string)fixtureB.Body.UserData == "ball";

              if (contact.IsTouching() && causedByBall) {
            bool shouldCollisionOccur = false;

            // A ball should only bounce off a breakable platform once.
            if (_breakable && _visible) {
              Break();
              // Don't collide with the ball anymore.
              _body.CollidesWith = Category.All & ~Category.Cat1;
              shouldCollisionOccur = true;
              // Don't bounce off broken platforms.
            } else if (_breakable && !_visible) {
              shouldCollisionOccur = false;
              // Always bounce off regular platforms.
            } else {
              shouldCollisionOccur = true;
            }

            // Call the methods listening for collision events.
            if (OnPlatformCollision != null && shouldCollisionOccur) {
              OnPlatformCollision(_breakable);
            }
            // Tell the physics engine the intended result.
            return shouldCollisionOccur;
              } else {
            // Otherwise, if it's not caused by a ball, then ignore the collision.
            return false;
              }
        }
Beispiel #6
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (contact.IsTouching())
            {
                LinkedList<PlayableCharacter> players = game.getEntitiesOfType<PlayableCharacter>();

                PlayableCharacter player = players.First();
                if (fixtureB == player.fixture)
                {
                    if (game.gMode != 2)
                    {
                        game.sounds["Rage//Wave//explosion"].Play();
                        game.PlayerDies();
                    }
                }
                else
                {
                    //Destroy block
                    //SetUpPhysics(Constants.player1SpawnLocation+origPos);
                    //body.SetTransform(ConvertUnits.ToSimUnits(pos), 0);
                    //Vector2 possi=ConvertUnits.ToSimUnits(pos);
                    //body.SetTransformIgnoreContacts(ref possi, 0);
                    //body.Awake = true;
                    //body.ApplyForce(new Vector2(1, 0));
                    //body.LinearVelocity=new Vector2(1, 0);
                    telePort = true;

                }
            }
            return true;
        }
Beispiel #7
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (IsVisible)
            {
                if (contact.IsTouching())
                {
                    LinkedList<PlayableCharacter> players = game.getEntitiesOfType<PlayableCharacter>();
                    if (players.Count == 0)
                        return false;
                    PlayableCharacter player = players.First();
                    if (fixtureB == player.fixture)
                    {
                        if (game.gMode != 2)
                        {
                            game.sounds["Rage//Wave//explosion"].Play();
                            game.PlayerDies();
                        }
                    }
                    else
                    {
                        explosion();

                    }
                }
            }
            return true;
        }
Beispiel #8
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (contact.IsTouching())
            {

            }
            return true;
        }
Beispiel #9
0
        /// <summary>
        /// コリジョン発生イベント ハンドラー
        /// </summary>
        /// <param name="fixtureA">フィクスチャーA (自分)</param>
        /// <param name="fixtureB">フィクスチャーB (衝突相手)</param>
        /// <param name="contact">コンタクト情報</param>
        /// <returns></returns>
        private bool CollisionEnterEventHandler(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            var phy = Physics2D.GetInstance ();

            var a = fixtureA.UserData as PhysicsBody;
            var b = fixtureB.UserData as PhysicsBody;
            if (a.body == null || b.body == null) {
                // メモ:
                // Bodyを Dispose してもただちに無効化されるわけではなく、
                // 同ステップではイベント ハンドラーも含めてまだ有効。
                // ここでチェックしてお帰りいただく必要がある。
                return false;
            }

            if (((a.CollisionMask & b.GroupID) == 0) || ((b.CollisionMask & a.GroupID) == 0)) {
                return false;
            }

            XnaVector2 normal;   // A --> B
            FixedArray2<XnaVector2> points;
            contact.GetWorldManifold (out normal, out points);

            var count = contact.Manifold.PointCount;
            if (count == 0 && contact.IsTouching ()) {
                // センサー(トリガー)モードの時、
                // count=0 かつ Manifold は未定義
                var cp = new ContactPoint (b, new Vector3 (0, 0, 0), new Vector3 (0, 0, 0));
                foreach (var comp in Node.Components) {
                    comp.OnCollisionEnter (cp);
                }
            }
            else if (count == 1) {
                var p = new Vector3 (points[0].X * phy.PPM, points[0].Y * phy.PPM, 0);
                var n = new Vector3 (normal.X, normal.Y, 0);
                var cp = new ContactPoint (b, p, n);
                foreach (var comp in Node.Components) {
                    comp.OnCollisionEnter (cp);
                }
            }
            else if (count == 2) {
                var p = new Vector3 ((points[0].X + points[1].X) / 2.0f * phy.PPM, (points[0].Y + points[1].Y) / 2.0f * phy.PPM, 0);
                var n = new Vector3 (normal.X, normal.Y, 0);
                var cp = new ContactPoint (b, p, n);
                foreach (var comp in Node.Components) {
                    comp.OnCollisionEnter (cp);
                }
            }

            return true;
        }
Beispiel #10
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (contact.IsTouching())
            {
                LinkedList<PlayableCharacter> players = game.getEntitiesOfType<PlayableCharacter>();
                if (players.Count == 0)
                    return false;

                PlayableCharacter player = players.First();
                if (fixtureB == player.fixture)
                {
                    if (!game.testLevel)
                    {
                        this.IsVisible = false;
                        game.numDeath = 0;
                        game.nextLevel(nextLevel++);
                    }
                }
                else
                {
                    if(game.deathBlockGoalCollision)
                        game.PlayerDies();
                }
            }
            return true;
        }
        /// <summary>
        /// Called when a collision with a wall occurs.
        /// </summary>
        /// <param name="fixtureA">The first fixture that has collided.</param>
        /// <param name="fixtureB">The second fixture that has collided.</param>
        /// <param name="contact">The Contact object that contains information about the collision.</param>
        /// <returns>Whether the collision should still happen.</returns>
        private bool HandleWallCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            // Check if one of the Fixtures belongs to a ball.
              bool causedByBall = (string)fixtureA.Body.UserData == "ball" || (string)fixtureB.Body.UserData == "ball";

              // A subtle fact about the OnCollision event is that it is only called
              // when the associated Contact object is changed from not-touching to touching.
              // While two objects are still touching each other, OnCollision won't be called again.
              if (contact.IsTouching() && causedByBall) {
            // Call any methods that are listening to this event.
            if (OnWallCollision != null) {
              OnWallCollision();
            }
            // The ball's trajectory should definitely be affected by the wall, so tell
            // the physics engine that by returning true.
            return true;
              }
              // If it's not a ball, then we don't really need to worry about it. Hopefully.
              return false;
        }
Beispiel #12
0
        public void PreSolve(Contact contact, ref Manifold manifold)
        {
            EventSystem eventSystem = (EventSystem)_systemManager.getSystem(SystemType.Event);
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            int playerId = PlayerSystem.PLAYER_ID;
            int entityA = (int)fixtureA.Body.UserData;
            int entityB = (int)fixtureB.Body.UserData;
            string levelUid = LevelSystem.currentLevelUid;

            // Check for custom collision filters
            bool fixtureAIgnoresEntityB = fixtureA.IsIgnoredEntity(entityB);
            bool fixtureBIgnoresEntityA = fixtureB.IsIgnoredEntity(entityA);
            if (fixtureAIgnoresEntityB)
                contact.Enabled = false;
            else if (fixtureBIgnoresEntityA)
                contact.Enabled = false;

            // Check for item pickup
            if (contact.IsTouching() && (entityA == playerId || entityB == playerId))
            {
                int itemEntityId = entityA == playerId ? entityB : entityA;
                Fixture fixture = entityA == playerId ? fixtureB : fixtureA;
                ItemComponent itemComponent = _entityManager.getComponent(levelUid, itemEntityId, ComponentType.Item) as ItemComponent;

                if (itemComponent != null)
                {
                    contact.Enabled = false;
                    if (itemComponent.state.inWorld)
                    {
                        InventoryComponent playerInventory = _entityManager.getComponent(levelUid, playerId, ComponentType.Inventory) as InventoryComponent;
                        EquipmentSystem equipmentSystem = _systemManager.getSystem(SystemType.Equipment) as EquipmentSystem;

                        equipmentSystem.addInventoryItem(playerInventory, itemComponent);
                        itemComponent.state.inWorld = false;
                        _bodiesToRemove.Add(fixture.Body);
                        _entityManager.killEntity(levelUid, itemEntityId);
                        eventSystem.postEvent(new GameEvent(GameEventType.OnItemPickedUp, itemEntityId));
                    }
                }
            }
        }
 private void PostSolve(Contact contact, ContactConstraint contactConstraint)
 {
     if (contact.IsTouching())
     {
         float maxImpulse = 0.0f;
         for (int i = 0; i < contactConstraint.Manifold.PointCount; ++i)
             maxImpulse = Math.Max(maxImpulse, contactConstraint.Manifold.Points[i].NormalImpulse);
         if (maxImpulse >= 12)
         {
             IGameObject aGameObj = contactConstraint.BodyA.UserData as IGameObject,
                         bGameObj = contactConstraint.BodyB.UserData as IGameObject;
             if (aGameObj != null)
             {
                 aGameObj.Health -= maxImpulse;
                 if (aGameObj.Health <= 0)
                 {
                     RemoveObject(aGameObj);
                 }
             }
             if (bGameObj != null)
             {
                 bGameObj.Health -= maxImpulse;
                 if (bGameObj.Health <= 0)
                 {
                     RemoveObject(bGameObj);
                 }
             }
         }
     }
 }
Beispiel #14
0
        bool DamageCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            Vector2 colNormal = contact.Manifold.LocalNormal;
            Vector2 aMomentum = fixtureA.Body.LinearVelocity;
            Vector2 bMomentum = fixtureB.Body.LinearVelocity * fixtureB.Body.Mass;

            float damage = Math.Abs(Vector2.Dot(aMomentum, colNormal) - Vector2.Dot(bMomentum, colNormal));
            damage = (damage < 15f ? 0 : damage); // Min damage = 15

            health[fixtureA.Body] -= damage / 200f; // Subject to change

            return contact.IsTouching();
        }
Beispiel #15
0
 private bool ResetCollisionCategory(Fixture fixA, Fixture fixB, Contact contact)
 {
     gun.CollisionCategories = Category.All & ~Category.Cat1;
     gun.CollidesWith = Category.All & ~Category.Cat1;
     return contact.IsTouching();
 }
        /// <summary>
        /// Called when a collision with the treasure occurs.
        /// </summary>
        /// <param name="fixtureA">The first fixture that has collided.</param>
        /// <param name="fixtureB">The second fixture that has collided.</param>
        /// <param name="contact">The Contact object that contains information about the collision.</param>
        /// <returns>Whether the collision should still happen.</returns>
        private bool HandleCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            // Check if one of the Fixtures belongs to a ball.
              bool causedByBall = (string)fixtureA.Body.UserData == "ball" || (string)fixtureB.Body.UserData == "ball";

              // Only mark the treasure as collected if a ball collided with it for the first time.
              // OnCollision doesn't get called again while the two objects are still touching, though.
              if (contact.IsTouching() && causedByBall && !_collected) {
            Collect();
              }
              // A treasure isn't an object that should be bounced off of, so don't actually
              // cause the collision to happen in the physics simulation.
              return false;
        }
Beispiel #17
0
 private bool OnGroundCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
 {
     Vector2 normal = contact.Manifold.LocalNormal;
     if (normal.X == 0 || normal.Y / normal.X > 1)
         onGround = true;
     return contact.IsTouching();
 }
        /// <summary>
        /// Called when a collision with the goal occurs.
        /// </summary>
        /// <param name="fixtureA">The first fixture that has collided.</param>
        /// <param name="fixtureB">The second fixture that has collided.</param>
        /// <param name="contact">The Contact object that contains information about the collision.</param>
        /// <returns>Whether the collision should still happen.</returns>
        private bool HandleCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            // Check if one of the Fixtures belongs to a ball.
              bool causedByBall = (string)fixtureA.Body.UserData == "ball" || (string)fixtureB.Body.UserData == "ball";

              // A subtle fact about the OnCollision event is that it is only called
              // when the associated Contact object is changed from not-touching to touching.
              // While two objects are still touching each other, OnCollision won't be called again.
              if (contact.IsTouching() && causedByBall) {
            // Call any methods that are listening to this event.
            if (OnGoalCollision != null) {
              OnGoalCollision();
            }
              }
              // A goal isn't an object that should be bounced off of, so don't actually
              // cause the collision to happen in the physics simulation.
              return false;
        }
Beispiel #19
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (contact.IsTouching())
            {
                LinkedList<PlayableCharacter> players = game.getEntitiesOfType<PlayableCharacter>();

                PlayableCharacter player = players.First();
                if (fixtureB == player.fixture)
                {
                    game.world.Gravity = new Vector2(0, 2.5f);
                    fixtureB.CollisionFilter.IgnoreCollisionWith(fixtureA);
                    fixtureA.CollisionFilter.IgnoreCollisionWith(fixtureB);
                    game.inWater = true;
                    game.waterCollisionTime = 15;
                    return true;

                }
            }
            return false;
        }
Beispiel #20
0
        bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
        {
            if (contact.IsTouching())
            {
                 LinkedList<PlayableCharacter> players=game.getEntitiesOfType<PlayableCharacter>();
                 if (players.Count == 0)
                     return false;

                 PlayableCharacter player = players.First();
                 if (fixtureB == player.fixture)
                 {
                     //game.sounds["Rage//Wave//Rage" + game.ran.Next(1, 2)].Play();
                     if (!game.testLevel)
                     {
                         game.PlayerDies();
                         game.sounds["Rage//Wave//death"].Play();
                         game.playRandomDeathSound();
                     }
                     //game.playSong("Rage//Rage"+game.ran.Next(1,8));

                 }
            }
            return true;
        }
        internal void Destroy(Contact contact)
        {
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            Body bodyA = fixtureA.Body;
            Body bodyB = fixtureB.Body;

            if (contact.IsTouching())
            {
                //Report the separation to both participants:
                if (bodyA != null) bodyA.OnSeparation(fixtureA, fixtureB);

                //Reverse the order of the reported fixtures. The first fixture is always the one that the
                //user subscribed to.
                if (bodyB != null) bodyB.OnSeparation(fixtureB, fixtureA);

                if (EndContact != null) EndContact(contact);
            }

            // Remove from the world.
            ContactList.Remove(contact);

            // Remove from body 1
            if (contact.NodeA.Prev != null)
            {
                contact.NodeA.Prev.Next = contact.NodeA.Next;
            }

            if (contact.NodeA.Next != null)
            {
                contact.NodeA.Next.Prev = contact.NodeA.Prev;
            }

            if (contact.NodeA == bodyA.ContactList)
            {
                bodyA.ContactList = contact.NodeA.Next;
            }

            // Remove from body 2
            if (contact.NodeB.Prev != null)
            {
                contact.NodeB.Prev.Next = contact.NodeB.Next;
            }

            if (contact.NodeB.Next != null)
            {
                contact.NodeB.Next.Prev = contact.NodeB.Prev;
            }

            if (contact.NodeB == bodyB.ContactList)
            {
                bodyB.ContactList = contact.NodeB.Next;
            }

            contact.Destroy();
        }
Beispiel #22
0
        protected virtual bool onCollision(Fixture f1, Fixture f2, Contact contact)
        {
            Fixture obstacle = (f1  == PhysicsBody) ? f2 : f1;

            //if beneath the feet, treat it as ground
            WorldManifold manifold;
            contact.GetWorldManifold(out manifold);
            if (contact.IsTouching())
            {
                if (isGround(manifold, obstacle))
                {
                    ground.Add(obstacle);
                    groundNormal = manifold.Normal;
                    groundVector = getGroundVector();
                    groundSlope = groundVector.Y / groundVector.X;
                    //Console.Out.WriteLine("OnCollision called");
                }
            }
            return true;
        }
Beispiel #23
0
        internal void Destroy(Contact contact, int index)
        {
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            Body bodyA = fixtureA.Body;
            Body bodyB = fixtureB.Body;

            if (EndContact != null && contact.IsTouching())
            {
                EndContact(contact);
            }

            // Remove from the world.
            if (index == -1)
                ContactList.Remove(contact);
            else
                ContactList.RemoveAt(index);

            // Remove from body 1
            if (contact.NodeA.Prev != null)
            {
                contact.NodeA.Prev.Next = contact.NodeA.Next;
            }

            if (contact.NodeA.Next != null)
            {
                contact.NodeA.Next.Prev = contact.NodeA.Prev;
            }

            if (contact.NodeA == bodyA.ContactList)
            {
                bodyA.ContactList = contact.NodeA.Next;
            }

            // Remove from body 2
            if (contact.NodeB.Prev != null)
            {
                contact.NodeB.Prev.Next = contact.NodeB.Next;
            }

            if (contact.NodeB.Next != null)
            {
                contact.NodeB.Next.Prev = contact.NodeB.Prev;
            }

            if (contact.NodeB == bodyB.ContactList)
            {
                bodyB.ContactList = contact.NodeB.Next;
            }

            contact.Destroy();
        }
Beispiel #24
0
 bool OnCollision(Fixture fixtureA, Fixture fixtureB, Contact contact)
 {
     if (contact.IsTouching())
     {
         if (disappearTimer < 0)
             return true;
         if (!isDisappearing)
         {
             stopWatch.Start();
             isDisappearing = true;
         }
     }
     return true;
 }
        internal void Destroy(Contact contact)
        {
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            Body bodyA = fixtureA.Body;
            Body bodyB = fixtureB.Body;

            if (EndContact != null && contact.IsTouching())
            {
                EndContact(contact);
            }

            // Remove from the world.
            ContactList.Remove(contact);

            // Remove from body 1
            if (contact.NodeA.Prev != null)
            {
                contact.NodeA.Prev.Next = contact.NodeA.Next;
            }

            if (contact.NodeA.Next != null)
            {
                contact.NodeA.Next.Prev = contact.NodeA.Prev;
            }

            if (contact.NodeA == bodyA.ContactList)
            {
                bodyA.ContactList = contact.NodeA.Next;
            }

            // Remove from body 2
            if (contact.NodeB.Prev != null)
            {
                contact.NodeB.Prev.Next = contact.NodeB.Next;
            }

            if (contact.NodeB.Next != null)
            {
                contact.NodeB.Next.Prev = contact.NodeB.Prev;
            }

            if (contact.NodeB == bodyB.ContactList)
            {
                bodyB.ContactList = contact.NodeB.Next;
            }

#if USE_ACTIVE_CONTACT_SET
			if (ActiveContacts.Contains(contact))
			{
				ActiveContacts.Remove(contact);
			}
#endif
			contact.Destroy();
        }
Beispiel #26
0
        internal void Destroy(Contact contact)
        {
            Fixture fixtureA = contact.FixtureA;
            Fixture fixtureB = contact.FixtureB;
            Body bodyA = fixtureA.Body;
            Body bodyB = fixtureB.Body;

            if (EndContact != null && contact.IsTouching())
            {
                EndContact(contact);
            }
            else
            {
                PressPlay.FFWD.Debug.Log("Destroying contact that is not touching: " + contact.FixtureA.Body.UserData + " <=> " + contact.FixtureB.Body.UserData);
            }

            // Remove from the world.
            ContactList.Remove(contact);

            // Remove from body 1
            if (contact.NodeA.Prev != null)
            {
                contact.NodeA.Prev.Next = contact.NodeA.Next;
            }

            if (contact.NodeA.Next != null)
            {
                contact.NodeA.Next.Prev = contact.NodeA.Prev;
            }

            if (contact.NodeA == bodyA.ContactList)
            {
                bodyA.ContactList = contact.NodeA.Next;
            }

            // Remove from body 2
            if (contact.NodeB.Prev != null)
            {
                contact.NodeB.Prev.Next = contact.NodeB.Next;
            }

            if (contact.NodeB.Next != null)
            {
                contact.NodeB.Next.Prev = contact.NodeB.Prev;
            }

            if (contact.NodeB == bodyB.ContactList)
            {
                bodyB.ContactList = contact.NodeB.Next;
            }

            contact.Destroy();
        }