void OnSceneLoaded(Scene scene, LoadSceneMode mode) { // update the player log every time a scene changes prevScenes[0] = prevScenes[1]; prevScenes[1] = scene.name; if (scene.name == "Menu") { SubmitCurrentRoundData(); } else if (scene.name.StartsWith("Tut") || scene.name.StartsWith("Main")) { Debug.Log("Logging " + currentLevel.ToString() + " rounddata"); currLevelData = new PlayerMovesData(currentLevel); submittedCurrRound = false; } }
// Start is called before the first frame update void Start() { DontDestroyOnLoad(gameObject); LoadGameData(); SceneManager.LoadScene("Menu"); currentLevel = 1; type = 1; currentlyAtTutorial = true; highestTutorial = true; currentProblemArea = ""; prevScenes = new string[2]; playerDataFileName = "playerData" + Directory.GetFiles(Application.streamingAssetsPath, "*.json").Length.ToString() + ".json"; levelIndexes = new int[7]; starsObtained = new int[7]; triedTutorial = new int[6]; tutorialStars = new int[6]; allEquationData.InitializeEquationsByString(); SceneManager.sceneLoaded += OnSceneLoaded; playerLog = new PlayerOverallData(); currLevelData = null; submittedCurrRound = false; // For some reason hardcoding the size at the start fixes resizing // issue between computers. It may look useless but removing the // sizeDelta setting will cause different resolution screens to render // the toys differently. // Setting localScale is so the toy scales with the canvas. Vector3 scale = FindObjectOfType <Canvas>().gameObject.transform.localScale; bearPrefab.GetComponent <RectTransform>().sizeDelta = new Vector2(40, 40); bearPrefab.transform.localScale = scale; boxPrefab.GetComponent <RectTransform>().sizeDelta = new Vector2(40, 40); boxPrefab.transform.localScale = scale; bearCoefPrefab.GetComponent <RectTransform>().sizeDelta = new Vector2(65, 40); bearCoefPrefab.transform.localScale = scale; boxCoefPrefab.GetComponent <RectTransform>().sizeDelta = new Vector2(65, 40); boxCoefPrefab.transform.localScale = scale; bracketPrefab.GetComponent <RectTransform>().sizeDelta = new Vector2(160, 60); bracketPrefab.transform.localScale = scale; }
public void NewRoundData(PlayerMovesData movesData) { playerMovesDataLog.Add(movesData); int level = movesData.level; attemptsPerLevel[level - 1] = attemptsPerLevel[level - 1] + 1; finalStars[level - 1] = finalStars[level - 1] + movesData.starsObtained; numDragsTotal = numDragsTotal + movesData.numDrags; foreach (string dragData in movesData.dragLog) { string[] check = dragData.Split(new string[] { " from " }, StringSplitOptions.None); if (check.Length > 1) { string[] check2 = check[1].Split(new string[] { " to " }, StringSplitOptions.None); string origin = check2[0]; string dest = check2[1]; if (origin.Contains("Drawer")) { numDragsFromDrawer++; } if (dest.Contains("Drawer")) { numDragsToDrawer++; } if ((origin.StartsWith("L") && dest.StartsWith("R")) || (origin.StartsWith("R") && dest.StartsWith("L"))) { if ((origin.EndsWith("Negative") && dest.EndsWith("Positive")) || (origin.EndsWith("Positive") && dest.EndsWith("Negative"))) { numDragsSwitchedSign++; } } } } }