Exemplo n.º 1
0
        public PageHandler(string gatewayServerAddress)
        {
            shuffUIManager = new ShuffUIManager();

            gameDrawer = new GameDrawer();
            TimeTracker = new TimeTracker();

            var gateway = new Gateway(gatewayServerAddress,false);
            ClientGameManager = new ClientGameManager(gateway);
            ClientSiteManager = new ClientSiteManager(gateway);
            ClientDebugManager = new ClientDebugManager(gateway);
            ClientChatManager = new ClientChatManager(gateway);

            ClientInfo = new ClientInformation();
            this.GameManager = new GameManager(this);

            LoginUI = new LoginUI(shuffUIManager, this);
            HomeUI = new HomeUI(shuffUIManager, this);
            QuestionUI = new QuestionUI(shuffUIManager, this);

            /*gateway.On("Area.Lobby.ListCardGames.Response", (data) => { });
            gateway.On("Area.Lobby.ListRooms.Response", (data) => { Logger.Log });*/

            //ie8
            /*   {
                   dynamic d2 = (Action<string, ElementEventHandler>)Document.Body.AttachEvent;

                   var m = (Action<string, ElementEventHandler>)d2;
                   m("contextmenu", () =>
                       {

                       });
               }*/
        }
Exemplo n.º 2
0
        private void start(string gatewayAddress, string gameName, bool create)
        {
            int myCount = count++;
            var gateway = new Gateway(gatewayAddress, true);
            ClientSiteManager clientManager = new ClientSiteManager(gateway);
            ClientGameManager gameManager = new ClientGameManager(gateway);
            ClientChatManager chatManager = new ClientChatManager(gateway);
            ClientDebugManager debugManager = new ClientDebugManager(gateway);
            clientManager.Login(userName = randomString(10), "");
            clientManager.OnLogin += (user, response) => {
                Console.WriteLine("Success: " + response.Successful + "    " + user.UserName + myCount);
                                         if (create)
                                             clientManager.CreateRoom(new CreateRoomRequest("Sevens", gameName));
                                         else {
                                             Global.SetTimeout(() => { clientManager.JoinRoom(new RoomJoinRequest("Sevens", gameName)); },
                                                               3000);
                                         }
                                     };
            clientManager.OnGetRoomsReceived += (user, response) => {
                                                    /*     foreach (var room in response.Rooms) {
                    if (room.Players.Count < 6) {
                        clientManager.JoinRoom(new RoomJoinRequest("Sevens", room.RoomName));
                        return;
                    }
                }*/
                                                };

         
            clientManager.OnRoomJoined += (user, response) => {
                Console.WriteLine("joined " + response.Room.Players.Count + " Players");
 
                                                  if (response.Room.Players.Count == 6)
                                                      clientManager.StartGame(new StartGameRequest());
                                              
                                          };
            clientManager.OnGetRoomInfoReceived += (user, response) => {
                                                       
                                                   };
            gameManager.OnGameStarted += (user, model) => { Console.WriteLine("Game Started: " + model.RoomID + "  " + userName); };

            gameManager.OnGameOver += (user, model) => { 
                                          gateway.Close();
                if(create)
                                          runGame(); 
                                      };

            gameManager.OnAskQuestion += (user, model) => {
                Console.WriteLine("Question Asked: " + user.UserName + "   Num Of Answers: " + model.Answers.Length);
                                             gameManager.AnswerQuestion(new GameAnswerQuestionModel(1));
                                         };
            gameManager.OnUpdateState += (user, s) => {
                                             //Console.Log("state updated ");
                                         };
        }
 public ClientSiteManagerService(GatewayService gateway)
 {
     clientSiteManager = new ClientSiteManager(gateway.Gateway);
     clientSiteManager.OnGetGameTypesReceived += (user, model) => OnGetGameTypesReceived.Trigger(user, model);
     clientSiteManager.OnLogin += (user, model) => OnLogin.Trigger(user, model);
     clientSiteManager.OnUserCreate += (user, model) => OnUserCreate.Trigger(user, model);
     clientSiteManager.OnGetRoomsReceived += (user, model) => OnGetRoomsReceived.Trigger(user, model);
     clientSiteManager.OnRoomJoined += (user, model) => OnRoomJoined.Trigger(user, model);
     clientSiteManager.OnGetRoomInfoReceived += (user, model) => OnGetRoomInfoReceived.Trigger(user, model);
     clientSiteManager.OnGetGamesByUserReceived += (user, model) => OnGetGamesByUserReceived.Trigger(user, model);
     clientSiteManager.OnDoesGameNameExistReceived += (user, model) => OnDoesGameNameExistReceived.Trigger(user, model);
     clientSiteManager.OnDeveloperCreateGameReceived += (user, model) => OnDeveloperCreateGameReceived.Trigger(user, model);
     clientSiteManager.OnDeveloperUpdateGameReceived += (user, model) => OnDeveloperUpdateGameReceived.Trigger(user, model);
 }