コード例 #1
0
    void OnCollisionEnter2D(Collision2D col)
    {
        if (col.gameObject.tag == "Jawaban")
        {
            TextMeshPro txtPilih = col.gameObject.GetComponent <TextMeshPro>();
            //Debug.Log("OnCollisionEnter2D : " +  txtPilih.text);
            if (GameAction.ARRAY_SOAL.Contains(txtPilih.text))
            {
                TRUE_SOUND.Play();
                GameAction.TRUE_ANS++;
                GameAction.KATA_JAWAB.Add(txtPilih.text);
                int idx = GameAction.ARRAY_BENAR.IndexOf(txtPilih.text);
                GameAction.KATA_SOAL[idx] = txtPilih.text;

                string strFix = string.Join(" ", GameAction.KATA_SOAL.ToArray());
                strFix = strFix.ToLower();
                strFix = GameControls.UppercaseWords(strFix);

                GameAction.TEXT_SOAL = strFix;
                GameAction.ARRAY_SOAL.Remove(txtPilih.text);

                if (GameAction.TRUE_ANS >= GameAction.ITEM_LEVEL[GameAction.GAME_LEVEL])
                {
                    GameAction.SCORES     += 10;
                    GameAction.GAME_STATUS = true;
                }
            }
            else
            {
                GameAction.TRY_COUNT++;
                WRONG_SOUND.Play();
            }
            col.gameObject.transform.position = new Vector3(col.gameObject.transform.position.x - 1000, col.gameObject.transform.position.y);
        }
    }