Exemplo n.º 1
0
    void GenerateNewTetramino()
    {
        currentCubesArr    = new List <GameObject> ();
        currTetramino      = tetraminos [Random.Range(0, tetraminos.Length)];
        currTetraminoState = currTetramino.getRandomState();

        currTetraminoCoords = new int[8];
        horizontalAddition  = initialTetraminoYAddition;
        isFirstRotation     = true;
        verticalAddition    = 0;
        for (int i = 0; i < currTetramino.States [currTetraminoState].Length; i += 2)
        {
            currTetraminoCoords [i]     = currTetramino.States [currTetraminoState] [i];
            currTetraminoCoords [i + 1] = currTetramino.States [currTetraminoState] [i + 1] + horizontalAddition;
            if (takenMatrixPositions [currTetraminoCoords [i], currTetraminoCoords [i + 1]])
            {
                isGameOver      = true;
                controlsEnabled = false;
                print("GAME OVER");
                break;
            }
        }
        if (!isGameOver)
        {
            for (int i = 0; i < 4; i++)
            {
                GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.GetComponent <Renderer> ().material.color = currTetramino.color;
                currentCubesArr.Add(cube);
            }
            UpateCurrentCubesPosition();
        }
    }