//spawn the tetramino at the location of the spawner private void spawnpiece(int n) { GameObject tetramino = (GameObject)Instantiate(Tetrominoes[n], transform.position, Quaternion.identity); TetrisBlock currentPiece = tetramino.GetComponent(typeof(TetrisBlock)) as TetrisBlock; if (!currentPiece.ValidMove()) { currentPiece.reset(); Application.LoadLevel(1); } }
void ghostTetromino() { if (instantiated != null) { Destroy(instantiated); } //GameObject clone = FindObjectOfType<spawn>().getCurrentPiece(); instantiated = (GameObject)Instantiate(gameObject); TetrisBlock ghostPiece = instantiated.GetComponent(typeof(TetrisBlock)) as TetrisBlock; ghostPiece.canMove = false; if (ghostPiece.ValidMove()) { ghostPiece.goDown(); ghostPiece.ghostify(); } else { Destroy(instantiated); } }