Beispiel #1
0
    /// <summary>
    /// show word from collection with desired index
    /// </summary>
    /// <param name="index">index of the element</param>
    public void ShowScramble(int index)
    {
        charObjs.Clear();
        foreach (Transform child in container)
        {
            Destroy(child.gameObject);
        }

        if (index > words.Length - 1)
        {
            //Debug.LogError("index out of range,please enter range between 0 to " + (words.Length - 1).ToString());
            Debug.Log("You Won");
            return;
        }

        char[] chars = words[index].GetString().ToCharArray();
        foreach (char c in chars)
        {
            CharObj clone = Instantiate(prefab.gameObject).GetComponent <CharObj>();
            clone.transform.SetParent(container);

            charObjs.Add(clone.Init(c));
        }

        currentWord = index;
        StartCoroutine(TimeLimit());
    }