public void CheckAns() { if (Ans != -1) //Answer and Click Shoot //If Wrong Answer { if (Ans != Answer && Ans != -2) { Ans = -1; ShowAns.text = ""; AudioSound.PlaySound("Wrong"); } else { //If Right Answer if (Ans == Answer) { BoomText.Play(); AudioSound.PlaySound("Shoot"); Qt [n].gameObject.SetActive(false); } countQt++; if (countQt <= 2) { n = Random.Range(0, Qt.Length); Debug.Log("สุ่ม ได้ " + n.ToString()); while (n == Arr [0] || n == Arr [1]) { n = Random.Range(0, Qt.Length); Debug.Log("สุ่มอีกที " + n.ToString()); } j += 1; Arr [j] = n; Qt [n].gameObject.SetActive(true); Ans = -1; ShowAns.text = ""; } } } else //Not Answer and Click Shoot { ShowAns.text = "กรุณากดตัวเลขก่อนกดปุ่มยิง"; } }
public void PlaySound(string fxFilename) { sound.PlaySound(fxFilename); }
public void CheckAns() { if (Ans != -1) { //Wrong Answer if (Ans != Answer && Ans != -2) { if (Sc != 0) { Sc = Sc - 5; } AudioSound.PlaySound("Wrong"); MinusText2.Play(); Ans = -1; ShowAns.text = ""; Score.text = "Score: " + Sc; } else { //Right Answer if (Ans == Answer) { Sc = Sc + (30 - int.Parse(Mathf.Round(time).ToString())); BoomText.Play(); AudioSound.PlaySound("Shoot"); Alients.gameObject.SetActive(false); } //No Answer if (Ans == -2) { if (Sc != 0) { Sc = Sc - 15; } AudioSound.PlaySound("Damaged"); MinusText.Play(); } time = 0; countQt++; StartCoroutine(WaitToStart()); if (countQt <= 25) { n = Random.Range(0, QtSet.Length); Debug.Log(n.ToString()); CurrQt = Qt(QtSet [n]); while (CurrQt == LastQt) { CurrQt = Qt(QtSet [n]); } Questions.text = CurrQt; Ans = -1; ShowAns.text = ""; Score.text = "Score: " + Sc; if (countQt < 25) { ShowNumOfQt.text = (countQt + 1) + "/25"; } } } } else //Not Answer and Click Shoot { ShowAns.text = "กรุณากดตัวเลขก่อนกดปุ่มยิง"; } }