コード例 #1
0
    private void OnKeyPressed(CharPack pack)
    {
        // Enrich the key pressed details with the position of this char in the word
        pack.charIndex = myIndex;

        // A key pressed event occured, forward it to the parent
        Debug.Log("Key pressed : " + pack);
        mySyllableParent.BuildingSyllable2(pack);
    }
コード例 #2
0
    public void BuildingSyllable(CharPack pack)
    {
        Debug.Log("Input Syllable:  " + thisSyllable.Text);
        Debug.Log("Pack: " + pack);

        bool hit = true;

        char[] syllArray = thisSyllable.Text.ToCharArray();
        for (int i = 0; i < syllArray.Length; i++)
        {
            // String treatments (Remove Diacritics locked by default, for now)
            string input     = myCharInputs[i].text.ToLower().Trim();
            string reference = StringTreatment.RemoveDiacritics(syllArray[i].ToString().ToLower().Trim());

            Debug.Log(input + "=" + reference);

            if (!input.Equals(reference))
            {
                Debug.Log(myCharInputs[i].text + "=" + syllArray[i]);
                hit = false;
                break;
            }

            myCharInputs[i].transform.parent.GetComponent <Image>().color = Color.green;
        }

        if (pack.enter)
        {
            myInputZoneParent.SendWholeInputText();
            return;
        }


        if (hit)
        {
            SyllableHit(pack.charIndex);

            //LockInputs();

            return;
        }

        // Move forward/backward according to key pressed
        if (pack.backspace || pack.leftArrow)
        {
            if (pack.charIndex > 0)
            {
                myInputZoneParent.SelectPreviousCharInput(pack.charIndex);
            }
        }
        else
        {
            myInputZoneParent.SelectNextCharInput(pack.charIndex);
        }
    }
コード例 #3
0
    public void BuildingSyllable2(CharPack pack)
    {
        Debug.Log("Full Syllable:  " + thisSyllable.Text);
        Debug.Log("Pack: " + pack);

        if (pack.enter)
        {
            myInputZoneParent.SendWholeInputText();
            return;
        }

        int hits = thisSyllable.Text.Length;

        char[] syllArray = thisSyllable.Text.ToCharArray();
        for (int i = 0; i < syllArray.Length; i++)
        {
            // String treatments (Remove Diacritics locked by default, for now)
            string input     = myCharInputs[i].text.ToLower().Trim();
            string reference = StringTreatment.RemoveDiacritics(char.ToLower(syllArray[i]).ToString());

            Debug.Log(input + " should be equal to " + reference);

            if (!input.Equals(reference))
            {
                Debug.Log(myCharInputs[i].text + "!=" + syllArray[i]);

                if (input.Length == 0 && !thisSyllable.Text.Contains(input))
                {
                    myCharInputs[i].transform.parent.GetComponent <Image>().color = Color.red;
                }

                if (input.Length == 0 && thisSyllable.Text.Contains(input))
                {
                    myCharInputs[i].transform.parent.GetComponent <Image>().color = Color.yellow;
                }
            }
            else
            {
                hits--;
                myCharInputs[i].transform.parent.GetComponent <Image>().color = Color.green;
                //LockInput(i);
            }

            if (hits <= 0)
            {
                SyllableHit(pack.charIndex);
                return;
            }
        }

        foreach (LXInputField g in myCharInputs)
        {
            if (g.text.Length == 0)
            {
                g.transform.parent.GetComponent <Image>().color = originalColor;
            }
        }

        if (pack.backspace && pack.charString.Length != 0)
        {
            myCharInputs[pack.charIndex].text = string.Empty;
            return;
        }


        // Move forward/backward according to key pressed
        if (pack.backspace || pack.leftArrow)
        {
            //myCharInputs[pack.charIndex].text = string.Empty;

            if (pack.charIndex > 0)
            {
                myInputZoneParent.SelectPreviousCharInput(pack.charIndex);
            }
        }
        else
        {
            myInputZoneParent.SelectNextCharInput(pack.charIndex);
        }
    }