void Update() { if (currentTetromino == null) //the tetromino is never generated on its own, it is cloned from the next tetromino { StopAllCoroutines(); currentTetromino = TetrominoControls.cloneTetromino(nextTetromino, field); TetrominoControls.CreateGhost(currentTetromino); blockControl.blk_cnj_clear(nextTetromino.GetBlocks()); nextTetromino = TetrominoControls.createTetromino(next); StartCoroutine(goDown()); changeColor(currentTetromino.GetBlocks()); } if (Input.GetKeyDown("d")) // Moves to the right { if (blockControl.blk_cnj_foreach(blockControl.blk_solo_checkRight, currentTetromino.GetBlocks(), 0)) { blockControl.blk_cnj_foreach(blockControl.blk_solo_moveRight, currentTetromino.GetBlocks(), 0); currentTetromino.SetLocation(new Vector2Int(1, 0)); TetrominoControls.CreateGhost(currentTetromino); } } if (Input.GetKeyDown("a"))// Moves to the left { if (blockControl.blk_cnj_foreach(blockControl.blk_solo_checkLeft, currentTetromino.GetBlocks(), 0)) { blockControl.blk_cnj_foreach(blockControl.blk_solo_moveLeft, currentTetromino.GetBlocks(), 0); currentTetromino.SetLocation(new Vector2Int(-1, 0)); TetrominoControls.CreateGhost(currentTetromino); } } if (Input.GetKeyDown("s"))// Moves Down { if (currentTetromino != null) { StopAllCoroutines(); tick = 0.05f; StartCoroutine(goDown()); } } if (Input.GetKeyUp("s"))// Moves Down { StopAllCoroutines(); tick = 1f; StartCoroutine(goDown()); } if (Input.GetKeyDown("w")) { rotation(); TetrominoControls.CreateGhost(currentTetromino); } if (Input.GetKeyDown("f")) { TetrominoControls.fitPiece(currentTetromino, currentTetromino.GetField()); UiControl.scr_add(score, 36); checkDown(currentTetromino); } if (Input.GetKeyDown("c") && recentlyChanged == false) { Tetromino cloneAux = null; if (holdTetromino != null) { cloneAux = holdTetromino; blockControl.blk_cnj_clear(holdTetromino.GetBlocks()); } holdTetromino = TetrominoControls.cloneTetromino(currentTetromino, hold); blockControl.blk_cnj_clear(currentTetromino.GetBlocks()); blockControl.blk_cnj_clear(currentTetromino.GetGhost().GetBlocks()); currentTetromino = TetrominoControls.cloneTetromino(cloneAux, field); TetrominoControls.CreateGhost(currentTetromino); recentlyChanged = true; } }