private void SaveData() { savePath = System.IO.Path.GetFullPath(savePath); Debug.Log("Sauvegarde des données : " + savePath); //title.text = System.IO.Path.GetFullPath(savePath); string header = System.DateTime.Now.ToString() + " - Trait visible: " + isDrawingVisible + " - Taille: " + size * 20 + " - Nombre de point: " + pointPositions.Length + "/" + nombreMaxPoint; CSVScript.SaveDataToCSV(savePath, dataPositionCollected, header: header); }
public void SaveDataBis() { int variableAure = PlayerPrefs.GetInt("variableAure"); savePath = System.IO.Path.GetFullPath("C:/Dev/Cassiopee-project/Neurotest/Assets/Users/" + variableAure + ".csv"); PlayerPrefs.SetInt("variableAure", variableAure + 1); List <Vector2> pointPositionCollected = new List <Vector2>(); for (int i = 0; i < pointPositions.Length; i++) { pointPositionCollected.Add(new Vector2(pointPositions[i].x, pointPositions[i].y)); } Debug.Log("Sauvegarde des données : " + savePath); //title.text = System.IO.Path.GetFullPath(savePath); CSVScript.SaveDataToCSV(savePath, pointPositionCollected); GoToNextLevel(); }
private void GenerateLevelData() { Vector3 screenSize = Camera.main.ScreenToWorldPoint(new Vector3(Camera.main.pixelHeight, Camera.main.pixelWidth)); int height = (int)screenSize[0]; int width = (int)screenSize[1]; if (!isRandomPosition) { string pointPath = Application.persistentDataPath + "/niveaux/" + difficultyFR + "/" + chiffreOuLettre + "/" + currentLevel + ".txt"; pointPath = System.IO.Path.GetFullPath(pointPath); Debug.Log("Looking for data at: " + pointPath); string[,] read = CSVScript.ReadCSV(pointPath); nombreMaxPoint = read.Length / 2; if (read[read.Length / 2 - 1, 0] == null) // Si il y a une ligne vide à la fin du fichier { nombreMaxPoint -= 1; } int sizePointArray = Math.Min(nombreMaxPoint, PlayerPrefs.GetInt(currentPlayer + "_option_numberPoints")); pointPositions = new Vector2[sizePointArray]; for (int i = 0; i < sizePointArray; i++) { if (read[i, 0] == null) { break; } pointPositions[i][0] = float.Parse(read[i, 0]); pointPositions[i][1] = float.Parse(read[i, 1]); } } else { int rand1 = 0; int rand2 = 0; pointPositions[0][0] = (int)UnityEngine.Random.Range(18, width - 18); pointPositions[0][1] = (int)UnityEngine.Random.Range(18, height - 40); for (int i = 1; i < pointPositions.Length; i++) { bool test = true; bool val = true; int noFreeze = 0; while (val) { noFreeze++; rand1 = (int)UnityEngine.Random.Range(18, width - 18); rand2 = (int)UnityEngine.Random.Range(18, height - 40); for (int j = 0; j < i; j++) { if (Math.Sqrt(Math.Pow(rand1 - pointPositions[j][0], 2) + Math.Pow(rand2 - pointPositions[j][1], 2)) < 22) { test = false; } } if (test) { pointPositions[i][0] = rand1; pointPositions[i][1] = rand2; val = false; } if (noFreeze > 10000) { pointPositions[i][0] = rand1; pointPositions[i][1] = rand2; val = false; } PlayerPrefs.SetInt(playerPrefLevelPath, currentLevel - 1); } } } }