public void UpdateLevel(int locNum) { currentLevel = levels[locNum]; targetScoreText = currentLevel.targetScore; scoreToBeat = currentLevel.scoreToBeat; Debug.Log("Level Updated"); }
public void RunManager() { levelNum = SceneManager.GetActiveScene().buildIndex; switch (levelNum) { case 0: print("level0"); LTfilePath = "/Files/Level0Target.json"; break; case 1: print("level1"); LTfilePath = "/Files/Level1Target.json"; break; case 2: print("level2"); LTfilePath = "/Files/Level2Target.json"; break; case 3: print("level3"); LTfilePath = "/Files/Level3Target.json"; break; case 4: print("level4"); LTfilePath = "/Files/Level4Target.json"; break; default: print("level not determined"); LTfilePath = "/Files/Level0Target.json"; break; } string locPath = Application.dataPath + LTfilePath; //full path to files #region LevelTargetManager levels = new levelTarget[numLevels]; //init array to have numLevels slots for (int i = 0; i < levels.Length; i++) { //string locPath = LTfilePath.Replace("<num>", "" + i); //creating a path to file num "i" string fileContent = File.ReadAllText(locPath); //fileContent will hold all the text from the file at locPath levelTarget l = JsonUtility.FromJson <levelTarget>(fileContent); levels[i] = l; } UpdateLevel(0); #endregion //scoreText = GetComponentInChildren<Text>(); //get the text component from the children of this gameObject }