//Save overall path player public static void PathTracing(GameObject obj) { Vector3 current_position = obj.transform.position; Vector3 current_rotation = obj.transform.rotation.eulerAngles; objPath = new PlayerInfo.PathMapping(); int k = CollectionObjs.trialPath.Count; if (k == 0 || CollectionObjs.trialPath[k - 1].s_x != current_position.x && CollectionObjs.trialPath[k - 1].s_z != current_position.z) { objPath.s_x = current_position.x; objPath.s_y = current_position.y; objPath.s_z = current_position.z; objPath.r_x = current_rotation.x; objPath.r_y = current_rotation.y; objPath.r_z = current_rotation.z; objPath.t = CollectionObjs.trial_t; CollectionObjs.trialPath.Add(objPath); } }
// Update is called once per frame void Update() { //Timer trial_t += Time.deltaTime; if (score == menuscore) { treasure.SetActive(false); //Check if the user pressed the button checkbutton = OnButtonPression(); if (checkbutton == true) { //if true saves the position and the time trial_position.Add(player.transform.position); collision_t.Add(trial_t); try { isSaving = true; SubjTrialInfo.InfoTrial infotrial; foreach (Vector3 v in trial_position) { infotrial = new SubjTrialInfo.InfoTrial(); infotrial.ID = objnames[i]; infotrial.s_x = v.x; infotrial.s_y = v.y; infotrial.s_z = v.z; if (i == 0) { infotrial.time = 0; } else { infotrial.time = collision_t[i-1]; } EndTrialInfo.Add(infotrial); i++; } _data = SerializeObject(EndTrialInfo); //Creates xml file with all the info of the trial CreateXML(); Debug.Log("Data Saved"); PlayerInfo.PathMapping overallpath; foreach (Vector3 v in PathIntegration.subpath) { overallpath = new PlayerInfo.PathMapping(); overallpath.s_x = v.x; overallpath.s_y = v.y; overallpath.s_z = v.z; overallpath.r_x = PathIntegration.p_rotation[asd].x; overallpath.r_y = PathIntegration.p_rotation[asd].y; overallpath.r_z = PathIntegration.p_rotation[asd].z; overallpath.t = PathIntegration.p_time[asd]; TrialPath.Add(overallpath); asd++; } _data = SerializeObject(TrialPath); //Creates xml file with all the info of the trial CreateXML(); Debug.Log("Data Saved"); } catch (System.Exception ex) { Debug.LogError(ex.ToString()); } finally { isSaving = false; } //Loads next trial Application.LoadLevel(3); } } }