public string generateCommand() { openConnection(); StringBuilder sb = new StringBuilder(); sb.Append("generate "); sb.Append(mazeName.ToString()); sb.Append(" " + MazeRows.ToString()); sb.Append(" " + MazeCols.ToString()); myMission = sb.ToString(); writer.WriteLine(myMission); writer.Flush(); // read all result string result = reader.ReadLine(); //string resultAllData; while (true) { // we add '@' char for each string that we want to print, and stop the printing // when we arrive this char. if (reader.Peek() == '@') { result.TrimEnd('\n'); break; } result += reader.ReadLine(); } reader.DiscardBufferedData(); //close the connection CloseConnection(); return(result); }
/// <summary> /// update the source. /// </summary> public void BindingUpdateSource() { BindingExpression be = ServerIP.GetBindingExpression(UCTextField.ValueProperty); be.UpdateSource(); be = ServerPort.GetBindingExpression(UCTextField.ValueProperty); be.UpdateSource(); be = MazeRows.GetBindingExpression(UCTextField.ValueProperty); be.UpdateSource(); be = MazeCols.GetBindingExpression(UCTextField.ValueProperty); be.UpdateSource(); }
public void StartGame() { string strMaze = model.startCommand("start " + MazeNames.ToString() + " " + MazeRows.ToString() + " " + MazeCols.ToString()); // convert the json to maze object // string strMaze = model.generateCommand(); MyMaze = Maze.FromJSON(strMaze); // update properties MazeRows = MyMaze.Rows; MazeCols = MyMaze.Cols; MazeNames = MyMaze.Name; InitialPosition = MyMaze.InitialPos; // update current position to the start point in maze CurrentPosition = MyMaze.InitialPos; EndPosition = MyMaze.GoalPos; }