public string[] List() { MultiPlayerModel model = MultiPlayerModel.GetInstance(); string[] gamesArray = model.GetListOfGames(); return(gamesArray); //JObject gamesArray = JObject.Parse(gamesArrayJsonStr); //string[] gamesArray = JsonConvert.DeserializeObject<string[]>(gamesArrayJsonStr); //return gamesArray; }
public JObject Start(string gameName, int rows, int cols) { //Clients.All.hello(); MultiPlayerModel model = MultiPlayerModel.GetInstance(); string clientID = Context.ConnectionId; string mazeAsString = model.Start(gameName, rows, cols, clientID); Maze maze = Maze.FromJSON(mazeAsString); JObject obj = JObject.Parse(maze.ToJSON()); return(obj); }
public JObject Join(string gameName) { MultiPlayerModel model = MultiPlayerModel.GetInstance(); string clientID = Context.ConnectionId; string mazeAsString = model.Join(gameName, clientID); Maze maze = Maze.FromJSON(mazeAsString); string otherPlayerID = model.GetOtherPlayerID(clientID); JObject obj = JObject.Parse(maze.ToJSON()); //TODO: Call to function to draw the mazes on other player client(by notify to otherPlayerID ). Clients.Client(clientID).drawMazes(obj); Clients.Client(otherPlayerID).drawMazes(obj); return(obj); }
public void Play(string direction, int oldRow, int oldCol) { MultiPlayerModel model = MultiPlayerModel.GetInstance(); string clientID = Context.ConnectionId; string otherPlayerID = model.GetOtherPlayerID(clientID); //TODO: Call to function to draw this move on the other client canvas. if (direction == "won") { Clients.Client(otherPlayerID).otherWon(); } else { Clients.Client(otherPlayerID).otherMoving(direction, oldRow, oldCol); } }