IEnumerator DelayDestoryStar(float delayTime, int index, Star s) { yield return(new WaitForSeconds(delayTime)); GUIHelper.PlayEffect(starRoot, s.transform.position, "starEffect" + (int)s.GetColor(), s.GetColor(), new Vector3(blockWidth / 2, -blockWidth / 2, 0)); GameObject.Destroy(s.gameObject); PlayNumberEffect(GameNumerical.GetStarScore(index + 1), s.GetX(), s.GetY()); }
//重置游戏 private void ResetGame() { tipList.Clear(); thinkTime = 0; isGameOver = false; m_context.score = 0; curLevelFinishScore = GameNumerical.GetFinishScore(m_context.level); txtTargert.text = curLevelFinishScore.ToString(); txtCurScore.text = m_context.score.ToString(); txtLevel.text = m_context.level.ToString(); for (int i = 0; i < hight; i++) { for (int j = 0; j < width; j++) { if (starsArr[i, j] != null) { Destroy(starsArr[i, j].gameObject); } GameObject obj = GameObject.Instantiate(starTemplate); obj.SetActive(true); RectTransform tran = obj.GetComponent <RectTransform>(); obj.name = j + "_" + i; tran.SetParent(starRoot); tran.localScale = Vector3.one; tran.localRotation = Quaternion.identity; tran.localPosition = Vector3.zero; tran.anchoredPosition = new Vector3(j * blockWidth, -i * blockWidth); Star star = obj.AddComponent <Star>(); star.SetColor((StarColorEnum)Random.Range(0, (int)StarColorEnum.MAX)); star.SetIndex(j, i); star.GetButton().onClick.AddListener(delegate() { OnClickStar(star); }); // star.ShowStarTip(true); starsArr[i, j] = star; } } emptyLine = 0; }