상속: MonoBehaviour
예제 #1
0
    void Start()
    {
        Instance = this;

        // find the button objects
        buttons = GetComponentsInChildren <OptionsMenuItem>();

        // start with the menu disabled}
        gameObject.SetActive(false);

        selectorLocalPos = selector.transform.localPosition;
    }
예제 #2
0
    IEnumerator AssignKey(InputType keyType, TextMeshProUGUI codeText)
    {
        waitingForKey = true;

        PopupManager.Instance.ShowInputControlMessage();
        yield return(WaitForKey());

        PopupManager.Instance.HideInputControlMessage();

        if (!IsKeyCodeInForbiddenList())
        {
            if (inputInfo.keyInputDict[keyType].inputCode == newKey)
            {
                PopupManager.Instance.ShowStandartPopup("You cannot change same key");
            }
            else if (IsSwapRequire())
            {
                SwapKeys();
                OptionsMenuController.ChangeInputText(keyType, inputInfo.keyInputDict[keyType].inputCode);
                OptionsMenuController.ChangeInputText(swapType, inputInfo.keyInputDict[swapType].inputCode);

                SaveManager.Save(inputData, INPUT_SAVE_FILE_NAME);
            }
            else
            {
                inputInfo.keyInputDict[keyType].inputCode = newKey;
                codeText.text = newKey.ToString();

                SaveManager.Save(inputData, INPUT_SAVE_FILE_NAME);
            }
        }
        else
        {
            PopupManager.Instance.ShowStandartPopup($"{newKey} is a Forbidden Key Change, Try Another Key.");
        }

        bool IsKeyCodeInForbiddenList()
        {
            return(forbiddenKeyChange.Contains(newKey));
        }

        bool IsSwapRequire()
        {
            foreach (var input in inputInfo.keyInputDict)
            {
                if (input.Value.inputCode == newKey)
                {
                    swapType = input.Key;
                    return(true);
                }
            }
            return(false);
        }

        void SwapKeys()
        {
            inputInfo.keyInputDict[keyType].inputCode  = inputInfo.keyInputDict[keyType].inputCode ^ inputInfo.keyInputDict[swapType].inputCode;
            inputInfo.keyInputDict[swapType].inputCode = inputInfo.keyInputDict[keyType].inputCode ^ inputInfo.keyInputDict[swapType].inputCode;
            inputInfo.keyInputDict[keyType].inputCode  = inputInfo.keyInputDict[keyType].inputCode ^ inputInfo.keyInputDict[swapType].inputCode;
        }
    }
예제 #3
0
 private void Awake()
 {
     menu = GetComponentInChildren <OptionsMenuController>();
 }