Exemple #1
0
    /*
     *  public TextBubble smGreenBubble;
     * public TextBubble lgGreenBubble;
     * public TextBubble smBlueBubble;
     * public TextBubble lgBlueBubble;
     */
    void SpawnBubble(BubbleColors color, string message)
    {
        numberOfBubbles++;

        TextBubble bubble         = null;
        bool       isGreen        = false;
        int        characterCount = message.Length;

        if (characterCount <= smallBubbleLimit)
        {
            if (color == BubbleColors.BLUE)
            {
                isGreen = false;
                bubble  = smBlueBubble;
                //bubble = Instantiate(smBlueBubble);
            }
            else if (color == BubbleColors.GREEN)
            {
                isGreen = true;
                bubble  = smGreenBubble;
                //bubble = Instantiate(smGreenBubble);
            }
            else
            {
                Debug.LogError("Yo you don't have the right color some how. Way to go.");
            }
        }
        else if (characterCount <= largeBubbleLimit)
        {
            if (color == BubbleColors.BLUE)
            {
                isGreen = false;
                bubble  = lgBlueBubble;
//              bubble = Instantiate(lgBlueBubble);
            }
            else if (color == BubbleColors.GREEN)
            {
                isGreen = false;
                bubble  = lgGreenBubble;
                //bubble = Instantiate(lgGreenBubble);
            }
            else
            {
                Debug.LogError("Yo you don't have the right color some how. Way to go.");
            }
        }
        else
        {
            Debug.LogError("The string entered is too long.");
        }

        //bubble.transform.parent = targetCanvas.transform;
        TextManager.Instance.SpawnBox(bubble, message, isGreen);


        UnityEngine.UI.Text textObject = bubble.GetComponentInChildren <UnityEngine.UI.Text>();
        textObject.text = message;
    }
Exemple #2
0
    public void BurstBubble(int size, Vector3 point, BubbleColors bubbleColor)
    {
        bubblesPoppedCounter++;

        if (bubblesPoppedCounter % bubblesToDropALife == 0)
        {
            Instantiate(duckLifePrefab, point, Quaternion.identity);
        }
        else
        {
            Instantiate(dropletPrefab, point, Quaternion.identity);
        }

        AudioManager.Instance.PlayPop();

        switch (bubbleColor)
        {
            case BubbleColors.Blue:
                break;
            case BubbleColors.Black:
                GrowOtherBubbles();
                break;
            case BubbleColors.Red:
                PopSurroundingBubbles(size, point);
                break;
            case BubbleColors.Yello:
                GiveUmbrella();
                break;
        }

        if (size > 1 && !instantPop.Contains(bubbleColor))
        {
            Vector3 leftPoint = new Vector3(point.x - 1, point.y);
            Vector3 rightPoint = new Vector3(point.x + 1, point.y);

            int newSize = size - 1;

            GameObject bubblePrefab = null;

            switch (bubbleColor)
            {
                case BubbleColors.Blue:
                    bubblePrefab = blueBubblePrefab;
                    break;
                case BubbleColors.Black:
                    bubblePrefab = blackBubblePrefab;
                    break;
                case BubbleColors.Red:
                    bubblePrefab = redBubblePrefab;
                    break;
                default:
                    bubblePrefab = blueBubblePrefab;
                    break;
            }

            GameObject leftBubble = (GameObject)Instantiate(bubblePrefab, leftPoint, Quaternion.identity);
            leftBubble.GetComponent<BubbleController>().size = newSize;
            leftBubble.transform.localScale = Vector3.one * (newSize * 0.25f);
            activeBubbles.Add(leftBubble);

            GameObject rightBubble = (GameObject)Instantiate(bubblePrefab, rightPoint, Quaternion.identity);
            rightBubble.GetComponent<BubbleController>().size = newSize;
            rightBubble.transform.localScale = Vector3.one * (newSize * 0.25f);
            activeBubbles.Add(rightBubble);
        }

        if (!activeBubbles.Any())
        {
            LevelComplete();
        }
    }
Exemple #3
0
    /// <summary>
    /// Метод для выставления рандомного цвета шарика
    /// </summary>
    private void SetNewBubbleColor()
    {
        int randomColorIndex = UnityEngine.Random.Range(0, maxBubbleColors);

        bubbleColor = (BubbleColors)randomColorIndex;
    }