// Start is called before the first frame update public void SetStartParams() { if (PlayerPrefs.GetString("Sound") == "On") { tapSound.Play(); } ShowCoins(); storeScript = GameObject.FindWithTag("Store").GetComponent <Store>(); tsaver = new TuningSaver(); currentRocketIdx = storeScript.selectedPanID; rocketImgPanel.GetComponent <Image>().sprite = (Sprite)storeScript.images[currentRocketIdx]; #if UNITY_ANDROID && !UNITY_EDITOR path = Path.Combine(Application.persistentDataPath, "settings.JSON"); #else path = Path.Combine(Application.dataPath, "settings.JSON"); #endif if (File.Exists(path)) { fileLinesArr = File.ReadAllLines(path); indexCurLine = Array.FindIndex(fileLinesArr, str => str.Contains(storeScript.names[currentRocketIdx])); tsaver = JsonUtility.FromJson <TuningSaver>(fileLinesArr[indexCurLine]); } ShowSettings(); }
void SetFirstSettings() { if (!PlayerPrefs.HasKey("Base")) { PlayerPrefs.SetString("Sound", "On"); PlayerPrefs.SetInt("Base", 1); PlayerPrefs.SetString("Selected", "Base"); } #if UNITY_ANDROID && !UNITY_EDITOR path = Path.Combine(Application.persistentDataPath, "settings.JSON"); #else path = Path.Combine(Application.dataPath, "settings.JSON"); #endif if (!File.Exists(path)) { List <string> settingsList = new List <string>(); TuningSaver ts = new TuningSaver(); foreach (var rocket in StaticPrefabs.rocketDictionary) { ts.name = rocket.Key; ts.speed = 2; ts.fuelConsumptionSpeed = 1; ts.control = 1; ts.resourceTime = 1; ts.levelSpeed = 0; ts.levelFuel = 0; ts.levelControl = 0; ts.levelResource = 0; settingsList.Add(JsonUtility.ToJson(ts)); } File.WriteAllLines(path, settingsList); } }
public void SetRocketSettings() { string path; #if UNITY_ANDROID && !UNITY_EDITOR path = Path.Combine(Application.persistentDataPath, "settings.JSON"); #else path = Path.Combine(Application.dataPath, "settings.JSON"); #endif TuningSaver ts = new TuningSaver(); if (File.Exists(path)) { string[] fileLinesArr = File.ReadAllLines(path); int indexCurLine = Array.FindIndex(fileLinesArr, str => str.Contains(rocketName)); ts = JsonUtility.FromJson <TuningSaver>(fileLinesArr[indexCurLine]); } RocketFly rocketScript = rocket.GetComponent <RocketFly>(); rocketScript.speed = ts.speed; rocketScript.control = ts.control; rocketScript.resourceTime = ts.resourceTime; rocketScript.fuelConsumptionSpeed = ts.fuelConsumptionSpeed; }