Today we talked about the multiplayer mode of our games again. Todd talked about the JSon coding that he had been working on, and how we will need to implement it into our game.
Todd will give us JsnDrop code (which we will place in jsnDrop class) and we will drag this script onto a GUI component.
Making use of Jsn system is when I ask person to move.
The code we put into the MoveInDirection() function of Player, which in my application is Move() in the Person class and this below code allows our player class to interact with the json server:
string anID = MakePlayerID();
To split a the jsn command handed to the server we worked through the different methods of splitting a string into a list of json things and then we can jsonise these things.
I suggested the use of the arguments.split function which was recommended as an answer to a question in this stackoverflow webpage http://stackoverflow.com/questions/39763521/split-not-parse-a-string-into-command-line-args-c-sharp
The code we decided on to use to split the string from the server as a result of the JsnGet command was:
private List<string> getJSNStrings(string pServer) //Get my Jsn strings. i.e. break information from server and put it in a list
{
List<string> result = new List<string>(); //create a string array
var parts = Regex.Split(pServer, “},{“); //Use a regular expression to split the string from json where there is a },{ in the string
foreach(string part in parts)
{
string newString = part.Replace(“{“,””); //Split the curly brackets off the split values
newString = newString.Replace(“}”,””);
newString = “{“+newString+”}”;
result.Add(newString); //Produce a list of the json records we are after.
Debug.Log(newString);
}
return result;
}
So using the supplied code what do we have to do for milestone 3?
We need to display what scene each player is in at a particular point in time.
e.g.
Player 1 Scene 5
Player 2 scene 10
One way to do this is having another screen (like inventory screen) that calls the server to get the player information to display it. So every time the player moves scene we need to call the function that inputs the player and scene data to the server by JsnPut command.
Every time you move you need to get the player information of what scene each player is at in a specific point in time.


