Beispiel #1
0
    void Update()
    {
        ProcessInput();

        if (Time.time - lastFallTime >= board.LastFallTime && !validUnder)
        {
            foreach (Transform child in transform)
            {
                board.OccupySpot(Convert.ToInt32(child.position.x), Convert.ToInt32(child.position.y));
            }

            board.CheckRows();
            spawner.NewTetromino();
            enabled = false;
        }

        double time = fallingFast ? board.FasterFallTime : board.FallTime;

        if (Time.time - previousFallTime >= time)
        {
            transform.SetPositionAndRotation(transform.position + Vector3.down, transform.rotation);

            if (ValidMove())
            {
                previousFallTime = Time.time;

                if (!CheckValidUnder())
                {
                    validUnder   = false;
                    lastFallTime = Time.time;
                }
            }
            else
            {
                transform.SetPositionAndRotation(transform.position + Vector3.up, transform.rotation);

                foreach (Transform child in transform)
                {
                    board.OccupySpot(Convert.ToInt32(child.position.x), Convert.ToInt32(child.position.y));
                }

                board.CheckRows();
                spawner.NewTetromino();
                enabled = false;
            }
        }
    }