public void SpawnBubble(BubbleType bubbleType) { Vector3 spawnPosition = new Vector3(transform.position.x, Random.Range(-(_boxCollider.size.y / 2), _boxCollider.size.y / 2), 0f); GameObject bubbleGameObject = Instantiate(BubblePrefab, spawnPosition, Quaternion.identity); Bubble bubble = bubbleGameObject.GetComponent <Bubble>(); bubble.TransformType = TransformType; bubble.BubbleType = bubbleType; BubbleManager.AddBubble(bubbleGameObject); }
private void OnBubbleHit(object sender, MessageEventArgs.ReadOnlyEventArgs <BubbleObject> e) { _shooterController.Reload(); var thisBo = sender as BubbleObject; var otherBo = e.Parameter; Vector2Int gridPos = FindNearestNeighborPos(thisBo, otherBo); bubbleManager.AddBubble(thisBo, gridPos); #region chain destory chainFinder.Reset(); HashSet <BubbleObject.BubbleTypes> bubbleTypes = new HashSet <BubbleObject.BubbleTypes>(); bubbleTypes.Add(thisBo.BubbleType); chainFinder.FindBloomBubbles(thisBo, bubbleTypes); //Debug.Log(chainFinder.BloomList.Count); if (chainFinder.BloomList.Count >= 3) { foreach (var b in chainFinder.BloomList) { bubbleManager.RemoveBubble(b); BubblePool.Instance.ReleaseBubble(b); } } #endregion #region fall down isolated chainFinder.Reset(); var IsoBubbles = chainFinder.FindIsolatedBubble(); foreach (var b in IsoBubbles) { if (b.BubbleState == BubbleObject.BubbleStates.State_Bullet) { Debug.Log("!"); } b.BubbleState = BubbleObject.BubbleStates.State_Fall; bubbleManager.RemoveBubble(b); } #endregion CheckWin(); CheckGameOver(); }