Пример #1
0
    // Update is called once per frame
    void Update()
    {
        fallCount += Time.deltaTime;
        if (fallCount >= fallSpeed - 0.07f * level)
        {
            // Spawn new block
            if (CanMove("fall"))
            {
                HideBlocks();
                curBlock.Fall();
            }
            else
            {
                for (int y = 0; y < wellVolume.y; y++)
                {
                    for (int x = 0; x < wellVolume.x; x++)
                    {
                        for (int z = 0; z < wellVolume.z; z++)
                        {
                            if (!well[x, y, z].activeSelf)
                            {
                                isFull = false;
                            }
                        }
                    }
                    if (isFull)
                    {
                        HidePlane(y);
                        y--;


                        pClearsFrame++;

                        planesCleared++;
                        if (planesCleared % 10 == 0)
                        {
                            level++;
                            levelLabel.text = "Level: " + level;
                        }
                    }
                    isFull = true;
                }

                if (pClearsFrame > 0)
                {
                    Debug.Log("pClearsFrame: " + pClearsFrame);
                    switch (pClearsFrame)
                    {
                    case 1:
                        score += 40 * level;
                        break;

                    case 2:
                        score += 100 * level;
                        break;

                    case 3:
                        score += 300 * level;
                        break;

                    case 4:
                        score += 1200 * level;
                        break;

                    default:
                        break;
                    }
                    scoreLabel.text = "Score: " + score;
                    pClearsFrame    = 0;
                }

                foreach (Vector3 loc in curBlock.locs) //See if stopped block is above threshold
                {
                    if (loc.y >= 21)
                    {
                        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
                    }
                }
                NewBlock();
                if (!CanMove("fall"))
                {
                    curBlock.Rise();
                    curBlock.Rise();
                    curBlock.Rise();
                    curBlock.Rise();
                }
            }

            DrawBlocks();

            fallCount = 0.0f;
        }
    }