private string GetGameUrl(Game game, PlayerDataResponse playerInfo) { var player = _repository.Players.Single(x => x.Id == playerInfo.id.Value); var brand = _repository.Brands .Include(x => x.BrandGameProviderConfigurations) .Include(x => x.BrandGameProviderConfigurations.Select(c => c.GameProviderConfiguration)) .Single(x => x.Id == player.BrandId); var providers = _repository.GameProviders.Where(x => x.IsActive).ToList(); var gameProvider = providers.Single(x => x.Id == game.GameProviderId); var url = brand.BrandGameProviderConfigurations.First(bc => bc.GameProviderId == gameProvider.Id) .GameProviderConfiguration.Endpoint; var token = playerInfo.token; if (string.IsNullOrEmpty(url)) { throw new ArgumentException(); } url = url + game.EndpointPath; url = url.Replace("{GameName}", game.Name); url = url.Replace("{GameId}", game.ExternalId); url = url.Replace("{GameProviderId}", gameProvider.Id.ToString()); var limiter = url.IndexOf('?') > 0 ? '&' : '?'; return(url + limiter + "token=" + token); }
/// <summary> /// This will retrieve the data for the player. Since the data can change depending /// on the game we need to pass the reponse serializable definition so we can /// parse it from the APIs JSON response /// </summary> public static void LoadData(OnRequestFinish callback) { string playerDataUrl = string.Format( "/games/{0}/player/data", Proba.Configuration.GameId ); Request request = new Request(playerDataUrl); request.Get().onFinish += (r) => { PlayerDataResponse response = JsonUtility.FromJson <PlayerDataResponse>(r.Response); callback(response.data); }; }
void FinallyLogin(PlayerDataResponse response) { string nextScene; if (response.scene == null) { nextScene = firstSceneOnNewAccount; } else { nextScene = response.scene; } WarpGateData.nextSceneName = nextScene; StartCoroutine(nakama.ClientJoinMatchByMatchId(nextScene)); }
private void SetupHandlers() { matchPresenceHandler = (presenceEvent) => { foreach (var presence in presenceEvent.Leaves) { EventManager.onRemoteDisconnectedPlayer.Invoke(presence); connectedOpponents.Remove(presence); } foreach (var presence in presenceEvent.Joins) { EventManager.onRemoteConnectedPlayer.Invoke(presence); } connectedOpponents.AddRange(presenceEvent.Joins); Debug.LogFormat("Connected opponents: [{0}]", string.Join(",\n ", connectedOpponents)); }; matchStateHandler = (state) => { switch (state.OpCode) { case 1: string data_json_string = System.Text.Encoding.UTF8.GetString(state.State, 0, state.State.Length); if (debugPackets) { Debug.Log(data_json_string); } Dictionary <string, object> player_data = (Dictionary <string, object>)Json.Deserialize(data_json_string); foreach (KeyValuePair <string, object> entry in player_data) { Dictionary <string, object> client = (Dictionary <string, object>)entry.Value; object data = (Dictionary <string, object>)client["data"]; PlayerDataResponse pData = JsonUtility.FromJson <PlayerDataResponse>(Json.Serialize(data)); //TODO: I'm doing an extra serial/deserialize to just get it working. Fix later. pData.name = (string)client["username"]; pData.userId = (string)client["user_id"]; playerData[pData.userId] = pData; } break; default: break; } }; }
public async void GetLoginInfo() { StorageObjectId[] objs = new StorageObjectId[] { new StorageObjectId { Collection = "character", Key = "location", UserId = session.UserId } }; IApiStorageObjects result = await client.ReadStorageObjectsAsync(session, objs); foreach (IApiStorageObject entry in result.Objects) { //Debug.Log(entry.Value); PlayerDataResponse pData = JsonUtility.FromJson <PlayerDataResponse>(entry.Value); EventManager.onGetLoginInformation.Invoke(pData); return; } EventManager.onGetLoginInformation.Invoke(new PlayerDataResponse()); }
GameObject InstantiateRemotePlayer(PlayerDataResponse response) { PlayerGender gender = (PlayerGender)System.Enum.Parse(typeof(PlayerGender), response.gender); GameObject rPlayer; switch (gender) { case PlayerGender.MALE: rPlayer = Instantiate(remoteMalePlayerPrefab, response.position, response.rotation); rPlayer.tag = "init_not_synced"; rPlayer.name = response.userId; return(rPlayer); case PlayerGender.FEMALE: rPlayer = Instantiate(remoteFemalePlayerPrefab, response.position, response.rotation); rPlayer.tag = "init_not_synced"; rPlayer.name = response.userId; return(rPlayer); default: return(null); } }
private async Task <ProductsDataResponse> GetProductsDataAsync(Guid lobbyId, PlayerDataResponse playerInfo) { var player = _repository.Players.Single(x => x.Id == playerInfo.id.Value); var lobby = await _repository.Lobbies.Include(x => x.GameGroups).SingleAsync(x => x.Id == lobbyId); var brand = await _repository.Brands.Include(x => x.BrandGameProviderConfigurations).SingleAsync(x => x.Id == player.BrandId); var gameGroups = lobby.GameGroups.ToList(); var gameGroupsData = new List <GameGroupSummary>(); var gameProviders = new List <GameProviderSummary>(); foreach (var gameGroup in gameGroups) { var games = gameGroup.GameGroupGames.Select(x => x.Game).ToList(); if (games.Count == 0) { continue; } var providers = games.Select(x => x.GameProvider).Distinct().ToList(); var lobbyGameGroup = new GameGroupSummary() { code = gameGroup.Code, name = gameGroup.Name, order = 0, games = games.Select(x => new GameSummary { id = x.ExternalId, name = x.Name, code = x.Code, url = GetGameUrl(x, playerInfo), isactive = x.IsActive && lobby.IsActive && x.GameProvider.IsActive && x.GameProvider.GameProviderConfigurations.First(c => c.Id == brand.BrandGameProviderConfigurations .First(bc => bc.GameProviderId == x.GameProviderId).GameProviderConfigurationId).IsActive, //popup_width = , //popup_height = , order = 0, iconpath = "Content/images/game1.png", providercode = x.GameProvider.Code, tags = new string[] { } }).ToArray() }; gameProviders.AddRange(providers.Where(x => gameProviders.All(gp => gp.code != x.Code)).Select(x => new GameProviderSummary { code = x.Code, name = x.Name, //betlimitid = })); gameGroupsData.Add(lobbyGameGroup); } var membersiteUrl = _commonSettingsProvider.GetMemberWebsiteUrl(); return(new ProductsDataResponse { lobbyid = lobby.Id, cdnroot = membersiteUrl, iconres = new string[] {}, groups = gameGroupsData.ToArray() }); }
public static void Build(JSONObject response) { ResponseEvent responseEvent = Spil.MonoInstance.gameObject.AddComponent <ResponseEvent>(); responseEvent.eventName = response.GetField("name").str; if (response.HasField("type")) { responseEvent.type = response.GetField("type").str; } if (response.HasField("action")) { responseEvent.action = response.GetField("action").str; } if (response.HasField("data")) { responseEvent.data = response.GetField("data"); } if (responseEvent.type != null) { switch (responseEvent.type.ToLower().Trim()) { case "advertisement": AdvertisementResponse.ProcessAdvertisementResponse(responseEvent); break; case "overlay": OverlayResponse.ProcessOverlayResponse(responseEvent); break; case "gameconfig": ConfigResponse.ProcessConfigResponse(responseEvent); break; case "packages": PackagesResponse.ProcessPackagesResponse(responseEvent); break; case "notification": break; case "gamedata": GameDataResponse.ProcessGameDataResponse(responseEvent); break; case "promotions": PromotionsResponse.ProcessPromotionResponse(responseEvent); break; case "userdata": UserDataResponse.ProcessUserDataResponse(responseEvent); break; case "playerdata": PlayerDataResponse.ProcessPlayerDataResponse(responseEvent); break; case "gamestate": GameStateResponse.ProcessGameStateResponse(responseEvent); break; case "reward": RewardResponse.ProcessRewardResponse(responseEvent); break; case "liveevent": LiveEventResponse.ProcessLiveEventResponse(responseEvent); break; case "authentication": SocialLoginResponse.ProcessSocialLoginResponse(responseEvent); break; } } GameObject.Destroy(responseEvent); }