Esempio n. 1
0
    IEnumerator SpawnRowRoutine(OnRowSpawnResult onRowSpawnResult)
    {
        bool  isGameOver   = false;
        float oddRowOffset = isOddRow ? bubbleRadius : 0f;

        isOddRow = !isOddRow;

        ToplineBubbles.Clear();

        for (int i = 0; i < GRID_WIDTH; i++)
        {
            yield return(new WaitForSeconds(0.1f));

            GridBubble lastSlot = bubbleGrid.Dequeue();

            // todo change gmeover condition, it will not work for the player added bubbles
            if (lastSlot.IsActive)
            {
                //* Add a call to a dequeued Bubble, if it exists it could run some game over destruction anim
                isGameOver = true;
                Debug.Log("game over");
            }

            //* activate new slot
            float xPosition = horizontalStep * i + oddRowOffset;
            lastSlot.ActivateBubble(new Vector3(xPosition, 0f, verticalStep));
            lastSlot.Bubble.ResetBubbleScale();
            bubbleGrid.Enqueue(lastSlot);
            ToplineBubbles.Add(lastSlot);
        }

        // * dirtyyy
        if (!isGameOver)
        {
            foreach (var bubble in bubbleGrid)
            {
                bubble.OffsetBubble(-verticalStep);
            }
        }

        onRowSpawnResult(isGameOver);
    }
Esempio n. 2
0
 public void SpawnRow(OnRowSpawnResult onRowSpawn)
 {
     StartCoroutine(SpawnRowRoutine(onRowSpawn));
 }