コード例 #1
0
    void UpdateProcessList()
    {
        bool needUpdateDrop = false;

        // Update last Flying Bubble
        if (_lastFlyingBubble != null)
        {
            // Normal bubble
            if (_lastFlyingBubble.ID >= 1 && _lastFlyingBubble.ID <= 10)
            {
                _connectedList.Clear();
                _lastFlyingBubble.dieDelayCount = 0;
                _lastFlyingBubble.rootDelay     = _lastFlyingBubble;
                _connectedList.Add(_lastFlyingBubble);
                GetConnectedBubble(_lastFlyingBubble, _connectedList);
                if (_connectedList.Count >= 3)
                {
                    _gameplayController.SetComboCount(_gameplayController.ComboCount + 1);
                    _gameplayController.GiveComboReward();

                    foreach (Bubble b in _connectedList)
                    {
                        if (!_nextProcessList.Contains(b))
                        {
                            _nextProcessList.Add(b);
                        }
                    }
                }
                else
                {
                    _gameplayController.SetComboCount(0);
                }
                _connectedList.Clear();
                _lastFlyingBubble = null;
                //UpdateChangingBubbles();
            }
            else if (_lastFlyingBubble.ID == 19) // rainbow
            {
                int newID = -1;
                foreach (Bubble b in _lastFlyingBubble.linkedBubbles)
                {
                    if (b.ID >= 1 && b.ID <= 10)
                    {
                        newID = b.ID;
                        _connectedList.Clear();
                        GetConnectedBubble(b, _connectedList, -1, 0);
                        if (_connectedList.Count >= 2)
                        {
                            _lastFlyingBubble.ID = b.ID;

                            _connectedList.Clear();
                            break;
                        }
                    }
                }

                if (_lastFlyingBubble.ID == 19) // No changes
                {
                    if (newID == -1)
                    {
                        newID = GetRandomColor();
                    }
                    _lastFlyingBubble.ID = newID;
                    _lastFlyingBubble.SetBubbleColor(newID, true);
                    _lastFlyingBubble = null;
                }

                needUpdateBoard = true;
            }
            else if (_lastFlyingBubble.ID == 20) // bomb
            {
                _connectedList.Clear();
                _lastFlyingBubble.dieDelayCount = 0;
                _lastFlyingBubble.rootDelay     = _lastFlyingBubble;
                _connectedList.Add(_lastFlyingBubble);
                GetConnectedBubble(_lastFlyingBubble, _connectedList, 2, 1);

                _gameplayController.SetComboCount(_gameplayController.ComboCount + 1);

                _gameplayController.GiveComboReward();
                _nextProcessList.AddRange(_connectedList);

                _connectedList.Clear();
                _lastFlyingBubble = null;
            }

            UpdateChangingBubbles();
        }

        // Update queued process list
        List <Bubble> processCopy = new List <Bubble>();

        foreach (Bubble b in _nextProcessList)
        {
            processCopy.Add(b);
        }
        _nextProcessList.Clear();

        foreach (Bubble b in processCopy)
        {
            if (b == null)
            {
                continue;
            }
            if (b.KillID == 0)
            {
                // Kill it
                if (b.isFreezed == false)
                {
                    _bubbleList.Remove(b);
                }

                if (b.special == 1)
                {
                    _gameplayController.IncreaseSquirrel();
                }

                _nextProcessList.Remove(b);
                b.DisconnectBubble(true);
                _gameplayController.AddBubbleToKillList(b);
            }
        }

        if (processCopy.Count > 0)
        {
            needUpdateDrop = true;

            needUpdateBoard = true;
        }

        processCopy.Clear();

        if (needUpdateDrop)
        {
            // Dropping
            //Collect all Top Row
            List <Bubble> topList = new List <Bubble>();
            foreach (Bubble b in _bubbleList)
            {
                if (b._positionY == 0 || b.ID == 15)
                {
                    if (b != null && b.ID != 13)
                    {
                        topList.Add(b);
                    }
                }
            }

            List <Bubble> securedList = new List <Bubble>();
            foreach (Bubble b in topList)
            {
                securedList.Add(b);
                GetConnectedBubble(b, securedList, -1, 1);
            }

            List <Bubble> dropList = new List <Bubble>();
            foreach (Bubble b in _bubbleList)
            {
                if (!securedList.Contains(b))
                {
                    dropList.Add(b);
                }
            }

            // Drop
            if (dropList.Count > 0)
            {
                _gameplayController.GiveComboReward(true, dropList.Count);

                foreach (Bubble b in dropList)
                {
                    _bubbleList.Remove(b);
                    if (b.special == 1)
                    {
                        _gameplayController.IncreaseSquirrel();
                    }

                    b.DisconnectBubble();
                    _gameplayController.AddBubbleToDropList(b);
                }
            }

            // Changing bullet
            _gameplayController.needUpdateBullet = true;
        }
    }