Пример #1
0
    bool UpdateBubble()
    {
        bool updateComplete = true;

        for (int i = _tileList.Count - 1; i >= 0; --i)
        {
            if (_tileList[i].IsEmptyTile == true)
            {
                continue;
            }

            if (_tileList[i].TargetBubble == null)
            {
                if (i >= TileWidth)
                {
                    continue;
                }

                BubbleScript bubble = null;
                if (_uselessBubbles.Count == 0)
                {
                    //들어오면 안되는 코드
                    Debug.LogError("???????????");
                    GameObject bubbleObj = Instantiate(_bubbleRes) as GameObject;
                    bubbleObj.transform.parent  = _bubblePanel.transform;
                    bubble.transform.localScale = Vector3.one;
                    bubble = bubbleObj.GetComponent <BubbleScript>();
                    bubble.Init();
                }
                else
                {
                    bubble = _uselessBubbles.Dequeue();
                    bubble.gameObject.SetActive(true);
                }

                _liveBubbleList.Add(bubble);

                bubble.transform.localPosition = new Vector3(TILE_SIZE * i + (TILE_SIZE / 2f), TILE_SIZE - ((i % 2) * (TILE_SIZE / 2)), 0f);

                bubble.TargetMapTile      = _tileList[i];
                _tileList[i].TargetBubble = bubble;
                bubble.GenerateBubble();
            }

            if (_tileList[i].TargetBubble.UpdateBubble(Time.deltaTime) == true)
            {
                updateComplete = false;
            }
        }

        return(updateComplete);
    }
Пример #2
0
    void MakeUselessBubbles()
    {
        for (int i = 0; i < _liveBubbleList.Count; ++i)
        {
            _liveBubbleList[i].transform.localPosition = new Vector3(10000f, 0, 0);
            _uselessBubbles.Enqueue(_liveBubbleList[i]);
            _liveBubbleList[i].ClearBubble();
        }
        _liveBubbleList.Clear();

        int createItemCount = TileWidth * TileHeight - _uselessBubbles.Count;

        for (int i = 0; i < createItemCount; ++i)
        {
            GameObject bubbleObj = Instantiate(_bubbleRes) as GameObject;
            bubbleObj.transform.parent        = _bubblePanel.transform;
            bubbleObj.transform.localScale    = Vector3.one;
            bubbleObj.transform.localPosition = new Vector3(10000f, 0, 0);
            BubbleScript bubble = bubbleObj.GetComponent <BubbleScript>();
            _uselessBubbles.Enqueue(bubble);

            bubble.Init();
        }
    }