Exemplo n.º 1
0
    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();
        }
    }
Exemplo n.º 2
0
 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));
 }
Exemplo n.º 3
0
 void InitiateBuah()
 {
     foreach (GameObject go in gambarBuah)
     {
         Buah buah = DatabaseBuah.Instance.GetRandomBuah();
         go.GetComponent <Image>().sprite = buah.sprite;
     }
 }
Exemplo n.º 4
0
 void InitiateBuah()
 {
     for (int i = 0; i < 14; i++)
     {
         Buah tmpBuah = DatabaseBuah.Instance.GetRandomBuah();
         daftarBuah.Add(tmpBuah);
     }
 }
Exemplo n.º 5
0
    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";
         * }*/
    }
Exemplo n.º 6
0
    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";
         * }*/
    }