/// <summary> /// Called once the server handles the client's registration request. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Instance_Registered(object sender, BooleanEventArgs e) { if (e.Answer) { isConnecting = false; isConnected = true; NetworkManager.Instance.GetAvailableGames(); } else { isConnecting = false; error = "Register failed"; } }
/// <summary> /// Called once the server responds to the user's request to create a new game. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Instance_NewGameCreated(object sender, BooleanEventArgs e) { if (e.Answer) { PhoneApplicationService.Current.State[Constants.YachtStateKey] = new YachtState(); ExitScreen(); Dispose(); ScreenManager.AddScreen(new GameplayScreen(GameTypes.Online), null); } else { EnterGameName("The name is in use", NetworkManager.Instance.gameName); } }
/// <summary> /// Handler called once a new game instance has been created. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Instance_NewGameCreated(object sender, BooleanEventArgs e) { NetworkManager.Instance.NewGameCreated -= Instance_NewGameCreated; if (e.Answer) { NetworkManager.Instance.GetGameState(); } else { Guide.BeginShowMessageBox("Cannot create the game with same name the name is in use", "", new String[] { "OK" }, 0, MessageBoxIcon.Alert, null, null); ExitScreen(); Dispose(); ScreenManager.AddScreen(new SelectOnlineGameScreen(NetworkManager.Instance.name), null); } }
/// <summary> /// Handler called once the server recognizes the player's request to join a game. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void Instance_JoinedGame(object sender, BooleanEventArgs e) { if (e.Answer) { PhoneApplicationService.Current.State[Constants.YachtStateKey] = new YachtState(); ExitScreen(); Dispose(); ScreenManager.AddScreen(new GameplayScreen(GameTypes.Online), null); } else { Guide.BeginShowMessageBox("Cannot join this game", " ", new String[] { "OK" }, 0, MessageBoxIcon.Alert, null, null); } }