void Start() { OpenDoorCheck = false; //StartCoroutine (ScoreUp ()); Sagam_face.SetActive(false); StartCoroutine(sagam()); }
IEnumerator sagam() { flag = false; flag2 = false; ct = 0; yield return(new WaitForSeconds(1f)); int rnd = Random.Range(0, 9); if (rnd < 3 && OpenDoorCheck == false) { Sagam_face.SetActive(true); if (Score <= 50) { yield return(new WaitForSeconds(2f)); } else if (Score <= 100) { yield return(new WaitForSeconds(1f)); } else { yield return(new WaitForSeconds(0.5f)); } if (function1 != 1) { flag = true; Sagam_face.SetActive(false); door.transform.Rotate(new Vector3(0, 90, 0)); yield return(new WaitForSeconds(1f)); Sagam.SetActive(true); if (function2 != 1) { score += 15; PanaltyScore.text = "" + score; plus.text = "+" + 15; flag2 = true; } else { score += 10; PanaltyScore.text = "" + score; plus.text = "+" + 10; } yield return(new WaitForSeconds(1f)); door.transform.Rotate(new Vector3(0, -90, 0)); plus.text = null; yield return(new WaitForSeconds(2f)); Sagam.SetActive(false); ct++; } if (function2 != 1 && flag2 != true) { score += 5; PanaltyScore.text = "" + score; yield return(new WaitForSeconds(1.5f)); Sagam_face.SetActive(false); if (flag == false) { door.transform.Rotate(new Vector3(0, 90, 0)); yield return(new WaitForSeconds(1f)); Sagam.SetActive(true); plus.text = "+" + 5; yield return(new WaitForSeconds(1f)); door.transform.Rotate(new Vector3(0, -90, 0)); plus.text = null; yield return(new WaitForSeconds(2f)); Sagam.SetActive(false); } } ct++; yield return(new WaitForSeconds(2f)); Sagam_face.SetActive(false); } StartCoroutine(sagam()); }