/// <summary> /// 特殊泡泡的功能 消除同样颜色的泡泡 /// </summary> public void ClearSameColorBubble(BubbleUnit bubble) { int typeID = Random.Range(1, 6); List <BubbleUnit> colorBubList = new List <BubbleUnit> (); for (int i = 0; i < this.bubbleList.Count; ++i) { BubbleUnit curBub = bubbleList[i]; int curType = IDTool.GetType(curBub.ID); int curTypeID = IDTool.GetTypeID(curBub.ID); if (curType != 2 && curTypeID == typeID) { colorBubList.Add(curBub); } } colorBubList.Add(bubble); for (int j = 0; j < colorBubList.Count; ++j) { RecycleBubble(colorBubList[j]); } }
/// <summary> /// 回收一个泡泡 /// </summary> /// <param name="bubble">Bubble.</param> public void RecycleBubble(BubbleUnit bubble) { if (bubbleList.Contains(bubble) == false) { return; } if (bubble.hitCount > 0) { return; } this.score += (int)(bubble.SingleScore * this.scoreMulti); EffectPool.Instance.PlayBubbleExplode(IDTool.GetTypeID(bubble.ID), bubble.transform.position); EffectPool.Instance.PlayFlowEffect(bubble.transform.position); bubbleList.Remove(bubble); pool.Despawn(bubble.transform); Transform newBubble = CreateNewRandomBubble(); newBubble.transform.localPosition = new Vector3(-200f + Random.value * 400, 450f, 0f); AudioManager.Instance.PlayBubble(); }
/// <summary> /// Raises the mouse down event. /// </summary> void OnMouseDown() { if (BubbleManager.Instance.isCanClick == false) { return; } Debug.Log("special monsedown"); int type = IDTool.GetType(ID); int typeID = IDTool.GetTypeID(ID); if (type != 2) { Debug.LogError("error type"); return; } else { BubbleManager.Instance.scoreMulti = 2f; if (typeID == 1) { CleanRow(); } else if (typeID == 2) { CleanCol(); } else if (typeID == 3) { CleanRowCol(); } else if (typeID == 4) { CleanRange(); } else if (typeID == 5) { BubbleManager.Instance.ClearSameColorBubble(this); this.ReduceHitCount(); BubbleManager.Instance.RecycleBubble(this); } else if (typeID == 6) { BubbleManager.Instance.CleanAllBubble(); this.ReduceHitCount(); BubbleManager.Instance.RecycleBubble(this); } GetComponent <Rigidbody2D>().isKinematic = true; } }
/// <summary> /// 广度优先搜索 查找相连的 泡泡 /// </summary> /// <returns>The link bubble.</returns> /// <param name="bubble">Bubble.</param> List <BubbleUnit> GetLinkBubble(BubbleUnit bubble) { List <BubbleUnit> resList = new List <BubbleUnit> (); List <BubbleUnit> tempList = new List <BubbleUnit> (); tempList.AddRange(bubbleList); //remove different bubble int index = 0; while (index < tempList.Count) { if (IDTool.GetTypeID(tempList[index].ID) != IDTool.GetTypeID(bubble.ID)) { tempList.RemoveAt(index); } else { index++; } } //get the link bubble of select one resList.Add(bubble); tempList.Remove(bubble); int i = 0; while (i < resList.Count) { BubbleUnit curBub = resList[i]; int j = 0; while (j < tempList.Count) { if (IsTouch(curBub, tempList[j])) { resList.Add(tempList[j]); tempList.RemoveAt(j); } else { ++j; } } ++i; } return(resList); }