Ejemplo n.º 1
0
        /// <summary>
        /// Calls join to function of model and call draw board on
        /// clients in game.
        /// </summary>
        /// <param name="nameOfGame">name of game</param>
        public void JoinTo(string nameOfGame)
        {
            ServerModel model = ServerModel.GetInstance();
            // current player
            string clientId = Context.ConnectionId;
            Maze   maze     = model.JoinTo(nameOfGame, Context.ConnectionId);

            // my boards
            Clients.Client(clientId).drawBoard("myCanvas", maze.ToJSON(),
                                               "playerImg", "exitImg", true);
            Clients.Client(clientId).drawBoard("competitorCanvas", maze.ToJSON(),
                                               "competitorImg", "exitImg", false);
            // competitor
            string opponentId = model.GetCompetitorOf(clientId);

            Clients.Client(opponentId).drawBoard("competitorCanvas", maze.ToJSON(),
                                                 "competitorImg", "exitImg", false);
            // notify other player
            Clients.Client(opponentId).gameStarted();
        }