예제 #1
0
    void GenerateNextBlock(GameObject currentBlock, out GameObject returnBlock)
    {
        int       index = 1;
        GameBlock block = new GameBlock();

        for (int i = 0; i < 3; i++)
        {
            Randomizer(ref index);
            block = MessageSystemGameBlock.ReturnUnusedGameBlock(index);
            if (block.GetGameObject() != null)
            {
                selectedBlock[index - 1] = true;
                StartCoroutine(PreparingPercent(index));
                break;
            }
            if (i == 2)
            {
                returnBlock             = GenerateNextEarth(currentBlock);
                Storage.CountBlockEarth = 0;
                return;
            }
        }
        block.CountUsing++;
        GameObject    newBlock = block.GetGameObject();
        BoxCollider2D curBox   = currentBlock.GetComponent <BoxCollider2D>();
        float         offset   = 0;

        if (block.Extents != -1)
        {
            offset = curBox.bounds.extents.x + block.Extents;
        }
        else
        {
            GenerateNextEarth(currentBlock);
            Storage.CountBlockEarth++;
        }
        newBlock.transform.position = new Vector3(curBox.bounds.center.x + offset, newBlock.transform.position.y, newBlock.transform.position.z);
        MessageSystemGameBlock.SetupParent(newBlock, false);
        block.SetActiveFull(true);
        returnBlock = newBlock;
    }