Exemple #1
0
    public void DefaultButton()
    {
        /*foreach (CommonButton tempButton in keyList.buttons)
         * {
         *  switch (tempButton.GetKeyType())
         *  {
         *      case KeyType.LEFT: tempButton.keyCodeName = leftDefaultKey.ToString(); break;
         *      case KeyType.RIGHT: tempButton.keyCodeName = rightDefaultKey.ToString(); break;
         *      case KeyType.UP: tempButton.keyCodeName = upDefaultKey.ToString(); break;
         *      case KeyType.DOWN: tempButton.keyCodeName = downDefaultKey.ToString(); break;
         *      case KeyType.SLASH: tempButton.keyCodeName = slashDefaultKey.ToString(); break;
         *      case KeyType.SHOOT: tempButton.keyCodeName = shootDefaultKey.ToString(); break;
         *      case KeyType.JUMP: tempButton.keyCodeName = jumpDefaultKey.ToString(); break;
         *      case KeyType.DASH: tempButton.keyCodeName = dashDefaultKey.ToString(); break;
         *      default: break;
         *  }
         * }*/
        keyList = new CommonButtonList();
        List <CommonButton> buttons = new List <CommonButton>();

        buttons.Add(new CommonButton(leftDefaultKey.ToString(), KeyType.LEFT.ToString()));
        buttons.Add(new CommonButton(rightDefaultKey.ToString(), KeyType.RIGHT.ToString()));
        buttons.Add(new CommonButton(upDefaultKey.ToString(), KeyType.UP.ToString()));
        buttons.Add(new CommonButton(downDefaultKey.ToString(), KeyType.DOWN.ToString()));
        buttons.Add(new CommonButton(slashDefaultKey.ToString(), KeyType.SLASH.ToString()));
        buttons.Add(new CommonButton(shootDefaultKey.ToString(), KeyType.SHOOT.ToString()));
        buttons.Add(new CommonButton(jumpDefaultKey.ToString(), KeyType.JUMP.ToString()));
        buttons.Add(new CommonButton(dashDefaultKey.ToString(), KeyType.DASH.ToString()));
        keyList.buttons = buttons;
    }
Exemple #2
0
    public void RefreshButton()
    {
        //controlConfig = Resources.Load<TextAsset>("Config/control");
        string configJson = PlayerPrefs.GetString("PlayerController");

        if (configJson == null || configJson == "")
        {
            DefaultButton();
            //TextAsset controlConfig = Resources.Load<TextAsset>("Config/control.json");
            //configJson = controlConfig.text;
            //configJson = File.ReadAllText(configPath);
            configJson = JsonUtility.ToJson(keyList, true);
            PlayerPrefs.SetString("PlayerController", configJson);
        }
        keyList = JsonUtility.FromJson <CommonButtonList>(configJson);

        foreach (CommonButton tempButton in keyList.buttons)
        {
            switch (tempButton.GetKeyType())
            {
            case KeyType.LEFT: leftKey = tempButton; break;

            case KeyType.RIGHT: rightKey = tempButton; break;

            case KeyType.UP: upKey = tempButton; break;

            case KeyType.DOWN: downKey = tempButton; break;

            case KeyType.SLASH: slashKey = tempButton; break;

            case KeyType.SHOOT: shootKey = tempButton; break;

            case KeyType.JUMP: jumpKey = tempButton; break;

            case KeyType.DASH: dashKey = tempButton; break;

            default: break;
            }
        }
    }