public void RefreshBuilder() { // Refresh board state selectors allBoardStates.Setup <Board.BoardState> ( board.boardStates.ToArray(), (button, boardState) => { RefreshStateButton(button, boardState); } ); // Refresh grid size displayArray = new Cell[gridHeight][]; for (int i = 0; i < gridHeight; i++) { displayArray [i] = new Cell[gridWidth]; for (int j = 0; j < gridWidth; j++) { int index = i * gridWidth + j; // create an existing Cell and add to the master list if we need to if (masterCellList.Count <= index) { Cell newCell = new Cell(SaFrMo.GenerateRandomString(), "Cell " + index); masterCellList.Add(newCell); } displayArray [i] [j] = masterCellList [index]; } } boardRows.Setup <Cell[]> ( displayArray, (row, cells) => { row.GetComponent <MenuRefresher> ().Setup <Cell> ( cells, (button, cell) => { button.GetComponentInChildren <CellLink>().LinkTo(cell); } ); } ); // Refresh cell selectors allCells.Setup <Cell> ( board.cells.ToArray(), (button, cell) => { RefreshCellButton(button, cell); } ); // Make sure each cell has a GameObject // cellActors.Setup<Cell> ( // board.cells.ToArray (), // (createdObject, originalCell) => { // // } // ); }
public Board.BoardState AddState(string id, string name = "New State") { // Make sure our ID is unique while (board.boardStates.FindAll(x => x.id == id).Count > 0) { id = SaFrMo.GenerateRandomString(); } Board.BoardState newState = new Board.BoardState(id, name); board.boardStates.Add(newState); RefreshBuilder(); return(newState); }
public Cell AddCell(string id, string name = "New Cell") { // Make sure our ID is unique while (board.cells.FindAll(x => x.id == id).Count > 0) { id = SaFrMo.GenerateRandomString(); } Cell newCell = new Cell(id, name); board.cells.Add(newCell); RefreshBuilder(); return(newCell); }