Exemple #1
0
    /// <summary>
    /// 根据配置文件 初始化泡泡布置
    /// </summary>
    public void InitByLayoutData(string layoutStr)
    {
        string[] items = layoutStr.Split('|');

        for (int i = 0; i < items.Length; ++i)
        {
            string             oneItem   = items[i];
            string[]           itemInfos = oneItem.Split('^');
            BubbleConfigStruct info      = new BubbleConfigStruct();
            info.id         = int.Parse(itemInfos[0]);
            info.prefabName = itemInfos[1];
            info.pos        = StrToVec(itemInfos[2]);
            info.rotate     = StrToVec(itemInfos[3]);
            info.scale      = StrToVec(itemInfos[4]);

            layoutList.Add(info);
        }

        for (int j = 0; j < layoutList.Count; ++j)
        {
            BubbleConfigStruct info = layoutList[j];

            Transform newBubble = GetBubbleTran(info.id);
            newBubble.parent = transform;

            BubbleUnit bubble = newBubble.GetComponent <BubbleUnit> ();
            bubble.SetData(info.id);
            bubbleList.Add(bubble);

            newBubble.transform.localPosition = info.pos;
            newBubble.transform.localRotation = Quaternion.Euler(info.rotate);
            newBubble.transform.localScale    = info.scale;
        }
    }
Exemple #2
0
    public Transform CreateNewRandomBubble()
    {
        int type = Random.value > 0.9 ? 30 : 10;

        int randonID = type + Random.Range(1, 6);
        //Debug.Log (randonID);
        Transform newBubble = GetBubbleTran(randonID);

        newBubble.parent = transform;

        BubbleUnit bubble = newBubble.GetComponent <BubbleUnit> ();

        bubble.SetData(randonID);
        bubbleList.Add(bubble);

        return(newBubble);
    }
    /// <summary>
    /// 消除多个泡泡生成特殊泡泡
    /// </summary>
    void CreateSpecialBubble(int cleanCount, Vector3 pos)
    {
        //至少4个
        if (cleanCount < 4)
        {
            return;
        }

        Transform bub;
        int       randomID = 21;

        //根据消除的个数 创新特殊气泡
        if (cleanCount == 4)
        {
            randomID = 20 + Random.Range(1, 3);
        }
        else if (cleanCount == 5)
        {
            randomID = 24;
        }
        else if (cleanCount == 6)
        {
            randomID = 23;
        }
        else if (7 <= cleanCount && cleanCount <= 9)
        {
            randomID = 25;
        }
        else
        {
            randomID = 26;
        }

        bub = GetBubbleTran(randomID);
        BubbleUnit bubble = bub.GetComponent <BubbleUnit> ();

        bubble.SetData(randomID);

        bub.transform.parent        = transform;
        bub.transform.localPosition = pos;

        bubbleList.Add(bubble);
    }
Exemple #4
0
    void CreateStoneBubble()
    {
        Vector3 startPos = new Vector3(-210f, -210f, 0);
        float   len      = 52f;

        for (int i = 0; i < 5; ++i)
        {
            int randonID = 40 + Random.Range(1, 6);

            Transform newBubble = GetBubbleTran(randonID);
            newBubble.parent = transform;

            BubbleUnit bubble = newBubble.GetComponent <BubbleUnit> ();
            bubble.SetData(randonID);
            bubbleList.Add(bubble);

            Vector3 pos = startPos + new Vector3(i * len, 0f, 0f);
            bubble.transform.localPosition = pos;
        }
    }