IEnumerator CreatWordsLoop() { float nextrefreshTime = 0.0f; while (!m_isWin) { List <WordsConfig.KeyCodeType> keys = Word.RandomKeys(); while (!KeysOk(keys)) { keys = Word.RandomKeys(); } WordsConfig words = CreatWord(); m_keysGroup.Add(keys); if (m_word == null) { break; } Word obj = Instantiate(m_word); obj.Init(words, keys); float positionX = Random.Range(m_leftEdge, m_rightEdge); while (Mathf.Abs(positionX - m_lastXPosition) <= m_xChange) { positionX = Random.Range(m_leftEdge, m_rightEdge); } obj.transform.position = new Vector3(positionX, m_Top, 0); m_lastXPosition = positionX; nextrefreshTime = Random.Range(m_minRefresh, m_maxRefresh); yield return(new WaitForSeconds(nextrefreshTime)); } }
public void Init(WordsConfig word, List <WordsConfig.KeyCodeType> keys) { Keys = keys; m_text.text = word.text; m_word = word; for (int i = 0; i < 3; i++) { switch (Keys[i]) { case WordsConfig.KeyCodeType.Left: m_keyImages[i].sprite = m_Left; //m_keyText[i].text = "F"; break; case WordsConfig.KeyCodeType.Right: m_keyImages[i].sprite = m_Right; //m_keyText[i].text = "J"; break; case WordsConfig.KeyCodeType.Middle: m_keyImages[i].sprite = m_Middle; //m_keyText[i].text = "SPACE"; break; default: break; } m_animator[i].speed = 0; } OnKeyPressSuccessHandler += OnKeyPressSuccessful; OnKeyPressFailedHandler += OnKeyPressFailed; GameController.Instance.OnWordsSuccessful += OnKeyPressFailed; }