public void StartGame()
        {
            LobbySave save = new LobbySave();

            save.ScriptCount = _number;
            save.ScriptPaths = new string[_number];
            save.ColorInds   = new int[_number];

            _scripts = new string[_number];
            for (int i = 0; i < _number; i++)
            {
                GameObject box = ScriptList.GetAt(i);
                _scripts[i]         = box.GetComponent <InputField>().text;
                save.ScriptPaths[i] = _scripts[i];
                save.ColorInds[i]   = ScriptList.GetColorIndex(i);
            }

            float oldVolume = 1.0f;

            if (File.Exists("prefs.json"))
            {
                string    saveJson = File.ReadAllText("prefs.json");
                LobbySave oldSave  = JsonUtility.FromJson <LobbySave>(saveJson);
                oldVolume = oldSave.Volume;
            }

            save.Volume = oldVolume;
            string json = JsonUtility.ToJson(save, true);

            File.WriteAllText("prefs.json", json);

            StartCoroutine(LoadMainScene());
        }
Exemplo n.º 2
0
 void InitVolumeSlider()
 {
     _volumeSlider = transform.GetChild(0).Find("VolumeSlider").gameObject.GetComponent <Slider>();
     if (File.Exists("prefs.json"))
     {
         string    saveJson = File.ReadAllText("prefs.json");
         LobbySave save     = JsonUtility.FromJson <LobbySave>(saveJson);
         SetupSlider(save.Volume);
     }
 }
Exemplo n.º 3
0
        public void ExitClick()
        {
            if (File.Exists("prefs.json"))
            {
                string    saveJson = File.ReadAllText("prefs.json");
                LobbySave save     = JsonUtility.FromJson <LobbySave>(saveJson);
                save.Volume = GetSliderVal();
                Debug.Log("Volume: " + save.Volume);
                saveJson = JsonUtility.ToJson(save, true);
                File.WriteAllText("prefs.json", saveJson);
            }
            //Application.Quit();
            GameController controller = FindObjectOfType <GameController>();

            controller.RequestQuitGame();
        }
        void SetupLobby()
        {
            ProgressBar.Setup();
            ProgressBar.SetHp(0);

            if (File.Exists("prefs.json"))
            {
                string    saveJson = File.ReadAllText("prefs.json");
                LobbySave save     = JsonUtility.FromJson <LobbySave>(saveJson);

                //GameObject.Find("Menu").GetComponent<GameMenu>().SetupSlider(save.Volume);

                GameObject box1 = ScriptList.GetAt(0);
                box1.GetComponent <InputField>().text = save.ScriptPaths[0];

                if (save.ColorInds != null)
                {
                    ScriptList.SetColorIndex(0, save.ColorInds[0]);
                }

                GameObject box2 = ScriptList.GetAt(1);
                box2.GetComponent <InputField>().text = save.ScriptPaths[1];
                if (save.ColorInds != null)
                {
                    ScriptList.SetColorIndex(1, save.ColorInds[1]);
                }


                for (int i = 2; i < save.ScriptCount; i++)
                {
                    IncCount();
                    GameObject box = ScriptList.GetAt(i);
                    box.GetComponent <InputField>().text = save.ScriptPaths[i];
                    if (save.ColorInds != null)
                    {
                        ScriptList.SetColorIndex(i, save.ColorInds[i]);
                    }
                }
            }
        }