in clients/unity/Assets/Scripts/StratSwitch_2DSingleDetection.cs [101:154]
IEnumerator RunExperiment()
{
while (!isDone) {
Debug.Log("trial# " + trialNum + " strat "+currentStrat + " strat's trial# " + AEPsychStrats[currentStrat].currentTrial);
SetText("Querying for next trial");
yield return StartCoroutine(client.Ask());
config = client.GetConfig();
SetText("Now presenting stimulus.");
yield return StartCoroutine(PresentStimulus(config));
SetText("Was it visible? (Y/N)");
yield return StartCoroutine(LogUserInput());
//check if strat or experiment is done
if (client.finished) //check if this was the final ask for this strat
{
SetText("Strat is complete.");
AEPsychStrats[currentStrat].isDone = true;
if (checkFinished())
{
SetText("Experiment complete");
isDone = true;
break;
}
}
AEPsychStrats[currentStrat].currentTrial++;
trialNum++;
//in this example, switch every 5 trials
if (AEPsychStrats[currentStrat].currentTrial % 5 == 4)
{
currentStrat = (currentStrat + 1) % numStrats;
while (AEPsychStrats[currentStrat].isDone)
{
currentStrat = (currentStrat + 1) % numStrats;
}
Debug.Log("switched to strat " + currentStrat);
yield return StartCoroutine(client.Resume(AEPsychStrats[currentStrat].stratId));
}
}
yield return 0;
}