public override void BeginContact(Box2D.Dynamics.Contacts.b2Contact contact) { base.BeginContact (contact); if (contact.FixtureA.UserData != null && contact.FixtureB.UserData != null) { switch ((WorldFixtureData)contact.FixtureA.UserData) { case WorldFixtureData.playergroundsensor: switch ((WorldFixtureData)contact.FixtureB.UserData) { case WorldFixtureData.ground: playerGround = WorldFixtureData.ground; break; case WorldFixtureData.platform: playerGround = WorldFixtureData.platform; playerGroundBody = contact.FixtureB.Body; break; case WorldFixtureData.jumppad: playerGround = WorldFixtureData.jumppad; playerGroundJumpPad = gameContainer.jumpPadContainer.First (search => search.JumpPadBody.Position == contact.FixtureB.Body.Position); break; default: playerGround = WorldFixtureData.air; break; } break; case WorldFixtureData.playerleftsensor: if ((WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.ground) { WallContact = Direction.Left; } else { WallContact = Direction.None; } break; case WorldFixtureData.playerrightsensor: if ((WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.ground) { WallContact = Direction.Right; } else { WallContact = Direction.None; } break; default: switch ((WorldFixtureData)contact.FixtureB.UserData) { case WorldFixtureData.playergroundsensor: switch ((WorldFixtureData)contact.FixtureA.UserData) { case WorldFixtureData.ground: playerGround = WorldFixtureData.ground; break; case WorldFixtureData.platform: playerGround = WorldFixtureData.platform; playerGroundBody = contact.FixtureA.Body; break; case WorldFixtureData.jumppad: playerGround = WorldFixtureData.jumppad; playerGroundJumpPad = gameContainer.jumpPadContainer.First (search => search.JumpPadBody.Position == contact.FixtureB.Body.Position); break; default: playerGround = WorldFixtureData.air; break; } break; case WorldFixtureData.playerleftsensor: if ((WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.ground) { WallContact = Direction.Left; } else { WallContact = Direction.None; } break; case WorldFixtureData.playerrightsensor: if ((WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.ground) { WallContact = Direction.Right; } else { WallContact = Direction.None; } break; } break; } } }
public override void EndContact(Box2D.Dynamics.Contacts.b2Contact contact) { if (contact.FixtureA.UserData != null && contact.FixtureB.UserData != null) { switch ((WorldFixtureData)contact.FixtureA.UserData) { case WorldFixtureData.playergroundsensor: if ((WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.platform) { playerGroundBody = null; playerGround = WorldFixtureData.air; } else if ((WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.jumppad) { playerGroundJumpPad = null; playerGround = WorldFixtureData.air; } else { playerGround = WorldFixtureData.air; } break; case WorldFixtureData.playerleftsensor: WallContact = Direction.None; break; case WorldFixtureData.playerrightsensor: WallContact = Direction.None; break; default: switch ((WorldFixtureData)contact.FixtureB.UserData) { case WorldFixtureData.playergroundsensor: if ((WorldFixtureData)contact.FixtureA.UserData == WorldFixtureData.platform) { playerGroundBody = null; playerGround = WorldFixtureData.air; } else if ((WorldFixtureData)contact.FixtureA.UserData == WorldFixtureData.jumppad) { playerGroundJumpPad = null; playerGround = WorldFixtureData.air; } else { playerGround = WorldFixtureData.air; } break; case WorldFixtureData.playerleftsensor: WallContact = Direction.None; break; case WorldFixtureData.playerrightsensor: WallContact = Direction.None; break; } break; } if ((WorldFixtureData)contact.FixtureA.UserData == WorldFixtureData.playergroundsensor && (WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.platform || (WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.playergroundsensor && (WorldFixtureData)contact.FixtureA.UserData == WorldFixtureData.platform) { } else if ((WorldFixtureData)contact.FixtureA.UserData == WorldFixtureData.playergroundsensor || (WorldFixtureData)contact.FixtureB.UserData == WorldFixtureData.playergroundsensor) { } } }