Exemple #1
0
    void FixedUpdate()
    {
        if (active)
        {
            timer += Time.deltaTime;

            if (timer > timeStep)
            {
                timer -= timeStep;

                if (CanMove(Vector3.down))
                {
                    offset += Vector3.down;
                    UpdateBlocks();
                }
                else
                {
                    for (int block = 0; block < NUMBER_OF_BLOCKS; block++)
                    {
                        int row    = shapes[rotation, block, 1] + (int)offset.y;
                        int column = shapes[rotation, block, 0] + (int)offset.x;

                        gameBoard.SetBlock(row, column, blocks[block]);
                    }

                    gameBoard.CheckRowsFilled();

                    spawner.ActivateTetramino();

                    for (int block = 0; block < NUMBER_OF_BLOCKS; block++)
                    {
                        Destroy(ghostBlocks[block]);
                    }

                    Destroy(gameObject);
                }
            }
        }
    }