public void CreatePiece(PieceData blockData) { m_myMasuBlocks.ForEach(x => Destroy(x)); m_myMasuBlocks = new List <GameObject>(); var centerIndex = new Vector2Int(1, 1); for (int x = 0; x < blockData.BlockData.GetLength(0); x++) { for (int y = 0; y < blockData.BlockData.GetLength(1); y++) { var celltype = blockData.BlockData[x, y].m_cellType; if (celltype == Cell.CellType.None || celltype == Cell.CellType.Wall) { continue; } var creteIndex = new Vector2Int(x, y) - centerIndex; var createPosition = m_offsetX * creteIndex.x + m_offsetY * creteIndex.y; var targetPrefab = (celltype == Cell.CellType.Vanish) ? m_vanishKomaPrefab : m_normalKomaPrefab; var obj = Instantiate(targetPrefab, Vector2.zero, Quaternion.identity, m_PieceAnchor); obj.transform.localPosition = createPosition; m_myMasuBlocks.Add(obj); } } }
private void Test_createBlock() { var blockData = new PieceData(new Cell[, ] { { new Cell(Vector2Int.zero, Cell.CellType.Normal), new Cell(Vector2Int.zero, Cell.CellType.Normal), new Cell(Vector2Int.zero, Cell.CellType.Normal) }, { new Cell(Vector2Int.zero, Cell.CellType.None), new Cell(Vector2Int.zero, Cell.CellType.Normal), new Cell(Vector2Int.zero, Cell.CellType.None) }, { new Cell(Vector2Int.zero, Cell.CellType.None), new Cell(Vector2Int.zero, Cell.CellType.Vanish), new Cell(Vector2Int.zero, Cell.CellType.None) } }); m_displayer.CreatePiece(blockData); }
public void SetPieceData(PieceData data, int hand) { m_blockDataList[hand] = data; m_displayerList[hand].CreatePiece(m_blockDataList[hand]); }