public void SaveBoard(bool playersTurn, string name) { //open stream with SaveLoadStream = new StreamWriter(Application.dataPath + "/Resources/" + name + ".txt"); //save board from dll string row = ""; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { row += (char)DLLFunctions.GetPiece(x, y); } if (y != 7) { row += Environment.NewLine; } } //send to file instance.Save(row); instance.Save(playersTurn.ToString()); SaveLoadStream.Close(); }
//generate grid and assign pieces private void GenerateBoard() { //generate board from dll checkersboard for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { GeneratePiece((char)DLLFunctions.GetPiece(x, y), x, y); } } //output initial board DebugLog.Instance.Write("The board has been generated as"); DebugLog.Instance.OutPutBoard(isDark); }
//output board for log public void OutPutBoard(bool playersTurn) { //output board from dll string row = ""; for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { row += (char)DLLFunctions.GetPiece(x, y); } row += Environment.NewLine; } EchoToConsole = AddTimeStamp = false; //turn off flags Write(row); //output board to write EchoToConsole = AddTimeStamp = true; //turn on flags }
private void UpdateBoard() { for (int y = 0; y < 8; y++) { for (int x = 0; x < 8; x++) { //erase current board Piece p = pieces[x, y]; if (p != null) { pieces[x, y] = null; Destroy(p.gameObject); } //reinitialises the board with updated values GeneratePiece((char)DLLFunctions.GetPiece(x, y), x, y); } } }