/** * soal selanjutnya ketika player selesai menjawab. * mendetect jawaban benar atau salah. * jika benar TruePoint bertambah FalsePoint Berkurang. * jika salah FalsePoint Bertambah TruePoint berkurang. * penambahan atau pengurangan TruePoint dan FalsePoint bergantung pada nomorSoal semakin besar nomorSoal semakin besar pula pertambahan atau pengurangan point. * jika truePoint atau falsePoint sama dengan PeakPoint maka permainan selesai. * */ public void NextSoal(int isTrue = 99) { System.GC.Collect(); NomorSoal++; HideAllQuiz(); if (isTrue != 99 && isTrue != 1 && isTrue != 0) { Debug.LogError("isTrue must be 1 || 0 || 99"); //random sprite buah rss.ChangeRandom(); } if (isTrue != 99) { if (isTrue == 1) { enemyImage.gameObject.GetComponent <Animator>().SetBool("isHit", true); StartCoroutine("ChangeAniState", enemyImage); TruePoint += NomorSoal; FalsePoint -= NomorSoal; SoundManager.instance.PlayCorrectSound(); //random sprite buah rss.ChangeRandom(); } else if (isTrue == 0) { playerImage.gameObject.GetComponent <Animator>().SetBool("isHit", true); StartCoroutine("ChangeAniState", playerImage); TruePoint -= NomorSoal; FalsePoint += NomorSoal; SoundManager.instance.PlayIncorrectSound(); //random sprite buah rss.ChangeRandom(); } } barUI.ChangeValBar(TruePoint / PeakPoint); Debug.Log(TruePoint / PeakPoint); //Cek apakah point sudah mencapai peak (puncak) if (TruePoint >= PeakPoint) { winScreen.gameObject.SetActive(true); //bg transparan ketika game selesai bgEndBattle.gameObject.SetActive(true); //Invoke("LoadingScene", 2f); Debug.Log("WIN"); } else if (FalsePoint >= PeakPoint) { loseScreen.gameObject.SetActive(true); //bg transparan ketika game selesai bgEndBattle.gameObject.SetActive(true); //Invoke("LoadingScene", 2f); Debug.Log("LOSE"); } else { //generating jenis soal yang ingin dipanggil int RandomSoal = Random.Range(0, AllMiniGameSoal.Count); Debug.Log("initiate soal jenis " + RandomSoal); AllMiniGameSoal[RandomSoal].LoadQuiz(NomorSoal, this); } }