IEnumerator StartEvent(float timer) { float time = 0; //trigger event while (time <= timer) { time += Time.deltaTime; if (currentTemp.Count > 0) { if (Input.GetAxis("Fire1") > 0) { if ((Vector2.Distance(Camera.main.GetComponent <Camera>().WorldToScreenPoint(currentTemp.Peek().position), Input.mousePosition)) <= radiusDetection) { currentTemp.Peek().GetComponent <Image>().enabled = false; currentTemp.Dequeue(); } } } else //if they finished the shape end the coroutines { //if the player completes quickly if (time <= timer - RunwayHandler.swpBonus) { wonLast = true; FinalJudgement.beaBnsPts++; print("Win (Swipe)"); } else { //A "tie" condition, does not increase difficulty and/or bonus points tie = true; print("Tie (Swipe)"); } StopAllCoroutines(); isRunning = false; GetComponent <Image> ().enabled = false; playerReactScript.QuickMove(); RunwayHandler.eventRunning = false; RunwayHandler.swipeWin = wonLast; } //yield return new WaitForSeconds(Time.deltaTime); yield return(null); } print("Lose (Swipe)"); wonLast = false; tie = false; splatter.SetActive(true); splatter.GetComponent <SplatEffectFade>().DoSplatter(); splatter.GetComponent <AudioSource>().Play(); FinalJudgement.beaBnsPts--; isRunning = false; GetComponent <Image> ().enabled = false; RunwayHandler.eventRunning = false; foreach (Transform pos in patternList) { currentTemp.Enqueue(pos); pos.GetComponent <Image>().enabled = false; } }