Пример #1
0
    void CleanUpBlocks()
    {
        /*if (iBlockQueueIndex_ == 1) {
         *      while (UseBlockList2_.Count > 0) {
         *              GameObject Block = UseBlockList2_.Dequeue();
         *              Block.renderer.enabled = false;
         *              UnusedBlockQueue_.Enqueue(Block);
         *      }
         *      iBlockQueueIndex_ = 2;
         * }
         * else if (iBlockQueueIndex_ == 2) {
         *      while (UseBlockList1_.Count > 0) {
         *              GameObject Block = UseBlockList1_.Dequeue();
         *              Block.renderer.enabled = false;
         *              UnusedBlockQueue_.Enqueue(Block);
         *      }
         *      iBlockQueueIndex_ = 1;
         * }*/

        // clean up unshown blocks
        foreach (int iIndex in UnShownBlockList_)
        {
            SBlock BlockThing = GetBlock(iIndex);
            BlockThing.Reset();
            if (BlockModels_[iIndex] != null && BlockModels_[iIndex].GetComponent <Renderer>().enabled)
            {
                BlockModels_[iIndex].GetComponent <Renderer>().enabled = false;
            }
        }
        UnShownBlockList_.Clear();
    }
Пример #2
0
    void CompileVisibleSet()
    {
        VisibleBlocks_.Clear();
        foreach (int iIndex in UpdateBlocks_)
        {
            if (!IsInRange(iIndex))
            {
                continue;
            }
            SBlock Block = GetBlock(iIndex);
            if (IsOn(Block.bIsVisible, Block.iNeighbors))
            {
                Block.bIsVisible = true;
                VisibleBlocks_.Add(iIndex);
            }
            else
            {
                Block.Reset();
                if (BlockModels_[iIndex] != null)
                {
                    BlockModels_[iIndex].GetComponent <Renderer>().enabled = false;
                }
            }

            Block.bIsInUpdateList = false;
            Block.iNeighbors      = 0;
        }
        UpdateBlocks_.Clear();

        foreach (int iVisibleIndex in VisibleBlocks_)
        {
            // enable block
            if (ShouldDraw(iVisibleIndex))
            {
                UseBlock(iVisibleIndex);
            }
            else
            {
                UnShownBlockList_.Enqueue(iVisibleIndex);
            }
        }

        // Clean up Used Queues
        CleanUpBlocks();
    }