Example #1
0
            private float ActualGetInputWithLock(string _input, bool _getRaw, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
            {
                if(!inputLocks.ContainsKey(inputLock))
                {
                    inputLocks.Add(inputLock, "");
                }

                if (inputLocks[inputLock] == "")
                {
                    float val = ActualGetInput(_input, _getRaw, _overrideLock);
                    if (val != 0)
                    {
                        inputLocks[inputLock] = _input;
                        return val;
                    }
                }

                return 0;
            }
Example #2
0
 //Get Inputs
 //Input Behaviours Behaviour
 private float ActualGetInput(string _input, bool _getRaw, LockOverride _overrideLock = LockOverride.None)
 {
     return ActualGetAllInput(_input, _getRaw, currentLayout, _overrideLock);
 }
Example #3
0
 public bool GetRawButtonWithDelay(string _input, float _delay, float _deltaTime, float _cutOff = 0.5f, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
 {
     return ActualGetInputWithDelay(_input, true, _delay, _deltaTime, _cutOff, _overrideLock, inputLock) != 0;
 }
Example #4
0
            // -------------------------------------------------------------------------------------------------------------------------------------------------------
            private float ActualGetAllInput(string _input, bool getRaw, ControlLayout controlLayout, LockOverride _overrideLock = LockOverride.None)
            {
                float returnVal = 0f;

                if ((!localLocked || _overrideLock == LockOverride.OverrideLocalLock) && !locked && controlLayout != null)
                {
                    if (controlLayout.controls.ContainsKey(_input))
                    {
                        foreach (ControlName control in controlLayout.controls[_input])
                        {
                            string buttonName = "";

                            //Add Joystick name to button if not Keyboard
                            if (inputType != InputType.Keyboard)
                            {
                                if (!control.isAxis)
                                    buttonName = "joystick " + joystickID + " ";
                                else
                                    buttonName = "Joystick" + joystickID;
                            }

                            //Add Input
                            buttonName += control.inputName;

                            //Check for + / - or * symbol
                            //Side Note: Using +/- on an axis will only allow values which are positive or negative.
                            //Using on a button will return either a positive or negative value
                            //Using * will inverse an axis
                            WantedInput wantedInput = WantedInput.Either;

                            if (buttonName[buttonName.Length - 1] == '-')
                                wantedInput = WantedInput.MinusOnly;
                            else if (buttonName[buttonName.Length - 1] == '+')
                                wantedInput = WantedInput.PlusOnly;
                            else if (buttonName[buttonName.Length - 1] == '*')
                                wantedInput = WantedInput.Inverse;

                            //Remove the + or - from the input
                            if (wantedInput != WantedInput.Either)
                                buttonName = buttonName.Remove(buttonName.Length - 1, 1);

                            //Check if input is an axis or a button
                            if (control.isAxis)
                            {
                                //Get the actual input
                                float tempValue = 0f;
                                if (getRaw)
                                    tempValue = Input.GetAxisRaw(buttonName);
                                else
                                    tempValue = Input.GetAxis(buttonName);

                                if (tempValue != 0f)
                                {
                                    //Assign the temp value if it is valid
                                    switch (wantedInput)
                                    {
                                        case WantedInput.Either: returnVal = tempValue; break;
                                        case WantedInput.MinusOnly: if (tempValue <= 0f) returnVal = tempValue; break;
                                        case WantedInput.PlusOnly: if (tempValue >= 0f) returnVal = tempValue; break;
                                        case WantedInput.Inverse: returnVal = -tempValue; break;
                                    }
                                }
                            }
                            else
                            {
                                //Get the actual input if button is pressed
                                returnVal = Input.GetKey(buttonName) ? (wantedInput == WantedInput.MinusOnly ? -1 : 1) : 0;
                            }

                            //Break out of inputs if input found
                            if (returnVal != 0f)
                                break;
                        }
                    }
                    else
                    {
                        if (controlLayout == defaultLayout)
                            Debug.LogError(_input + " is not a registered input!");
                        else if (!InputIgnoreList.ignoreList.Contains(_input))
                            return ActualGetAllInput(_input, getRaw, defaultLayout);
                    }
                }

                return returnVal;
            }
Example #5
0
 //Accessible Methods - Input With Delay ------------------------------------------------------------------------------------------------------------------
 public float GetInputWithDelay(string _input, float _delay, float _deltaTime, float _cutOff = 0.5f, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
 {
     return ActualGetInputWithDelay(_input, false, _delay, _deltaTime, _cutOff, _overrideLock, inputLock);
 }
Example #6
0
 public int GetRawIntInputWithDelay(string _input, float _delay, float _deltaTime, float _cutOff = 0.5f, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
 {
     return MathHelper.Sign(ActualGetInputWithDelay(_input, true, _delay, _deltaTime, _cutOff, _overrideLock, inputLock));
 }
Example #7
0
 public int GetRawIntInputWithLock(string _input, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
 {
     return MathHelper.Sign(ActualGetInputWithLock(_input, true, _overrideLock, inputLock));
 }
Example #8
0
 public bool GetRawButtonWithLock(string _input, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
 {
     return ActualGetInputWithLock(_input, true, _overrideLock, inputLock) != 0;
 }
Example #9
0
 public float GetRawInputWithLock(string _input, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
 {
     return ActualGetInputWithLock(_input, true, _overrideLock, inputLock);
 }
Example #10
0
 public bool GetRawButton(string _input, LockOverride _overrideLock = LockOverride.None)
 {
     return ActualGetInput(_input, true, _overrideLock) != 0;
 }
Example #11
0
 public int GetRawIntInput(string _input, LockOverride _overrideLock = LockOverride.None)
 {
     return MathHelper.Sign(ActualGetInput(_input, true, _overrideLock));
 }
Example #12
0
 public float GetRawInput(string _input, LockOverride _overrideLock = LockOverride.None)
 {
     return ActualGetInput(_input, true, _overrideLock);
 }
Example #13
0
            private float ActualGetInputWithDelay(string _input, bool _getRaw, float _delay, float _deltaTime, float _cutOff = 0.5f, LockOverride _overrideLock = LockOverride.None, string inputLock = "Default")
            {
                if (!inputLocks.ContainsKey(inputLock))
                {
                    inputLocks.Add(inputLock, "");
                }

                float val = GetInput(_input, _overrideLock);

                if (inputTimer <= 0f && (inputLocks[inputLock] == _input || inputLocks[inputLock] == ""))
                {
                    if (Mathf.Abs(val) >= _cutOff)
                    {
                        inputLocks[inputLock] = _input;
                        inputTimer = _delay;
                        return val;
                    }
                }

                if (inputLocks[inputLock] == _input && val != 0f)
                {
                    inputTimer -= _deltaTime;
                }

                return 0;
            }