public void ShowSpell(int index) { charObject.Clear(); foreach (Transform child in containerA) { Destroy(child.gameObject); } if (index > word.Length) { Debug.LogError("index out of rang, please enter rang between 0-" + (word.Length - 1).ToString()); return; } gameWord = word[index].word; char[] chars = word[index].GetString().ToCharArray(); foreach (char c in chars) { CharObject clone = Instantiate(prefebA.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(containerA); charObject.Add(clone.Init(c)); } currentWord = index; }
// 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) { CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(container); charObjects.Add(clone.Init(c)); } currentWord = index; StartCoroutine(TimeLeft()); }
/// <summary> /// Show word from collection with desired index /// </summary> /// <param name="index">index of the element</param> public void ShowScramble(int index) { charObjects.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-" + (words.Length - 1)); PlayerPrefs.SetInt(PlayerPrefs.GetString("PlayerName"), result.totalScore); PlayerPrefs.Save(); LoadMenu(); return; } char[] chars = words[index].GetString().ToCharArray(); //print(chars[0]); foreach (char c in chars) { CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(container); charObjects.Add(clone.Init(c)); // print(words[index].word); } currentWord = index; StartCoroutine(TimeLimit()); }
// show word from collection with certain index public void ShowScramble(int index) { charObjects.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 - " + (words.Length - 1).ToString()); return; } char[] chars = words[index].GetString().ToCharArray(); foreach (char c in chars) { CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(container); charObjects.Add(clone.Init(c)); } currentWord = index; }
public void ShowScramble(int index) { _charObjects.Clear(); foreach (Transform child in container) { Destroy(child.gameObject); } if (index > words.Length - 1) { gameOverPanel.SetActive(true); levelScoreText.text = "Ты набрал " + _scores + " очков!"; return; } char[] chars = words[index].GetString().ToCharArray(); foreach (char c in chars) { CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(container); clone.rectTransform.localScale = new Vector3(1f, 1f, 1f); _charObjects.Add(clone.Init(c)); } currentWord = index; }
/// <summary> /// Show word from collection with desired index /// </summary> /// <param name="index"> index of the element</param> public void ShowScramble(int index) { charObjects.Clear(); foreach (Transform child in container) { Destroy(child.gameObject); } //PROCEED TO NEXT STAGE IF TRUE if (index >= 1) { NextStage(); if (timeLimit <= 0) { result.GameOver(); } } //Show achievement if reached level 5 if (index == 5) { if (PlayerPrefs.HasKey("Achievement2")) { Debug.Log("Already has keys"); } else { Achievement.instance.lbl.text = "Reached Level 5!"; Achievement.instance.achievement.GetComponent <Animator>().Play("", 0, 0f); } PlayerPrefs.SetString("Achievement2", "two"); PlayerPrefs.Save(); } //WORDS FINISHED //SHOW RESULT SCREEN if (index > words.Length - 1) { result.ShowResult(); wordCanvas.SetActive(false); return; } char[] chars = words[index].GetString().ToCharArray(); foreach (char c in chars) { CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(container); charObjects.Add(clone.Init(c)); } currentWord = index; StartCoroutine(TimeLimit()); }
/// <summary> /// Show word from collection with desired index /// </summary> /// <param name="index">index of the element</param> public void ShowSorting(int index) { //ถ้า index มากกว่าคำที่มีทั้งหมดใน array //show หน้า summary if (index > words.Count - 1) { //ถ้าคำหมดแล้วให้แสดงหน้า summaryScoreเลย result.ShowSummary(); //ปิดหน้าเกมด้วย wordCanvas.SetActive(false); return; } if (currentWord <= numIndexList.Count) { result.textJapan.text = wordManager.words[numIndexList[currentWord]].wordname_JP.ToString(); //result.textJapan.text = WordManager.words[numIndexList[currentWord]].wordname_romanji.ToString(); result.textMean.text = wordManager.words[numIndexList[currentWord]].word_meaning.ToString(); } //แสดงตามindex charObjects.Clear(); foreach (Transform child in container) { Destroy(child.gameObject); } //เก็บตัวอักษรที่เอาไป sort ใน function getString char[] chars = words[index].GetString().ToCharArray(); foreach (char c in chars) { //Clone Button ออกมาตามจำนวนอักษรที่มีในคำ CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); //เป็นการเอาbutton ที่clone มาไปเก็บอยู่ใน container clone.transform.SetParent(container); clone.transform.localScale = new Vector3(1, 1, 1); charObjects.Add(clone.Init(c)); } //ทุกครั้งที่มีคำใหม่ก็นับเวลาเท่าเดิมที่ 15 วิ StartCoroutine(TimeLimit()); }
public void showScrambleLetters(int index) { charObjects.Clear(); foreach (Transform child in container) { Destroy((child.gameObject)); } chars = words [index].ToCharArray(); foreach (char c in chars) { clone = Instantiate(prefab.gameObject).GetComponent <CharObject> (); clone.transform.SetParent(container); charObjects.Add((clone.Init(c))); clone.enabled = true; } currentWord = index; }
/* * show word for collecton with desired index * param index = index of the elemnt */ public void ShowScramble() { // clear the list and destroy the children of this object. charObjects.Clear(); foreach (Transform child in container) { Destroy(child.gameObject); } // Get the word as an array of characters and clone/set up the prefab. char[] chars = word.GetRandomChars(); foreach (char c in chars) { CharObject clone = Instantiate(prefab.gameObject).GetComponent <CharObject>(); clone.transform.SetParent(container); // Inits the character visually and internally and then // adds that same character to the list for checking. charObjects.Add(clone.Init(c, this)); } }