private void OnTriggerEnter2D(Collider2D collision) { if (Input.GetKeyDown(KeyCode.W)) { onEnter.Invoke(); } }
/// <summary> /// Makes a new instance of <see cref="GlfwMouse"/> class. /// </summary> /// <param name="window">Current context.</param> public GlfwMouse(GlfwWindow window) { handler = window; handler.OnRestore += Handler_OnRestore; cursorCallback = (w, x, y) => { OnMove?.Invoke(this, new MousePositiontEventArgs { Position = new Vector2((float)x, (float)y) }); }; scrollCallback = (w, x, y) => { OnScroll?.Invoke(this, new MouseOffsetEventArgs { Offset = new Vector2((float)x, (float)y) }); }; buttonCallback = (w, button, action, modifiers) => { OnButtonEvent?.Invoke(this, new MouseKeyEventArgs { Key = (MouseButton)button, Action = (KeyState)action, Modifiers = (KeyModifier)modifiers }); }; }
private void OnTriggerExit2D(Collider2D collision) { p_collisionCounter--; if (p_collisionCounter != 0) { return; } p_spriteAnimator.SetBool(p_isPressed, false); onButtonEventExit.Invoke(); }
private void OnTriggerEnter2D(Collider2D collision) { if (p_collisionCounter == 0) { SoundManager.Instance.Play("Button", true); p_spriteAnimator.SetBool(p_isPressed, true); onButtonEventEnter.Invoke(); } p_collisionCounter++; }
public void Update(IFrameBasedClock clock) { while (currentState != null && currentState.Events.Count > 0) { IInputEvent e = currentState.Events.Dequeue(); if (e is InputEvent <MouseKeyEventArgs> keyEvent && keyEvent.Name == "OnButtonEvent") { OnButtonEvent?.Invoke(this, keyEvent.Info); } if (e is InputEvent <MousePositiontEventArgs> modEvent && modEvent.Name == "OnMove") { OnMove?.Invoke(this, modEvent.Info); } if (e is InputEvent <MouseOffsetEventArgs> tyEvent && tyEvent.Name == "OnScroll") { OnScroll?.Invoke(this, tyEvent.Info); } } }
private void OnTriggerExit2D(Collider2D collision) { onExit.Invoke(); }
public override void Update() { if (_onScreen) { _cameraPos = Camera.Pos; } if (_fadesIn) { _fadeCount++; } _fadeCount = Clamp(_fadeCount, 0, 100); _buttonArea = new Rectangle() { X = Pos.X + _cameraPos.X, Y = Pos.Y + _cameraPos.Y, Width = _width, Height = _height }; if (MiddleAligned) { _buttonArea.X -= _width / 2; _buttonArea.Y -= _height / 2; } Rectangle _activeMouseRect = new Rectangle() { X = Pos.X, Y = Pos.Y, Width = _width, Height = _height }; if (MiddleAligned) { _activeMouseRect.X -= _width / 2; _activeMouseRect.Y -= _height / 2; } if (SwinGame.PointInRect(SwinGame.MousePosition(), _activeMouseRect)) { if (_isMouseOver == false) { //false-->true mousing over. if (_mouseOverSoundEffect != null) { if (Artillery3R.Services.A3RData.EasterEggTriggered) { SwinGame.PlaySoundEffect("newMenuSound"); } else { SwinGame.PlaySoundEffect(_mouseOverSoundEffect); } } } _isMouseOver = true; } else { _isMouseOver = false; } if (_isMouseOver && SwinGame.MouseClicked(MouseButton.LeftButton)) { if (Artillery3R.Services.A3RData.EasterEggTriggered) { SwinGame.PlaySoundEffect("confirmSound"); } OnUIEvent?.Invoke(this, _uiEventArgs); _buttonEvent?.Invoke(); } }
public virtual void ButtonEventAction(UIButtonEventArgs eventArgs) { OnButtonEvent?.Invoke(this, eventArgs); }