void CheckMusicAgainstTiming() { //make note of time which you touched screen //plus an offset float hitTime = m_MusicTime; //go through list for (int i = 0; i < m_MusicList.Count; i++) { if (hitTime > m_MusicList[i] - EXCELLENT_MIN_MAX && hitTime < m_MusicList[i] + EXCELLENT_MIN_MAX) { m_ComboScript.IncreaseCombo(1); m_NumExcellents++; m_ScoreScript.IncreaseScore(100); UpdateScoreText(); m_TextResult = m_Excellent.gameObject; InstantiateTextGameObject(); //Remove the timing that we checked just now from the list //There was an error before where, if the timings were too close together (2.5f, 2.7f, 2.9f), the timing wouldn't know which to test against. //By removing a timing from the list, the code won't retest a timing we have tried before. m_MusicList.Remove(m_MusicList[i]); StartCoroutine("ToggleTouchPanelSpark"); return; } else if (hitTime > m_MusicList[i] - GOOD_MIN_MAX && hitTime < m_MusicList[i] + GOOD_MIN_MAX) { m_ComboScript.IncreaseCombo(1); m_NumGoods++; m_ScoreScript.IncreaseScore(10); UpdateScoreText(); m_TextResult = m_Good.gameObject; InstantiateTextGameObject(); m_MusicList.Remove(m_MusicList[i]); return; } else { //once i is the last one in the list if (i == m_MusicList.Count - 1) { MissDetected(); m_NumPoors++; UpdateScoreText(); m_TextResult = m_Poor.gameObject; InstantiateTextGameObject(); } } } }