public void DestroyBoardIO(BoardIO boardIo) { // Destroy all the outputs foreach (GameObject o in boardIo._outputModuleGameObjects) { // Unsubscribe from all inputs foreach (GameObject i in boardIo._inputModuleGameObjects) { o.GetComponent <IOutputModule> ().UnsubscribeFromInput(i.GetComponent <IInputModule>()); } GameObject.Destroy(o); } // Destroy all the inputs foreach (GameObject i in boardIo._inputModuleGameObjects) { i.GetComponent <IInputModule> ().DestroyInput(); GameObject.Destroy(i); } // Once all inputs and outputs are unsubscribed and destroyed, destroy the BoardIo itself GameObject.Destroy(boardIo._handle.gameObject); GameObject.Destroy(boardIo.gameObject); }
/// <summary> /// Load a board, pass it to a new algorithm instance and run it. /// The IO operation will cause an error if the file is missing. /// Here the file is looked for in the same directory as the executable /// usually \bin\Debug\ whilst developing /// </summary> static void Main() { Board board = BoardIO.getBoard("testMap.xml"); AbstractAlgorithm alg = new DemoConsoleAlgorithm(board); alg.run(); }
public void AddBoardIO(Board board) { // Instantiate the prefab GameObject newBoardIoGameObject = GameObject.Instantiate(_boardIoPrefab, _boardIoPrefab.transform.position, Quaternion.identity, _boardIoRoot.transform); BoardIO newBoardIo = newBoardIoGameObject.GetComponent <BoardIO> (); newBoardIo._board = board; newBoardIo.Init(); _boardIoDictionary.Add(board, newBoardIo); }
public void DestroyBoard(Board board) { // Destroy all the notes foreach (Note n in board._notes) { n.DestroyNote(); GameObject.Destroy(n.gameObject); } // Destroy the BoardIOs and unsubscribe from all events BoardIO thisBoardIo = BoardIOManager._instance._boardIoDictionary[board]; BoardIOManager._instance.DestroyBoardIO(thisBoardIo); BoardIOManager._instance._boardIoDictionary.Remove(board); GameObject.Destroy(board._root); GameObject.Destroy(board._handle.gameObject); GameObject.Destroy(board.gameObject); }