Actually comment the code

This commit is contained in:
Chris Midkiff 2020-05-27 02:10:41 -04:00
parent c101d05ff1
commit 8508de23c1
2 changed files with 13 additions and 1 deletions

View File

@ -34,6 +34,7 @@ public class ExperimentController : MonoBehaviour {
UnityEngine.Debug.Log(platform); UnityEngine.Debug.Log(platform);
string response = ""; string response = "";
UnityEngine.Debug.Log(Application.persistentDataPath); UnityEngine.Debug.Log(Application.persistentDataPath);
//Load Trial data from server
using (WebClient client = new WebClient()) using (WebClient client = new WebClient())
{ {
string endpoint = "http://<URL OF SERVER INSTANCE>" + platform; string endpoint = "http://<URL OF SERVER INSTANCE>" + platform;
@ -45,6 +46,7 @@ public class ExperimentController : MonoBehaviour {
playerCamera = GameObject.FindGameObjectsWithTag("MainCamera")[0]; playerCamera = GameObject.FindGameObjectsWithTag("MainCamera")[0];
trialIndex = 0; trialIndex = 0;
trialDotIndex = 0; trialDotIndex = 0;
//Hide all the non-start dots and the DONE text
foreach (GameObject go in GameObject.FindGameObjectsWithTag("Dot")) foreach (GameObject go in GameObject.FindGameObjectsWithTag("Dot"))
{ {
dots.Add(go); dots.Add(go);
@ -67,6 +69,7 @@ public class ExperimentController : MonoBehaviour {
public void NextDot() public void NextDot()
{ {
//Stop the timer if it is running.
if (stopwatch.IsRunning) if (stopwatch.IsRunning)
{ {
stopwatch.Stop(); stopwatch.Stop();
@ -74,8 +77,10 @@ public class ExperimentController : MonoBehaviour {
stopwatch.Reset(); stopwatch.Reset();
double angle = Vector3.Angle(nextDot.transform.position, playerCamera.transform.position); double angle = Vector3.Angle(nextDot.transform.position, playerCamera.transform.position);
//double distance = Vector3.Distance(nextDot.transform.position, startDot.transform.position); //double distance = Vector3.Distance(nextDot.transform.position, startDot.transform.position);
//Save a sample
SaveSample(angle, time, false); SaveSample(angle, time, false);
} }
//Advance to the next dot and make it visible, while hiding the start dot.
if (trialDotIndex < participant.trials[trialIndex].Length) if (trialDotIndex < participant.trials[trialIndex].Length)
{ {
@ -84,10 +89,12 @@ public class ExperimentController : MonoBehaviour {
Show(nextDot); Show(nextDot);
Hide(startDot); Hide(startDot);
} }
//Advance to the next trial
else if(trialIndex < participant.trials.Length) else if(trialIndex < participant.trials.Length)
{ {
trialIndex++; trialIndex++;
trialDotIndex = 0; trialDotIndex = 0;
//Save data if we aren't in practice mode.
if(participant.participantId != 9999) dataSet.SaveDataSet(); if(participant.participantId != 9999) dataSet.SaveDataSet();
dataSet.Samples.Clear(); dataSet.Samples.Clear();
if (trialIndex < participant.trials.Length && participant.participantId != 9999) if (trialIndex < participant.trials.Length && participant.participantId != 9999)
@ -104,6 +111,7 @@ public class ExperimentController : MonoBehaviour {
} }
else else
{ {
//Save data if we aren't in practice mode.
if (participant.participantId != 9999) dataSet.SaveDataSet(); if (participant.participantId != 9999) dataSet.SaveDataSet();
} }
stopwatch.Start(); stopwatch.Start();
@ -111,6 +119,7 @@ public class ExperimentController : MonoBehaviour {
} }
//Hide current dot, Show start dot, and reset the timer.
public void BackToStart() public void BackToStart()
{ {
stopwatch.Stop(); stopwatch.Stop();
@ -118,6 +127,7 @@ public class ExperimentController : MonoBehaviour {
stopwatch.Reset(); stopwatch.Reset();
double angle = Vector3.Angle(nextDot.transform.position, playerCamera.transform.position); double angle = Vector3.Angle(nextDot.transform.position, playerCamera.transform.position);
//double distance = Vector3.Distance(nextDot.transform.position, startDot.transform.position); //double distance = Vector3.Distance(nextDot.transform.position, startDot.transform.position);
//Save a sample
SaveSample(angle, time, true); SaveSample(angle, time, true);
Hide(nextDot); Hide(nextDot);
Show(startDot); Show(startDot);
@ -126,6 +136,7 @@ public class ExperimentController : MonoBehaviour {
} }
//Wrapper method to convert the Cardboard way of handling things to the Oculus one.
public void CardboardWrapper(GameObject go, PointerEventData eventData) public void CardboardWrapper(GameObject go, PointerEventData eventData)
{ {
UnityEngine.Debug.Log(eventData.pointerPressRaycast.worldPosition); UnityEngine.Debug.Log(eventData.pointerPressRaycast.worldPosition);
@ -151,6 +162,7 @@ public class ExperimentController : MonoBehaviour {
{ {
Sample sample = new Sample(); Sample sample = new Sample();
sample.Angle = angle; sample.Angle = angle;
//Fill in dot distances.
if(nextDot.name.Contains("Short")){ if(nextDot.name.Contains("Short")){
sample.Distance = 500; sample.Distance = 500;
} }

View File

@ -7,7 +7,7 @@ public class Participant
public string[][] trials; public string[][] trials;
public string inputMethod; public string inputMethod;
public int participantId; public int participantId;
//Parse data from server.
public Participant(string json) public Participant(string json)
{ {
JObject jObject = JObject.Parse(json); JObject jObject = JObject.Parse(json);