public void UpdateGrid(TetroMino tetroMino) //запись в Grid новых Tetromino { for (int y = 0; y < GridHeight; y++) { for (int x = 0; x < GridWeight; x++) { if (grid[x, y] != null) { if (grid[x, y].parent == tetroMino.transform) { grid[x, y] = null; } } } } foreach (Transform mino in tetroMino.transform) { Vector2 pos = Round(mino.position); if (pos.y < GridHeight) { grid[(int)pos.x, (int)pos.y] = mino; } } }
/// <summary> /// Проверка на превышение верхней границы грид /// </summary> /// <param name="tetromino"></param> /// <returns></returns> public bool CheckIsAboveGrid(TetroMino tetromino) { foreach (Transform mino in tetromino.transform) { Point pos = ReverseVector(TetroMino.positionDeterminationMino(mino)); if (pos.j > GridHeight - 1) { return(true); } } return(false); }
public bool CheckIsAboveGrid(TetroMino tetromino) { foreach (Transform mino in tetromino.transform) { Vector2 pos = Round(mino.position); if (pos.y > GridHeight - 1) { return(true); } } return(false); }
public void GoStart(Player player) { for (int y = 0; y < GridHeight; y++) { for (int x = 0; x < GridWeight; x++) { grid[x, y] = null; } } this.player = player; previewTetromino = null; hub_Name.text = player.GetName; timer = Time.time; SpawnNextTetromino(); }
/// <summary> /// запись в Grid новых Tetromino /// </summary> /// <param name="tetroMino"></param> public void UpdateGrid(TetroMino tetroMino) { for (int y = 0; y < GridHeight; y++) { for (int x = 0; x < GridWeight; x++) { if (grid[x, y] != null && grid[x, y].parent == tetroMino.transform) { grid[x, y] = null; } } } foreach (Transform mino in tetroMino.transform) { Point pos = ReverseVector(TetroMino.positionDeterminationMino(mino)); if (pos.j < GridHeight) { grid[(int)pos.i, (int)pos.j] = mino; } } }
public void SpawnNextTetromino() { if (previewTetromino == null) { GameObject next = (GameObject)Instantiate(GetRandomTetromino(), transform); changeGridPosition = new Vector3(4, 20, 0); nextTetromino = next.GetComponent <TetroMino>(); } else { nextTetromino = previewTetromino; nextTetromino.enabled = true; nextTetromino.transform.parent = transform; nextTetromino.transform.localPosition = Vector3.zero; } nextTetromino.SetGame = this; GameObject preview = (GameObject)Instantiate(GetRandomTetromino(), previewTetrominoTransform); previewTetromino = preview.GetComponent <TetroMino>(); previewTetromino.enabled = false; }