/// <summary> /// /// </summary> /// <param name="friends">周边相同的猫的集合</param> internal void RemoveCat(List <GameObject> friends) { // int score=Control.Instance.ScoreWithStartNumber(friends.Count); //GameLayer.Instance.AddScore(score); TouchLayer.isTouch = false; List <int> columnList = new List <int>();//存储被消掉的列 foreach (GameObject item in friends) { catsList.Remove(item); Point key = item.GetComponent <Cat>().point; catsDic[key] = null; CatManager.Instance.RemoveCat(item); columnList.Add(key.X); } float maxTime = 0; foreach (int column in columnList) { float t = RepairRaw(column);//找到每一空余的列,调整行; if (maxTime < t) { maxTime = t; } } //要等到行的操作完成后,才进行列的操作 this.transform.RunAction(CCSequence.Create(CCDelay.Create(maxTime), CCCallFunc.Create(RepairColumn))); }
public void RepairColumn() { int num = 0; float time = 0; for (int x = 0; x < 10; x++) { bool isNull = true;//当为true的时候说明整列都是空的 for (int y = 0; y < 10; y++) { Point key = new Point(x, y); if (catsDic[key] != null) { isNull = false; } } if (isNull) { num++; } if (!isNull) { if (num > 0) { for (int y = 0; y < 10; y++) { Point key = new Point(x, y); int dx = key.X - num; GameObject cat = catsDic[key]; catsDic[key] = null; if (cat != null) { time = cat.GetComponent <Cat>().RunToX(new Point(dx, y)); } } } } } var action = CCSequence.Create(CCDelay.Create(time), CCCallFunc.Create(() => { if (IsGameOver()) { //分数奖励 JiangLiScore(); StartCoroutine(IsPassGameLv()); } TouchLayer.isTouch = true; })); this.transform.RunAction(action); }