예제 #1
0
    public IEnumerator LaunchChallenge()
    {
        MiniGameScript.Instance.gameObject.SetActive(true);
        yield return(new WaitForSeconds(0.1f));

        _serieOfKeysStr = "";
        for (int i = 0; i < _numberOfKeys; i++)
        {
            int    unicode   = Random.Range(97, 123);
            char   character = (char)unicode;
            string key       = character.ToString();
            if (i == 0 || !_serieOfKeysStr.Contains(key))
            {
                //_currentSerieOfKeys.Push(key);
                _serieOfKeysStr += key;
            }
            else
            {
                i--;
            }
        }
        _inputAction.ApplyBindingOverride("<Keyboard>/#(" + _serieOfKeysStr[0] + ")");
        _challengeIsPlaying = true;

        MiniGameScript.Instance.SetInfoText("Press the serie of key in the correct order !");
        MiniGameScript.Instance.SetProgress(0);
        MiniGameScript.Instance.SetGameKeys(_serieOfKeysStr);
    }
예제 #2
0
        private void Awake()
        {
            InputAction move = inputActionAsset.FindAction("Move");

            InputBinding touchMoveBinding = new InputBinding
            {
                overrideProcessors = "ScaleVector2(x=" + movementSpeed * touchSpeedMultiplier + ",y=" +
                                     movementSpeed * touchSpeedMultiplier + ")"
            };

            InputBinding gamepadMoveBinding = new InputBinding
            {
                overrideProcessors = "ScaleVector2(x=" + movementSpeed * gamepadSpeedMultiplier + ",y=" +
                                     movementSpeed * gamepadSpeedMultiplier + ")"
            };

            InputBinding keyboardMoveBinding = new InputBinding
            {
                overrideProcessors = "ScaleVector2(x=" + movementSpeed * keyboardSpeedMultiplier + ",y=" +
                                     movementSpeed * keyboardSpeedMultiplier + ")"
            };

            move.ApplyBindingOverride(0, gamepadMoveBinding);
            move.ApplyBindingOverride(1, touchMoveBinding);
            move.ApplyBindingOverride(2, keyboardMoveBinding); //TODO Change this if you change order in input action asset.
        }
예제 #3
0
    public IEnumerator LaunchChallenge()
    {
        MiniGameScript.Instance.gameObject.SetActive(true);
        yield return(new WaitForSeconds(0.1f));

        int    unicode   = Random.Range(97, 123);
        char   character = (char)unicode;
        string key       = character.ToString();

        _keysToAlternate[0] = key;

        int secondUnicode = Random.Range(97, 123);

        while (secondUnicode == unicode)
        {
            secondUnicode = Random.Range(97, 123);
        }
        character = (char)secondUnicode;
        key       = character.ToString();

        _keysToAlternate[1] = key;

        Debug.Log("Challenge Keys to Alternate: " + _keysToAlternate[0] + " / " + _keysToAlternate[1]);
        _inputAction.ApplyBindingOverride("<Keyboard>/#(" + _keysToAlternate[0] + ")");
        _challengeIsPlaying = true;

        MiniGameScript.Instance.SetInfoText("Alternate between both keys " + _goalOfRepetition + " times !");
        MiniGameScript.Instance.SetProgress(0);
        MiniGameScript.Instance.SetGameKeys(_keysToAlternate[0] + _keysToAlternate[1]);
        MiniGameScript.Instance.SetCounterText(_goalOfRepetition.ToString());
    }
예제 #4
0
    void RemapButtonClicked(string name, int bindingIndex = 0)
    {
        m_Button.enabled = false;
        m_Text.text      = "Press button/stick for " + name;
        m_RebindOperation?.Dispose();
        m_RebindOperation = m_Action.PerformInteractiveRebinding()
                            .WithControlsExcluding("<Mouse>/position")
                            .WithControlsExcluding("<Mouse>/delta")
                            .OnMatchWaitForAnother(0.1f)
                            .OnComplete(operation => ButtonRebindCompleted());
        if (m_CompositeBindingIndices != null)
        {
            m_RebindOperation = m_RebindOperation
                                .OnComputeScore((x, y) => ScoreFunc(m_CompositeType, x, y))
                                .OnGeneratePath(x =>
            {
                if (!ControlMatchesCompositeType(x, m_CompositeType))
                {
                    m_IsUsingComposite = true;
                }
                else
                {
                    m_IsUsingComposite = false;
                }
                return(null);
            })
                                .OnApplyBinding((x, path) =>
            {
                if (m_IsUsingComposite)
                {
                    m_Action.ApplyBindingOverride(m_DefaultBindingIndex, "");
                    m_Action.ApplyBindingOverride(
                        bindingIndex != m_DefaultBindingIndex ? bindingIndex : m_CompositeBindingIndices[0], path);

                    GameObject myEventSystem = GameObject.Find("EventSystem");
                    myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(m_CompositeButtons[0].gameObject);
                    m_CompositeButtons[0].OnSelect(null);
                }
                else
                {
                    m_Action.ApplyBindingOverride(m_DefaultBindingIndex, path);
                    foreach (var i in m_CompositeBindingIndices)
                    {
                        m_Action.ApplyBindingOverride(i, "");
                    }
                    GameObject myEventSystem = GameObject.Find("EventSystem");
                    myEventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>().SetSelectedGameObject(m_Button.gameObject);
                    m_Button.OnSelect(null);
                }
            });
        }
        m_RebindOperation.Start();
    }
예제 #5
0
 public static void InvertY(this InputAction action, bool state)
 {
     // TODO: do we need to check if action is vector2?
     action.ApplyBindingOverride(new InputBinding {
         overrideProcessors = $"invertVector2(invertX=false,invertY={state})"
     });
 }
예제 #6
0
 // Start is called before the first frame update
 void Start()
 {
     m_tirer = settings.FindActionMap(player).FindAction("Fire");
     if (PlayerPrefs.GetString("Fire" + player) != "")
     {
         m_tirer.ApplyBindingOverride(PlayerPrefs.GetString("Fire" + player));
     }
     m_tirer.Enable();
     shootTimer = shootColldown;
 }
예제 #7
0
    public void Confirm()
    {
        if (binding.isPartOfComposite)
        {
            input_action.ApplyBindingOverride(input_action.bindings.IndexOf((x) => x.name == binding.name), new_binding);
        }
        else
        {
            input_action.ApplyBindingOverride(new_binding);
        }

        RInput.SaveOverrides();
        input_action.Enable();
        SetWindow(false);
        CleanUp();

        // Hack to refresh pause menu and reset content of all Keybind settings
        transform.parent.gameObject.SetActive(false);
        transform.parent.gameObject.SetActive(true);
    }
    public void TrySetBinding(string bindingName, string newPath)
    {
        InputAction action = actionMap.FindAction(bindingName);

        if (action == null)
        {
            Debug.LogWarning($"Tried to set non existant action: {bindingName}");
        }
        else
        {
            action.ApplyBindingOverride(new InputBinding(newPath));
        }
    }
예제 #9
0
    public IEnumerator LaunchChallenge()
    {
        MiniGameScript.Instance.gameObject.SetActive(true);
        yield return(new WaitForSeconds(0.1f));

        int  unicode   = Random.Range(97, 123);
        char character = (char)unicode;

        _keyToSpam = character.ToString();

        _inputAction.ApplyBindingOverride("<Keyboard>/#(" + _keyToSpam + ")");
        _challengeIsPlaying = true;
        MiniGameScript.Instance.SetInfoText("Press the " + _keyToSpam + " key " + _nbrToSpam + " times !");
        MiniGameScript.Instance.SetProgress(0);
        MiniGameScript.Instance.SetGameKeys(_keyToSpam);
        MiniGameScript.Instance.SetCounterText(_nbrToSpam.ToString());
    }
예제 #10
0
    void Start()
    {
        inputAction = actionReference.action;

        string action = PlayerPrefs.GetString(inputAction.name, null);

        if (action != null)
        {
            inputAction.ApplyBindingOverride(action);
        }

        if (button == null)
        {
            button = GetComponentInChildren <Button>();
        }

        if (text == null)
        {
            text = GetComponentInChildren <Text>();
        }

        button.onClick.AddListener(delegate { RemapButtonClicked(name, defaultBindingIndex); });
        ResetButtonMappingTextValue();
    }
예제 #11
0
 /* Bind an action with a new path. */
 public void KeyBinding( InputAction _action, string _path )
 {
     _action.ApplyBindingOverride( _path );
 }