예제 #1
0
    public void InitializeBlockPair()
    {
        if (gameOver)
        {
            return;
        }
        isActive = true;

        leftBlock  = SpawnBlock(previewLeftType, 2);
        rightBlock = SpawnBlock(previewRightType, 3);

        if (previewRightType == "diamond")
        {
            previewRightBlock.GetComponent <DiamondScript>().RemoveDiamondScript();
        }

        if (previewLeftBlock == null)
        {
            InitializePreviewBlocks();
        }
        else if (queueDiamond)
        {
            previewLeftType  = getRandomElement();
            previewRightType = "diamond";
            queueDiamond     = false;

            previewLeftBlock.GetComponent <MeshRenderer>().material.color = getColorByType(previewLeftType);
            previewRightBlock.AddComponent <DiamondScript>();
        }
        else
        {
            previewLeftType  = getRandomElement();
            previewRightType = getRandomElement();

            previewLeftBlock.GetComponent <MeshRenderer>().material.color  = getColorByType(previewLeftType);
            previewRightBlock.GetComponent <MeshRenderer>().material.color = getColorByType(previewRightType);
        }

        leftBlock.SetFallSpeed(1f + 0.3f * manager.speed);

        leftBlock.isLeft  = true;
        rightBlock.isLeft = false;

        leftBlock.blockPair  = this;
        rightBlock.blockPair = this;

        orientation = 0;
    }