void ConstructPiece() { GameObject temp = GetRandomObject(pieces); Vector2 tempPos = RoundVector.RoundedVector(constructorPos.position); Instantiate(temp, tempPos, Quaternion.identity); }
//Cria uma peça public void SpawnPiece() { GameObject newPiece = GetRandomPiece(pieces); Vector2 newPos = RoundVector.RoundedVector(spawnPoint.position); Piece piece = Instantiate(newPiece, newPos, Quaternion.identity).GetComponent <Piece>(); piece.Setup(grid); currentPiece = piece; }
bool isValidPosition() { for (int i = 0; i < blocks.Length; i++) { Vector2 tempVector = new Vector2(blocks[i].transform.position.x, blocks[i].transform.position.y); tempVector = RoundVector.RoundedVector(tempVector); if (!grid.IsWithinAndEmpty(tempVector)) { return(false); } } return(true); }
public void ConstructPiece() { if (!canPlay) { return; } // GameObject temp = GetRandomObject(pieces); GameObject temp = GetRandomFromBag(); Vector2 tempPos = RoundVector.RoundedVector(constructorPos.position); Group tempGroup = Instantiate(temp, tempPos, Quaternion.identity).GetComponent <Group>(); tempGroup.Setup(grid); currentGroup = tempGroup; }
//Verifica se a posição da peça é valida por estar dentro do grid e em um espaço vazio bool IsValidPosition() { //Faz a verificação em cada bloco que compõe a peça for (int i = 0; i < blocks.Length; i++) { Vector2 blockPos = new Vector2(blocks[i].transform.position.x, blocks[i].transform.position.y); blockPos = RoundVector.RoundedVector(blockPos); if (!grid.IsInsideAndEmpty(blockPos)) { return(false); } } return(true); }
//Arredonda a posição da peça para valores inteiros void RoundPosition() { Vector2 newPos = RoundVector.RoundedVector(new Vector2(transform.position.x, transform.position.y)); transform.position = new Vector3(newPos.x, newPos.y, 0f); }
void StoreBlockInGrid(GameObject block) { Vector2 intPosition = RoundVector.RoundedVector(new Vector2(block.transform.position.x, block.transform.position.y)); grid[(int)intPosition.x, (int)intPosition.y] = block; }
void RoundPosition() { Vector2 tempVector = RoundVector.RoundedVector(new Vector2(transform.position.x, transform.position.y)); transform.position = new Vector3(tempVector.x, tempVector.y); }