Exemplo n.º 1
0
 public Game(int gameId, IGameUserManager gameUserManager, IGameMessageHandler gameMessageHandler)
 {
     gameStatus              = GameStatus.Idle;
     this.gameUserManager    = gameUserManager;
     this.gameMessageHandler = gameMessageHandler;
     this.gameUserManager.UserDisconnected += OnUserDisconnected;
 }
Exemplo n.º 2
0
 public bool CreateGame(int gameId, User host)
 {
     try
     {
         IGameUserManager    gameUserManager    = ServiceFactory.CreateGameUserManager(webSocketHandler, host);
         IGameMessageHandler gameMessageHandler = ServiceFactory.CreateGameMessageHandler(gameUserManager, webSocketHandler);
         var game      = new MapGame(gameId, gameUserManager, gameMessageHandler);
         var isSuccess = games.TryAdd(gameId, game);
         return(isSuccess);
     }
     catch
     {
         return(false);
     }
 }
Exemplo n.º 3
0
 public MapGame(int gameId, IGameUserManager gameUserManager, IGameMessageHandler gameMessageHandler) : base(gameId, gameUserManager, gameMessageHandler)
 {
 }
Exemplo n.º 4
0
 public static IGameMessageHandler CreateGameMessageHandler(IGameUserManager gameUserManager, WebSocketHandler webSocketHandler)
 {
     return(new GameMessageHandler(gameUserManager, webSocketHandler));
 }
Exemplo n.º 5
0
 public GameMessageHandler(IGameUserManager gameUserManager, WebSocketHandler webSocketHandler)
 {
     this.gameUserManager  = gameUserManager;
     this.webSocketHandler = webSocketHandler;
 }