// show word from collection with desired index public void ShowScramble(int index) { charObjects.Clear(); foreach (Transform child in container) { Destroy(child.gameObject); } if (index > words.Length - 1) { gameDone(); return; } char[] chars = words[index].GetString().ToCharArray(); foreach (char c in chars) { CharObject1 clone = Instantiate(prefab.gameObject).GetComponent <CharObject1>(); clone.transform.SetParent(container); charObjects.Add(clone.Init(c)); } currentWord = index; StartCoroutine(TimeLeft()); }
public void SwapCharObject(int indexA, int indexB) { CharObject1 tmpA = charObjects[indexA]; charObjects[indexA] = charObjects[indexB]; charObjects[indexB] = tmpA; charObjects[indexA].transform.SetAsLastSibling(); //top one, if setAsFirstSibling means bottom one charObjects[indexB].transform.SetAsLastSibling(); CheckWord(); }
public void Select(CharObject1 charObject) { if (firstSelected) { SwapCharObject(firstSelected.charIndex, charObject.charIndex); firstSelected.Select(); charObject.Select(); } else { firstSelected = charObject; } }
public void UnSelect() { firstSelected = null; }