Ejemplo n.º 1
0
        void UpdateButtonText()
        {
            if (_handler != null)
            {
                switch (positiveAlternative)
                {
                case PositiveAlternative.Positive:
                    ButtonText.text = _handler.GetListener(ListenerName).Positive.ToString();
                    break;

                case PositiveAlternative.Alternative:
                    ButtonText.text = _handler.GetListener(ListenerName).Alternative.ToString();
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        private IEnumerator ListenForKeyToChange(IInputHandler handler, string listenerName, bool positive, Action UIUpdater)
        {
            var newKey = KeyCode.None;

            var listener = handler.GetListener(listenerName);

            if (listener == null)
            {
                yield break;
            }
            while (newKey == KeyCode.None)
            {
                foreach (KeyCode keyCode in Enum.GetValues(typeof(KeyCode)))
                {
                    if (!Input.GetKey(keyCode))
                    {
                        continue;
                    }
                    newKey = keyCode;
                    break;
                }

                yield return(new WaitForEndOfFrame());
            }

            KeyCode oldKey;

            if (positive)
            {
                oldKey            = listener.Positive;
                listener.Positive = newKey;
            }
            else
            {
                oldKey = listener.Alternative;
                listener.Alternative = newKey;
            }

            if (UIUpdater != null)
            {
                UIUpdater.Invoke();
            }

            handler.ChangeKey(listenerName, oldKey, newKey);
            UpdateStack();
        }