Пример #1
0
    // Spawn a new tetromino at the top of the screen
    void SpawnTetromino(int tetrominoIndex)
    {
        if (!dead)
        {
            buttonInfo.softDropCounter = 0;
            nextTetrominoIndex         = UnityEngine.Random.Range(1, 8);

            tetrominoPool          = Tetrominoes.GetTetrominoFromIndex(tetrominoIndex);
            currentTetrominoState  = Slicer3D(tetrominoPool, 0);
            rotationState          = 0;
            currentTetrominoPos[0] = 3;
            currentTetrominoPos[1] = 18;

            tetrominoSpawned?.Invoke();
        }
    }
Пример #2
0
    void UpdateTetrominoHolder()
    {
        foreach (Transform child in obj.nextTetrominoHolder)
        {
            Destroy(child.gameObject);
        }

        int[,,] tetrominoPool = Tetrominoes.GetTetrominoFromIndex(engine.nextTetrominoIndex);

        for (int x = 0; x < 4; x++)
        {
            for (int y = 0; y < 4; y++)
            {
                if (engine.Slicer3D(tetrominoPool, 0)[x, y] != 0)
                {
                    Vector2    spawnPos = new Vector2(obj.nextTetrominoHolder.position.x - 2 + x, obj.nextTetrominoHolder.position.y - 1 + y);
                    GameObject newTile  = Instantiate(obj.tileObj, spawnPos, Quaternion.identity);
                    newTile.GetComponent <TileRenderer>().isNext = true;
                    newTile.transform.parent = obj.nextTetrominoHolder;
                    newTile.GetComponent <TileRenderer>().engine = engine;
                }
            }
        }
    }