public GroundConstraint(Body body, Fixture bodyFixture, SurfaceMovementControl surfaceMovementControl) { _body = body; _surfaceMovementControl = surfaceMovementControl; Add(bodyFixture.CreateContactHandler(HexPhysicTypes.Ground, EnterGroundContact, ExitGroundContact)); // sensor var sensor = _body.AttachCircle(10f, 0); sensor.IsSensor = true; sensor.SetCollisionType(HexPhysicTypes.GroundSensor); _closeHexList = Add(new FixtureContactList(sensor)); // ground constraint _groundConstraintUpdate = new UpdateComponent(UpdateGroundConstraint, UpdateTime.Sim); Add(_groundConstraintUpdate); // state Add(new StateRecorder("groundConstraint", state => { }, state => { _isOnGround = false; _currentHex = null; })); }
public MovementKeyboardInput(SurfaceMovementControl surface, BoostController boost) { Add(new KeyBinding(Keys.W, () => surface.InputY -= 1, () => surface.InputY += 1)); Add(new KeyBinding(Keys.S, () => surface.InputY += 1, () => surface.InputY -= 1)); Add(new KeyBinding(Keys.A, () => surface.InputX -= 1, () => surface.InputX += 1)); Add(new KeyBinding(Keys.D, () => surface.InputX += 1, () => surface.InputX -= 1)); Add(new KeyBinding(Keys.Space, boost.Prepare, boost.Apply)); }