Example #1
0
    public void Tick()
    {
        if (IsEnabled)
        {
            if (Input.GetKeyDown(KeyCode.LeftArrow))
            {
                OnLeft?.Invoke();
            }
            if (Input.GetKeyDown(KeyCode.RightArrow))
            {
                OnRight?.Invoke();
            }
            if (Input.GetKeyDown(KeyCode.UpArrow))
            {
                OnUp?.Invoke();
            }

            if (Time.time - previousTime >
                (Input.GetKey(KeyCode.DownArrow) ? fallTime / 10 : fallTime))
            {
                OnDown?.Invoke();
                previousTime = Time.time;
            }
        }
    }
Example #2
0
            /// <summary>
            /// Handles watching the given key for
            /// </summary>
            /// <param name="myCurrentState"></param>
            /// <param name="myPrevState"></param>
            /// <param name="key"></param>
            public void Watch(KeyboardState myCurrentState, KeyboardState myPrevState)
            {
                bool wasPressed = myPrevState.IsKeyDown(myKey);
                bool isPressed  = myCurrentState.IsKeyDown(myKey);

                ButtonDelta deltaState =
                    isPressed != wasPressed ?
                    isPressed ? ButtonDelta.Pressed : ButtonDelta.Released :
                    isPressed ? ButtonDelta.Down : ButtonDelta.Up;

                if (deltaState == ButtonDelta.Pressed)
                {
                    OnPressed?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                if (deltaState == ButtonDelta.Released)
                {
                    OnReleased?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                if (deltaState == ButtonDelta.Down)
                {
                    OnDown?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                if (deltaState == ButtonDelta.Up)
                {
                    OnUp?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
                }

                OnEvent?.Invoke(this, new KeyPressEventArgs(myKey, deltaState));
            }
 public void Up()
 {
     if (OnUp != null)
     {
         OnUp.Invoke();
     }
 }
Example #4
0
            internal void UpdateState(bool onHold)
            {
                Down = false;
                Up   = false;
                if (onHold)
                {
                    if (!Hold)
                    {
                        Down = true;
                        OnDownOnce?.Invoke();
                        OnDownOnce = null;
                        OnDown?.Invoke();
                    }
                }
                else
                {
                    if (Hold)
                    {
                        Up = true;

                        OnUpOnce?.Invoke();
                        OnUpOnce = null;
                        OnUp?.Invoke();
                    }
                }
                Hold = onHold;
            }
Example #5
0
        /// <summary>
        /// Response mouse left button up.
        /// </summary>
        protected virtual void OnMouseUp()
        {
            if (!isEnabled)
            {
                return;
            }

            if (selfLock)
            {
                isLock = !isLock;
            }

            if (isLock)
            {
                currentOffset = downOffset * lockPercent;
                OnLock.Invoke();
            }
            else
            {
                IsDown        = false;
                currentOffset = 0;
                OnUp.Invoke();
            }
            Translate(currentOffset);

            if (useLED && !isLock)
            {
                LED.TurnOff();
            }
        }
Example #6
0
    public override void OnPointerUp(PointerEventData eventData)
    {
        OnUp.SafeInvoke();

        ButtonUp = true;
        Pressed  = false;

        base.OnPointerUp(eventData);
    }
Example #7
0
            public void Watch(DeltaMouseState change)
            {
                ButtonDelta deltaState = ButtonDelta.Invalid;

                switch (myButton)
                {
                case MouseButton.Left:
                    deltaState = change.LeftButton;
                    break;

                case MouseButton.Right:
                    deltaState = change.RightButton;
                    break;

                case MouseButton.Middle:
                    deltaState = change.MiddleButton;
                    break;

                case MouseButton.XButton1:
                    deltaState = change.XButton1;
                    break;

                case MouseButton.XButton2:
                    deltaState = change.XButton2;
                    break;
                }

                if (deltaState != ButtonDelta.Invalid)
                {
                    if (deltaState == ButtonDelta.Pressed)
                    {
                        OnPressed?.Invoke(this, change);
                    }

                    if (deltaState == ButtonDelta.Released)
                    {
                        OnReleased?.Invoke(this, change);
                    }

                    if (deltaState == ButtonDelta.Down)
                    {
                        OnDown?.Invoke(this, change);
                    }

                    if (deltaState == ButtonDelta.Up)
                    {
                        OnUp?.Invoke(this, change);
                    }

                    OnEvent?.Invoke(this, change);
                }
            }
Example #8
0
        private void OnStateChanged(PlatformState state)
        {
            switch (state)
            {
            case PlatformState.Appear:
                OnAppear?.Invoke();
                break;

            case PlatformState.Up:
                OnUp?.Invoke();
                break;

            case PlatformState.Down:
                OnDown?.Invoke();
                break;
            }
        }
Example #9
0
 public void Compute()
 {
     output = Input.GetAxis(name);
     value  = Mathf.Abs(Input.GetAxisRaw(name));
     if (value > 0f && oldValue == 0f)
     {
         OnDown.Invoke(output);
     }
     if (value < 1f && oldValue == 1f)
     {
         OnUp.Invoke(output);
     }
     if (value > 0f && oldValue > 0f)
     {
         OnPressed.Invoke(output);
     }
     oldValue = value;
 }
Example #10
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            OnLeft?.Invoke();
        }
        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            OnRight?.Invoke();
        }
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            OnUp?.Invoke();
        }

        if (Time.time - previousTime >
            (Input.GetKey(KeyCode.DownArrow) ? fallTime / 10 : fallTime))
        {
            OnDown?.Invoke();
            previousTime = Time.time;
        }
    }
Example #11
0
    void Button_OnUp(UiButton button, PointerEventData data)
    {
        GuiButtonTypeTEMP key = GuiButtonTypeTEMP.None;

        if (button == upButton)
        {
            key = GuiButtonTypeTEMP.Up;
        }
        else if (button == downButton)
        {
            key = (GuiButtonTypeTEMP.Down);
        }
        else if (button == leftButton)
        {
            key = (GuiButtonTypeTEMP.Left);
        }
        else if (button == rightButton)
        {
            key = (GuiButtonTypeTEMP.Right);
        }
        else if (button == resetButton)
        {
            key = (GuiButtonTypeTEMP.Reset);
        }
        else if (button == disconnectButton)
        {
            key = (GuiButtonTypeTEMP.Disconnect);
        }

        if (key != GuiButtonTypeTEMP.None)
        {
            isPressed.Remove(key);
            isPressed.Add(key, false);
        }

        OnUp?.Invoke(key);
    }
 public override void Update(double deltaTime)
 {
     base.Update(deltaTime);
     if (Input.onHover(ActRectangle))
     {
         OnHover?.Invoke(this, new UiEventArgs(Input.getPosition()));
     }
     if (Input.onLeave(ActRectangle))
     {
         OnLeave?.Invoke(this, new UiEventArgs(Input.getPosition()));
     }
     if (Input.OnMouseDown(Input.LeftButton) && Input.IsHover(ActRectangle))
     {
         OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton));
     }
     if (Input.OnMouseDown(Input.MiddleButton) && Input.IsHover(ActRectangle))
     {
         OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton));
     }
     if (Input.OnMouseDown(Input.RightButton) && Input.IsHover(ActRectangle))
     {
         OnDown?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton));
     }
     if (Input.OnMouseUp(Input.LeftButton) && Input.IsHover(ActRectangle))
     {
         OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.LeftButton));
     }
     if (Input.OnMouseUp(Input.MiddleButton) && Input.IsHover(ActRectangle))
     {
         OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.MiddleButton));
     }
     if (Input.OnMouseUp(Input.RightButton) && Input.IsHover(ActRectangle))
     {
         OnUp?.Invoke(this, new UiEventArgs(Input.getPosition(), Input.RightButton));
     }
 }
Example #13
0
        IEnumerator UpdateRoutine()
        {
            while (true)
            {
                if (Input.GetMouseButtonDown(0))
                {
                    OnDown.Invoke(this, Input.mousePosition);
                    buttonActive = true;
                }

                if (Input.GetMouseButtonUp(0))
                {
                    OnUp.Invoke(this, Input.mousePosition);
                    buttonActive = false;
                }

                if (Input.GetMouseButton(0) && buttonActive)
                {
                    OnMove.Invoke(this, Input.mousePosition);
                }

                yield return(null);
            }
        }
    private void Update()
    {
        if (Input.GetButtonDown("Vertical"))
        {
            float axisVertical = Input.GetAxisRaw("Vertical");

            if (axisVertical == 1)
            {
                OnUp?.Invoke();
                return;
            }

            if (axisVertical == -1)
            {
                OnDown?.Invoke();
                return;
            }
        }

        if (Input.GetButtonDown("Horizontal"))
        {
            float axisHorizontal = Input.GetAxisRaw("Horizontal");

            if (axisHorizontal == -1)
            {
                OnLeft?.Invoke();
                return;
            }

            if (axisHorizontal == 1)
            {
                OnRight?.Invoke();
                return;
            }
        }
    }
Example #15
0
 private void _OnUp()
 {
     OnUp?.Invoke(this, EventArgs.Empty);
 }
    public void InputPass()
    {
        // Get Input
        float y = 0;
        float x = 0;

        if (_useAxis)
        {
            y = Input.GetAxisRaw("Horizontal");
            x = Input.GetAxisRaw("Vertical");
        }
        else
        {
            if (Input.GetButtonDown("Fire_A"))
            {
                x--;
            }
            if (Input.GetButtonDown("Fire_B"))
            {
                y++;
            }
            if (Input.GetButtonDown("Fire_X"))
            {
                y--;
            }
            if (Input.GetButtonDown("Fire_Y"))
            {
                x++;
            }
        }

        if (_lastX != x || _lastY != y)
        {
            // Debug.Log($"x : {x} - y : {y}");
            _lastY = y;
            _lastX = x;
        }

        // Check Up
        if (!_validated[(int)VirtualNote.Up] && x > _validationThreshold)
        {
            _validated[(int)VirtualNote.Up] = true;
            OnUp?.Invoke();
            OnHammerHit?.Invoke();
            OnUpUnity?.Invoke();
            // Debug.Log("Up");
        }
        if (!_validated[(int)VirtualNote.Right] && y > _validationThreshold)
        {
            _validated[(int)VirtualNote.Right] = true;
            OnRight?.Invoke();
            OnHammerHit?.Invoke();
            OnRightUnity?.Invoke();
            // Debug.Log("Right");
        }
        if (!_validated[(int)VirtualNote.Down] && x < _validationThreshold * -1)
        {
            _validated[(int)VirtualNote.Down] = true;
            OnDown?.Invoke();
            OnHammerHit?.Invoke();
            OnDownUnity?.Invoke();
            // Debug.Log("Down");
        }
        if (!_validated[(int)VirtualNote.Left] && y < _validationThreshold * -1)
        {
            _validated[(int)VirtualNote.Left] = true;
            OnLeft?.Invoke();
            OnHammerHit?.Invoke();
            OnLeftUnity?.Invoke();
            // Debug.Log("Left");
        }

        // Check disabled
        if ((_validated[(int)VirtualNote.Up] || _validated[(int)VirtualNote.Down]) && Mathf.Abs(x) <= _disableThreshold)
        {
            _validated[(int)VirtualNote.Up]   = false;
            _validated[(int)VirtualNote.Down] = false;
        }
        if ((_validated[(int)VirtualNote.Right] || _validated[(int)VirtualNote.Left]) && Mathf.Abs(y) <= _disableThreshold)
        {
            _validated[(int)VirtualNote.Right] = false;
            _validated[(int)VirtualNote.Left]  = false;
        }
    }
Example #17
0
 private void OnMouseUp()
 {
     OnUp?.Invoke();
     blood.Fill(false, 0.002f * BPM.Instance?.Bpm ?? 60);
 }
Example #18
0
        public override void OnPointerUp(PointerEventData eventData)
        {
            base.OnPointerUp(eventData);

            OnUp?.Invoke();
        }
Example #19
0
 private async void OnUpClicked(object sender, EventArgs e)
 {
     await OnUp?.Invoke(sender, e);
 }
Example #20
0
 private void OnUpInput(InputAction.CallbackContext context)
 {
     //Debug.Log($"{index}: Up");
     OnUp?.Invoke();
 }
 //Protected Methods:
 protected void Up()
 {
     OnUp?.Invoke(this);
 }
Example #22
0
 private void OnMouseUp()
 {
     OnUp?.Invoke(gameObject);
 }
Example #23
0
 /// <summary>
 /// Can be mouse up for a click or a mouse up for a cancel operation
 /// </summary>
 void MouseUp()
 {
     OnUp?.Invoke( );
 }
Example #24
0
 public void OnPointerUp(PointerEventData eventData)
 {
     OnUp?.Invoke(this);
 }
Example #25
0
 public void UpAction()
 {
     OnUp?.Invoke();
 }
Example #26
0
 protected virtual void OnIsUp(EndPointArgs args)
 {
     OnUp?.Invoke(args);
 }
 public void TriggerOnUp() => OnUp?.Invoke();