/* Single Flash Operation */ IEnumerator SingleFlash() { while (startFlashes) { //Generate a random number from the list of indices that have non-zero counters System.Random random = new System.Random(); int randomIndex = random.Next(s_indexes.Count); int randomShapeIndex = s_indexes[randomIndex]; //Turn off the cubes to give the flashing image TurnOff(); //If the counter is non-zero, then flash that cube and decrement the flash counter if (flash_counter[randomShapeIndex] > 0) { yield return(new WaitForSecondsRealtime((1f / freqHz))); Shapes2D.Shape randomShape = arcShapes[randomIndex]; randomShape.settings.fillColor = onColor; flash_counter[randomShapeIndex]--; counter++; //print("CUBE: " + randomShape.ToString()); //print(counter); //Write to the LSL Outlet stream marker.Write("s," + randomShape.ToString()); } else if (numTrials == counter) { print("Done P300 Single Flash Trials"); break; } else { //If the counter for a specific cube has reached zero, then remove it from the indexes so that the random //number generator does not pick it again (to reduce lag) if (flash_counter[randomShapeIndex] == 0) { s_indexes.RemoveAt(randomIndex); } //Go to the next iteration of the single flash continue; } yield return(new WaitForSecondsRealtime(flashLength)); } ResetCounters(); //Write to LSL stream to indicate end of P300 SingleFlash //marker.Write("P300 SingleFlash Ends"); startFlashes = !startFlashes; //keyLocks[KeyCode.S] = !keyLocks[KeyCode.S]; }
public void TurnOff() { for (int i = 0; i < arcShapes.Count; i++) { Shapes2D.Shape shape = arcShapes[i]; string shapeName = shape.ToString(); if (shapeName.Contains("Large")) { shape.settings.fillColor = largeColor; } else if (shapeName.Contains("Medium")) { shape.settings.fillColor = mediumColor; } else { shape.settings.fillColor = smallColor; } } }