public void CreateTetrimo(bool firstPiece) { Tetrimino block = mSpawner.GetRandomTetrimino(); int rotation = RandomGenerator.random.Next(0, block.blockPositions.GetLength(0)); Vector2Int position = block.GetInitialPosition(rotation); position.x += WIDTH / 2; block.currentPosition = position; block.currentRotation = rotation; if (mGameSettings.debugMode) { Debug.Log("CREATING TETRIMINO: " + block.name); } if (firstPiece) { //Set first block to random block mCurrentTetrimino = block; //Generate new block for next block block = mSpawner.GetRandomTetrimino(); rotation = RandomGenerator.random.Next(0, block.blockPositions.GetLength(0)); position = block.GetInitialPosition(rotation); position.x += WIDTH / 2; block.currentPosition = position; block.currentRotation = rotation; //Set next block to random block mNextTetrimino = block; } else { //Set next current block to next block, then generate new block mCurrentTetrimino = mNextTetrimino; mNextTetrimino = block; } }
//Create a random piece in the engine and returns it public Tetrimino CreateTetrimo() { mCurrentTetrimino = mSpawner.GetRandomTetrimino(); int rotation = RandomGenerator.random.Next(0, mCurrentTetrimino.blockPositions.GetLength(0)); Vector2Int position = mCurrentTetrimino.GetInitialPosition(rotation); position.x += WIDTH / 2; mCurrentTetrimino.currentPosition = position; mCurrentTetrimino.currentRotation = rotation; if (mGameSettings.debugMode) { Debug.Log("CREATING TETRIMINO: " + mCurrentTetrimino.name); } return(mCurrentTetrimino); }