public void Jawab(Buah buah) { if (buah == jawaban) { Debug.Log("Benar"); benar++; StartCoroutine(PreparingSuaraBenar()); if (currentPhase < level [currentLevel].phase - 1) { currentPhase++; GeneratingQuestion(); } else { ShowReward(); } } else { Debug.Log("Salah"); salah++; StartCoroutine(PreparingSuaraSalah()); GetComponent <AudioSource> ().clip = clipSalah; GetComponent <AudioSource> ().Play(); GeneratingQuestion(); } }
void ShowInformasi(Buah buah) { informasiPanel.SetActive(true); informasiGambar.GetComponent <Image> ().sprite = buah.sprite; GetComponent <AudioSource> ().clip = buah.clipManfaat; GetComponent <AudioSource> ().Play(); StartCoroutine(ShowCloseButton(buah.clipManfaat.length)); }
void InitiateBuah() { foreach (GameObject go in gambarBuah) { Buah buah = DatabaseBuah.Instance.GetRandomBuah(); go.GetComponent <Image>().sprite = buah.sprite; } }
void InitiateBuah() { for (int i = 0; i < 14; i++) { Buah tmpBuah = DatabaseBuah.Instance.GetRandomBuah(); daftarBuah.Add(tmpBuah); } }
public void GeneratingQuestion() { soalText.text = level [currentLevel].warna[currentPhase].ToString(); DatabaseSuara.instance.PlaySuara(level [currentLevel].warna[currentPhase]); jawaban = level [currentLevel].warna [currentPhase]; buahLoaded.Clear(); for (int i = 0; i < buahPilihan.Length; i++) { Buah buah = DatabaseBuah.Instance.GetRandomBuah(); // Biar gak ada buah yang sama while (buahLoaded.Exists(x => x.nama == buah.nama)) { buah = DatabaseBuah.Instance.GetRandomBuah(); } // Biar gak ada dua jawaban if (buahLoaded.Exists(x => x.warna == jawaban)) { while (buah.warna == jawaban) { buah = DatabaseBuah.Instance.GetRandomBuah(); } } buahLoaded.Add(buah); buahPilihan [i].GetComponent <TombolBuah> ().buah = buah; buahPilihan [i].GetComponent <Image> ().sprite = buah.sprite; } // Generate ulang apabila tidak ada jawaban yang benar if (!buahLoaded.Exists(x => x.warna == jawaban)) { GeneratingQuestion(); } /*if (GameManager.Instance.level == 1) { * soalText.text = namaWarnaLevel1 [0]; * } * else if (GameManager.Instance.level == 2) { * soalText.text = namaWarnaLevel2 [0]; * } * else if (GameManager.Instance.level == 3) { * soalText.text = namaWarnaLevel3 [0]; * } * else if (GameManager.Instance.level == 4) { * soalText.text = namaWarnaLevel4 [0]; * } * else if (GameManager.Instance.level == 5) { * soalText.text = namaWarnaLevel5 [0]; * } * else { * soalText.text = "sasa"; * }*/ }
public void GeneratingQuestion() { buahLoaded.Clear(); for (int i = 0; i < buahPilihan.Length; i++) { Buah buah = DatabaseBuah.Instance.GetRandomBuah(); // Biar gak ada buah yang sama while (buahLoaded.Exists(x => x.nama == buah.nama)) { buah = DatabaseBuah.Instance.GetRandomBuah(); } buahLoaded.Add(buah); buahPilihan [i].GetComponent <TombolBuah> ().buah = buah; buahPilihan [i].GetComponent <Image> ().sprite = buah.sprite; } Buah buahJawaban = buahPilihan [Random.Range(0, buahPilihan.Length)].GetComponent <TombolBuah> ().buah; soalText.text = buahJawaban.nama; jawaban = buahJawaban; /*if (GameManager.Instance.level == 1) { * soalText.text = namaWarnaLevel1 [0]; * } * else if (GameManager.Instance.level == 2) { * soalText.text = namaWarnaLevel2 [0]; * } * else if (GameManager.Instance.level == 3) { * soalText.text = namaWarnaLevel3 [0]; * } * else if (GameManager.Instance.level == 4) { * soalText.text = namaWarnaLevel4 [0]; * } * else if (GameManager.Instance.level == 5) { * soalText.text = namaWarnaLevel5 [0]; * } * else { * soalText.text = "sasa"; * }*/ }