/// <summary> /// 點到闖紅燈的車子 /// </summary> private IEnumerator ClickRed() { btnRed.interactable = false; speed = 0; rect.GetComponent <CircleCollider2D>().enabled = false; Lv5_PoliceVersion1.instance.SetScore(100); icon.SetImage(5); icon.StartUp(); icon.StartFadeInAndOut(); float top = rect.anchoredPosition.y; float topUp = top + 200; //while (top < topUp) //{ // top += 30; // Vector3 pos = rect.anchoredPosition; // pos.y = top; // rect.anchoredPosition = pos; // rect.localScale += Vector3.one * 0.05f; // yield return new WaitForSeconds(0.05f); //} Image img = rect.GetComponent <Image>(); float a = img.color.a; while (a > 0) { a -= 0.3f; img.color = new Color(1, 1, 1, a); yield return(new WaitForSeconds(0.05f)); } }
/// <summary> /// 剛從停止要前往通過位置 /// </summary> private void StartPass() { stop = false; icon.ResetIcon(); icon.StopAllCoroutines(); if (!Lv5_PoliceVersion1.instance.click) { return; // 如果還沒點過按鈕就跳出 第一次不加分 } // 加分 icon.SetImage(0); icon.StartUp(); icon.StartFadeInAndOut(); Invoke("AddScoreDelay", Random.Range(0f, 0.8f)); }