// 更新時に呼ばれる void Update() { // ボタンの状態表示 print("ButtonA Pressed: " + ButtonA.IsPressed()); print("ButtonA Down: " + ButtonA.IsDown()); print("ButtonA Up: " + ButtonA.IsUp()); }
public override void Input() { IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap; foreach (PlayerMovementComponent pmc in WatchedComponents) { Physical rb = pmc.Owner.Components.Get <Physical>(); ButtonState jumpButton = inputMap.Jump; if (jumpButton.IsPressed()) { pmc.Jump.RegisterPressed(); } else { pmc.Jump.RegisterUnpressed(); } if (pmc.OnGround) { if (jumpButton.IsPressed() && pmc.Jump.Execute()) { rb.Velocity.Y = pmc.JumpSpeed; } } double xMovement = inputMap.Movement.X * pmc.CurrentSpeed; double xMovementCap = pmc.CurrentMaxSpeed; if (xMovement > 0) { if (rb.Velocity.X <= xMovementCap) { rb.Velocity.X = Math.Min(rb.Velocity.X + xMovement, xMovementCap); } } else if (xMovement < 0) { if (rb.Velocity.X >= -xMovementCap) { rb.Velocity.X = Math.Max(rb.Velocity.X + xMovement, -xMovementCap); } } } }
public override void Input() { IInputMap inputMap = Woofer.Controller.InputManager.ActiveInputMap; foreach (PulseAbility pa in WatchedComponents.Where(c => c is PulseAbility)) { ButtonState pulseButton = inputMap.Pulse; if (pulseButton.IsPressed()) { pa.Pulse.RegisterPressed(); } else { pa.Pulse.RegisterUnpressed(); } if (pa.EnergyMeter >= pa.PulseCost) { if (pulseButton.IsPressed() && pa.Pulse.Execute()) { double strength = (pa.PulseStrength * Math.Sqrt(pa.EnergyMeter / pa.MaxEnergy)); if (pa.Owner.Components.Has <Physical>() && pa.Owner.Components.Has <PlayerOrientation>()) { pa.Owner.Components.Get <Physical>().Velocity = pa.Owner.Components.Get <PlayerOrientation>().Unit * -strength; } pa.EnergyMeter -= pa.PulseCost; if (pa.Owner.Components.Has <Spatial>()) { Spatial sp = pa.Owner.Components.Get <Spatial>(); if (sp == null) { continue; } PlayerOrientation po = pa.Owner.Components.Get <PlayerOrientation>(); Owner.Events.InvokeEvent(new PulseEvent(pa, sp.Position, po != null ? po.Unit : new Vector2D(), strength, pa.MaxRange)); } } } } }
public void RegisterState(ButtonState state) { FrameConsumed = false; if (state.IsPressed()) { FramesPressed++; } else { FramesPressed = 0; Consumed = false; } }
public static ButtonState ButtonOr(ButtonState a, ButtonState b) { return((a.IsPressed() || b.IsPressed()) ? ButtonState.Pressed : ButtonState.Released); }