public void SpawnNextTetromino() // спавнит фигуры { if (!gameStarted) // если игра только началась, создает фигуру для управления и показывает следующую фигуру { grid = new Transform[gridWidth, gridHeight]; currentScore = 0; numLineCleared = 0; gameStarted = true; previewTetromino = Instantiate(GetRandomTetromino(), previewPoint, Quaternion.identity, locationspawn); nextTetromino = Instantiate(GetRandomTetromino(), spawnPoint, Quaternion.identity, locationspawn); previewTetromino.GetComponent <Tetromino>().enabled = false; previewTetromino.GetComponent <GhostTetromino>().enabled = false; nextTetromino.GetComponent <GhostTetromino>().enabled = false; GlobalScore.Instance.Global(this, nextTetromino); nextTetromino.Initialize(this); SpawnGhostTetromino(); } else//если игра уже идет, следующую фигуру перемещает под управление игрока и показывает следующую фигуру { previewTetromino.transform.position = spawnPoint; nextTetromino = previewTetromino; nextTetromino.GetComponent <Tetromino>().enabled = true; previewTetromino = Instantiate(GetRandomTetromino(), previewPoint, Quaternion.identity, locationspawn); previewTetromino.GetComponent <Tetromino>().enabled = false; previewTetromino.GetComponent <GhostTetromino>().enabled = false; nextTetromino.GetComponent <GhostTetromino>().enabled = false; GlobalScore.Instance.Global(this, nextTetromino); nextTetromino.Initialize(this); SpawnGhostTetromino(); } }
public void SpawnGhostTetromino() { if (GameObject.FindGameObjectWithTag("GhostTetromino1Player") != null && playerNumber == 1) { Destroy(GameObject.FindGameObjectWithTag("GhostTetromino1Player")); } if (GameObject.FindGameObjectWithTag("GhostTetromino2Player") != null && playerNumber == 2) { Destroy(GameObject.FindGameObjectWithTag("GhostTetromino2Player")); } ghostTetromino = Instantiate(nextTetromino, nextTetromino.transform.position, Quaternion.identity, locationspawn); ghostTetromino.InitializeGostTetromino(this, nextTetromino); Destroy(ghostTetromino.GetComponent <Tetromino>()); ghostTetromino.GetComponent <GhostTetromino>().enabled = true; }
public void SpawnNewTetrominoIntoGrid() { if (gridState != GridState.InsertingNewTetromino && gridState != GridState.PoccessingLimitsExceded && gridState != GridState.ProcessingRoundComplete ) { gridState = GridState.InsertingNewTetromino; var tetrominoObject = TetrominoPool.instance.GetPooledTetroMinoObject(); currentTetromino = tetrominoObject.GetComponent <Tetromino>(); currentTetromino.transform.SetParent(this.gameObject.transform); currentTetromino.Initialize(this, nextTetroMinoType); currentTetromino.transform.localPosition = spawnPoint; currentTetromino.name = "Tetromino" + spawnedTetrominos; tetrominosList.Add(currentTetromino.GetComponent <Tetromino>()); spawnedTetrominos++; player.round.IncrementTetroMinosSpawned(nextTetroMinoType); ProcessNextTetromino(); currentTetrominoMovement = currentTetromino.GetComponent <TetrominoMovement>(); currentTetrominoMovement.Initialize(this, currentTetromino); } }