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", () => { }); }*/ }
public ClientGameManagerService(GatewayService gateway) { clientGameManager = new ClientGameManager(gateway.Gateway); clientGameManager.OnAskQuestion += (user, model) => { OnAskQuestion.Trigger(user, model); }; clientGameManager.OnGameOver += (user, model) => OnGameOver.Trigger(user, model); clientGameManager.OnGameStarted += (user, model) => OnGameStarted.Trigger(user, model); clientGameManager.OnUpdateState += (user, model) => OnUpdateState.Trigger(user, model); }
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 GameManager(PageHandler pageHandler) { PageHandler = pageHandler; ClientGameManager = pageHandler.ClientGameManager; Init( ); }