public ButtonComponent(string Name, DrawableComponent drawInfo, IDrawableUnit SelectedColors, IDrawableUnit PressedColors, IDrawableUnit UnselectedColors, PressAction calledWhenPressed) : base(Name, drawInfo) { this.SelectedColors = SelectedColors; this.UnselectedColors = UnselectedColors; this.PressedColors = PressedColors; Pressed = false; Selected = false; SetColors(UnselectedColors); this.calledWhenPressed = calledWhenPressed; }
public ButtonComponent(string Name, DrawableComponent drawInfo, IDrawableUnit SelectedColors, IDrawableUnit PressedColors, IDrawableUnit UnselectedColors, PressAction calledWhenPressed) : base(Name,drawInfo) { this.SelectedColors = SelectedColors; this.UnselectedColors = UnselectedColors; this.PressedColors = PressedColors; Pressed = false; Selected = false; SetColors(UnselectedColors); this.calledWhenPressed = calledWhenPressed; }
private void Rotate() { _rotationCooldown--; if (_rotationCooldown <= 0) { if (Input.GetAxis("RT") > 0.8) { PressAction.OnButtonPressed("RT"); _rotationCooldown = 15; transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z - 90); } if (Input.GetAxis("LT") > 0.8) { PressAction.OnButtonPressed("LT"); _rotationCooldown = 15; transform.rotation = Quaternion.Euler(0, 0, transform.rotation.eulerAngles.z + 90); } } }
public static bool GetMouseButton(PressAction action, MouseButton button) { if (action == PressAction.DOWN) { return(GetButton(Mstate.CURRENT, button)); } else if (action == PressAction.UP) { return(!GetButton(Mstate.CURRENT, button)); } else if (action == PressAction.PRESSED) { return(GetButton(Mstate.CURRENT, button) && !GetButton(Mstate.PREV, button)); } else if (action == PressAction.RELEASED) { return(!GetButton(Mstate.CURRENT, button) && GetButton(Mstate.PREV, button)); } return(false); }
public void Update(ButtonState state, InputKey inputKey, FrameDetails frame) { if (state.IsPressed) { if (isPressed) { // Down -> down holdDuration += frame.TimeDelta; if (!holdHandled && holdDuration >= Configuration.Duration) { HoldAction.Execute(); holdHandled = true; } } else { // Up -> down holdDuration = 0d; isPressed = true; } } else { if (isPressed) { // Down -> up if (holdDuration < Configuration.Duration) { PressAction.Execute(); } holdHandled = false; isPressed = false; } holdDuration = 0d; } }
public static bool GetKey(PressAction action, Keys key) { bool isInPrev = KeyIsIn(Mstate.PREV, key); bool isInCurr = KeyIsIn(Mstate.CURRENT, key); if (action == PressAction.DOWN) { return(isInCurr); } else if (action == PressAction.UP) { return(!isInCurr); } else if (action == PressAction.PRESSED) { return(!isInPrev && isInCurr); } else if (action == PressAction.RELEASED) { return(isInPrev && !isInCurr); } return(false); }