Пример #1
0
        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;
        }
Пример #2
0
        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);
        }
Пример #3
0
        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);
        }
Пример #4
0
        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);
            }
        }