// void setPreview() { //store a piece from the top of the queue into StoredPiece (display piece) StoredPiece preview = GameObject.FindGameObjectWithTag(Constants.DISPLAY_PIECE).GetComponent <StoredPiece>(); GameObject nextPiece = Instantiate(nextPieces.Dequeue(), preview.transform.position, Quaternion.identity); nextPiece.GetComponent <Piece>().enabled = false; nextPiece.GetComponent <Piece>().tag = Constants.DISPLAY_PIECE; preview.StowedPiece = nextPiece; if (nextPieces.Count <= 3) { populateNextPieces(); } }
void storePiece() { if (!Global.Swapped) { tag = Constants.INACTIVE_PIECE; StoredPiece storeTo = GameObject.FindGameObjectWithTag(Constants.STORE_PIECE).GetComponent <StoredPiece>(); PieceSpawner spawner = FindObjectOfType <PieceSpawner>(); GameObject newPiece = storeTo.StowedPiece; storeTo.StowedPiece = gameObject; transform.rotation = Quaternion.identity; transform.position = storeTo.Location; enabled = false; //Board.UpdatePosition(transform); if (newPiece == null) { spawner.SpawnNext(); } else { spawner.SpawnPiece(newPiece); } Global.Swapped = true; } }