Exemple #1
0
        void UpdateInputState()
        {
            lastVectorState = thisVectorState;
            thisVectorState = Vector2.zero;

            var dir = MoveAction ?? direction;

            if (Utility.AbsoluteIsOverThreshold(dir.X, analogMoveThreshold))
            {
                thisVectorState.x = Mathf.Sign(dir.X);
            }

            if (Utility.AbsoluteIsOverThreshold(dir.Y, analogMoveThreshold))
            {
                thisVectorState.y = Mathf.Sign(dir.Y);
            }

            if (VectorIsReleased)
            {
                nextMoveRepeatTime = 0.0f;
            }

            if (VectorIsPressed)
            {
                if (lastVectorState == Vector2.zero)
                {
                    if (Time.realtimeSinceStartup > lastVectorPressedTime + 0.1f)
                    {
                        nextMoveRepeatTime = Time.realtimeSinceStartup + moveRepeatFirstDuration;
                    }
                    else
                    {
                        nextMoveRepeatTime = Time.realtimeSinceStartup + moveRepeatDelayDuration;
                    }
                }

                lastVectorPressedTime = Time.realtimeSinceStartup;
            }

            lastSubmitState = thisSubmitState;
            lastCancelState = thisCancelState;
            thisSubmitState = false;
            thisCancelState = false;
            foreach (var device in Devices)
            {
                if (device.GetControl((InputControlType)submitButton).IsPressed)
                {
                    thisSubmitState = true;
                }
                if (device.GetControl((InputControlType)cancelButton).IsPressed)
                {
                    thisCancelState = true;
                }
            }
        }
Exemple #2
0
        bool IsPressed(UnknownDeviceControl control, InputDevice device)
        {
            var value = control.GetValue(device);

            return(Utility.AbsoluteIsOverThreshold(value, 0.5f));
        }
 public void Set(float value, float threshold)
 {
     Value = value;
     State = Utility.AbsoluteIsOverThreshold(value, threshold);
 }
 bool IsPressed(InputControl control)
 {
     return(Utility.AbsoluteIsOverThreshold(control.Value, 0.5f));
 }