Exemplo n.º 1
0
        public void SpawnBubbles()
        {
            for (int y = maxY - 1; y >= maxY - initialRowsCount; y--)
            {
                for (int x = 0; x < initialColumnsCount; x++)
                {
                    var bubble = bubblesPool.GetOrInstantiate(BUBBLE_ID);
                    bubble.transform.localPosition = GetLocalSpawnPosition(x, y);
                    bubble.X = x;
                    bubble.Y = y;
                    bubbles.Add(bubble);

                    bubble.Power = UnityEngine.Random.Range(generationMinPower, generationMaxPower);
                    bubble.gameObject.SetActive(true);

                    OnBubbleAdded?.Invoke(bubble);
                }
            }
            LinkBubbles();
        }
Exemplo n.º 2
0
        public Bubble SpawnBubble(int x, int y, int power = 1, bool link = true, bool merge = true)
        {
            var bubble = bubblesPool.GetOrInstantiate(BUBBLE_ID);

            bubble.transform.localPosition = GetLocalSpawnPosition(x, y);
            bubble.X     = x;
            bubble.Y     = y;
            bubble.Power = power;
            bubbles.Add(bubble);
            bubble.gameObject.SetActive(true);
            OnBubbleAdded?.Invoke(bubble);
            if (link)
            {
                LinkBubbles();
            }
            if (merge)
            {
                TryMerge(bubble);
            }
            return(bubble);
        }
Exemplo n.º 3
0
        private void LowerBubbles()
        {
            maxY++;
            minY++;
            deadlineY++;

            for (int x = 0; x < maxX; x++)
            {
                var bubble = bubblesPool.GetOrInstantiate(BUBBLE_ID);
                bubble.transform.localPosition = GetLocalSpawnPosition(x, maxY - 1);
                bubble.X = x;
                bubble.Y = maxY - 1;
                bubbles.Add(bubble);

                bubble.Power = UnityEngine.Random.Range(generationMinPower, generationMaxPower);
                bubble.gameObject.SetActive(true);

                OnBubbleAdded?.Invoke(bubble);
            }
            LinkBubbles();

            rootNextPosition = bubblesPool.Root.localPosition + Vector3.down * Mathf.Sin(INPUT_ANGLE_IN_RADIANS);
            isRootMoving     = true;
        }