public static void GetCharacterDataById(string characterId) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetCharacterReadOnlyData); GetCharacterDataRequest request = new GetCharacterDataRequest(); //request.PlayFabId = PlayFabSettings.PlayerId; request.CharacterId = characterId; request.Keys = new List <string>() { "CharacterData" }; PlayFabClientAPI.GetCharacterReadOnlyData(request, (result) => { if (result.Data.ContainsKey("CharacterData")) { playerCharacterData[result.CharacterId] = PlayFabSimpleJson.DeserializeObject <FG_CharacterData>(result.Data["CharacterData"].Value); PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetCharacterReadOnlyData, MessageDisplayStyle.none); } }, PF_Bridge.PlayFabErrorCallback); }
public static void GetFriendsList(UnityAction callback = null) { var request = new GetFriendsListRequest { IncludeFacebookFriends = true, IncludeSteamFriends = false }; //DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetFriendList); PlayFabClientAPI.GetFriendsList(request, result => { playerFriends.Clear(); foreach (var eachFriend in result.Friends) { playerFriends.Add(eachFriend); } if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GetFriendList, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
/// <summary> /// Login with Facebook token. /// </summary> /// <param name="token">Token obtained through the FB plugin. (works on mobile and FB canvas only)</param> public static void LoginWithFacebook(string token, bool createAccount = false, UnityAction errCallback = null) { //LoginMethodUsed = LoginPathways.facebook; LoginWithFacebookRequest request = new LoginWithFacebookRequest(); request.AccessToken = token; request.TitleId = PlayFabSettings.TitleId; request.CreateAccount = createAccount; DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin); PlayFabClientAPI.LoginWithFacebook(request, OnLoginResult, (PlayFabError error) => { if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound) { errCallback(); PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.error); } else { OnLoginError(error); } }); }
/// <summary> /// Called on a successful login attempt /// </summary> /// <param name="result">Result object returned from PlayFab server</param> private static void OnLoginResult(PlayFab.ClientModels.LoginResult result) //LoginResult { PF_PlayerData.PlayerId = result.PlayFabId; if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.isEditor) { if (!FB.IsInitialized) { FB.Init(); } if (usedManualFacebook) { LinkDeviceId(); usedManualFacebook = false; } } PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none); if (OnLoginSuccess != null) { OnLoginSuccess(string.Format("SUCCESS: {0}", result.SessionTicket), MessageDisplayStyle.error); } }
public void TogglePushNotification() { if (!PF_PlayerData.isRegisteredForPush) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.Generic); UnityAction afterPush = () => { changedLoginState = true; PF_PlayerData.isRegisteredForPush = true; SetCheckBox(registerPush.GetComponent <Image>(), true); Debug.Log("AccountStatusController: PUSH ENABLED!"); PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.Generic, MessageDisplayStyle.none); }; StartCoroutine(PF_GamePlay.Wait(1.5f, () => { PF_PlayerData.RegisterForPushNotification(pushToken, afterPush); })); } else { Action <bool> processResponse = response => { if (!response) { return; } changedLoginState = true; PF_PlayerData.isRegisteredForPush = false; SetCheckBox(registerPush.GetComponent <Image>(), false); Debug.Log("AccountStatusController: PUSH DISABLED!"); }; DialogCanvasController.RequestConfirmationPrompt(GlobalStrings.PUSH_NOTIFY_PROMPT, GlobalStrings.PUSH_NOTIFY_MSG, processResponse); } }
public static void GetCharacterDataById(string characterId) { var JsonUtil = PluginManager.GetPlugin <ISerializerPlugin>(PluginContract.PlayFab_Serializer); DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetCharacterReadOnlyData); var request = new GetCharacterDataRequest { PlayFabId = PlayerId, CharacterId = characterId, Keys = new List <string> { "CharacterData" } }; PlayFabClientAPI.GetCharacterReadOnlyData(request, result => { if (result.Data.ContainsKey("CharacterData")) { playerCharacterData[result.CharacterId] = JsonUtil.DeserializeObject <UB_CharacterData>(result.Data["CharacterData"].Value); PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetCharacterReadOnlyData, MessageDisplayStyle.none); } }, PF_Bridge.PlayFabErrorCallback); }
public IEnumerator GetAssetPackages(List <AssetBundleHelperObject> assets, UnityAction <bool> callback = null) { var stTime = Time.time; var timeOut = 30.0f; foreach (var asset in assets) { StartCoroutine(DownloadAndUnpackAsset(asset)); } while (AreAssetDownloadsAndUnpacksComplete(assets) == false) { if (Time.time > stTime + timeOut) { PF_Bridge.RaiseCallbackError("CDN Timeout: Could not obtain AssetBundles", PlayFabAPIMethods.GetCDNConent, MessageDisplayStyle.error); if (callback != null) { callback(false); } yield break; } yield return(0); } foreach (var asset in assets) { unpackedAssets.Add(asset.FileName, asset.Unpacked); } if (callback != null) { callback(true); } Debug.Log("--- AllComplete ---"); }
public void AddFriendClicked() { UnityAction <int> afterSelect = (int response) => { Action <string> afterInput = (string input) => { PF_PlayerData.AddFriend(input, (PF_PlayerData.AddFriendMethod)response, (bool result) => { if (result) { Dictionary <string, object> eventData = new Dictionary <string, object>(); // no real data to be sent with this event, just sending an empty dict for now... PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_FriendAdded, eventData); PF_PlayerData.GetFriendsList(() => { UpdateFriendList(); }); } }); }; DialogCanvasController.RequestTextInputPrompt(GlobalStrings.ADD_FRIEND_PROMPT, string.Format(GlobalStrings.ADD_FRIEND_MSG, (PF_PlayerData.AddFriendMethod)response), afterInput); }; DialogCanvasController.RequestSelectorPrompt(GlobalStrings.FRIEND_SELECTOR_PROMPT, Enum.GetNames(typeof(PF_PlayerData.AddFriendMethod)).ToList(), afterSelect); }
public static void GetEncounterLists(List <string> encounters) { var request = new GetTitleDataRequest { Keys = encounters }; DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetTitleData); PlayFabClientAPI.GetTitleData(request, (result) => { //clear encounters for now (until we have reasons to merge dicts); PF_GamePlay.ClearQuestProgress(); Encounters.Clear(); foreach (var item in encounters) { if (result.Data.ContainsKey(item)) { Encounters.Add(item, PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_EncounterData> >(result.Data[item], PlayFab.Internal.PlayFabUtil.ApiSerializerStrategy)); } } PF_Bridge.RaiseCallbackSuccess("Encounters Loaded!", PlayFabAPIMethods.GetTitleData, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
public void ShowRegistration() { Action <AddUsernamePasswordResult> afterRegistration = result => { PF_PlayerData.accountInfo.Username = result.Username; PF_PlayerData.accountInfo.PrivateInfo.Email = "Pending Refresh"; Dictionary <string, object> eventData = new Dictionary <string, object>() { //pull emailf from RC due to it not being returned. { "Username", result.Username }, { "Email", rc.email.text } }; PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_RegisteredAccount, eventData); registerAccount.gameObject.SetActive(false); accountStatus.text = GlobalStrings.ACT_STATUS_REG_MSG; resetPassword.gameObject.SetActive(true); accountStatus.color = Color.green; }; rc.gameObject.SetActive(true); rc.Init(afterRegistration); }
private static void OnGetTitleDataSuccess(GetTitleDataResult result) { Debug.Log("OnGetTitleDataSuccess"); Debug.Log("OnGetTitleDataSuccess -- Classes"); if (result.Data.ContainsKey("Classes")) { Spells = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_SpellDetail> >(result.Data["Spells"]); } Debug.Log("OnGetTitleDataSuccess -- Spells"); if (result.Data.ContainsKey("Spells")) { Classes = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_ClassDetail> >(result.Data["Classes"]); } Debug.Log("OnGetTitleDataSuccess -- StartingCharacterSlots"); if (result.Data.ContainsKey("StartingCharacterSlots")) { StartingCharacterSlots = Int32.Parse(result.Data["StartingCharacterSlots"]); } Debug.Log("OnGetTitleDataSuccess -- MinimumInterstitialWait"); if (result.Data.ContainsKey("MinimumInterstitialWait")) { MinimumInterstitialWait = float.Parse(result.Data["MinimumInterstitialWait"]); } Debug.Log("OnGetTitleDataSuccess -- CharacterLevelRamp"); if (result.Data.ContainsKey("CharacterLevelRamp")) { CharacterLevelRamp = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, int> >(result.Data["CharacterLevelRamp"]); } Debug.Log("OnGetTitleDataSuccess -- Levels"); if (result.Data.ContainsKey("Levels")) { Levels = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_LevelData> >(result.Data["Levels"]); } if (result.Data.ContainsKey("Achievements")) { Achievements = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_Achievement> >(result.Data["Achievements"]); } if (result.Data.ContainsKey("Sales")) { Sales = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_SaleData> >(result.Data["Sales"], PlayFab.Internal.PlayFabUtil.ApiSerializerStrategy); Debug.Log("Sale Data Retrieved"); if (Sales.Count > 0) { DetermineSalesPromotionalTypes(); } } if (result.Data.ContainsKey("Events")) { Events = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_EventData> >(result.Data["Events"], PlayFab.Internal.PlayFabUtil.ApiSerializerStrategy); Debug.Log("Event Data Retrieved"); if (Events.Count > 0) { DetermineEventPromotionalTypes(); } } if (result.Data.ContainsKey("Offers")) { Offers = PlayFab.Json.JsonWrapper.DeserializeObject <Dictionary <string, UB_OfferData> >(result.Data["Offers"], PlayFab.Internal.PlayFabUtil.ApiSerializerStrategy); Debug.Log("Offer Data Retrieved"); } if (result.Data.ContainsKey("CommunityWebsite")) { CommunityWebsite = result.Data["CommunityWebsite"]; Debug.Log("Community Website URL Retrieved"); } if (result.Data.ContainsKey("StandardStores")) { StandardStores = PlayFab.Json.JsonWrapper.DeserializeObject <List <string> >(result.Data["StandardStores"]); Debug.Log("Standard Stores Retrieved"); } Debug.Log("OnGetTitleDataSuccess -- AndroidPushSenderId"); if (result.Data.ContainsKey("AndroidPushSenderId")) { AndroidPushSenderId = result.Data["AndroidPushSenderId"]; } else { AndroidPushSenderId = GlobalStrings.DEFAULT_ANDROID_PUSH_SENDER_ID; } BuildCDNRequests(); PF_Bridge.RaiseCallbackSuccess("Title Data Loaded", PlayFabAPIMethods.GetTitleData, MessageDisplayStyle.none); }
public static void RegisterForPushNotification(string pushToken = null, UnityAction callback = null) { #if UNITY_EDITOR || UNITY_EDITOR_OSX if (callback != null) { callback(); return; } #endif #if UNITY_IPHONE string hexToken = string.Empty; byte[] token = UnityEngine.iOS.NotificationServices.deviceToken; if (token != null) { RegisterForIOSPushNotificationRequest request = new RegisterForIOSPushNotificationRequest(); request.DeviceToken = BitConverter.ToString(token).Replace("-", "").ToLower(); hexToken = request.DeviceToken; Debug.Log(hexToken); DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.RegisterForPush); PlayFabClientAPI.RegisterForIOSPushNotification(request, result => { if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.RegisterForPush, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); } else { Debug.Log("Push Token was null!"); } #endif #if UNITY_ANDROID if (!string.IsNullOrEmpty(pushToken)) { Debug.Log("GCM Init Success"); var request = new AndroidDevicePushNotificationRegistrationRequest { DeviceToken = pushToken }; DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.RegisterForPush); PlayFabClientAPI.AndroidDevicePushNotificationRegistration(request, result => { if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.RegisterForPush, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); } else { Debug.Log("Push Token was null or empty: "); } #endif }
private void OnConsumePurchaseFailed(string error) { Debug.Log("Consume purchase failed: " + error); // _processingPayment = false; PF_Bridge.RaiseCallbackError(error, PlayFabAPIMethods.Generic, MessageDisplayStyle.error); }
private static void OnUpdateCharacterStatisticsSuccess(UpdateCharacterStatisticsResult result) { PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.UpdateCharacterStatistics, MessageDisplayStyle.none); }
public void CompleteEncounter(bool useEvade = false) { // was evasion / flee used? if (useEvade == true) { //TODO evasion check to see if evasion passes CycleNextEncounter(); return; } // Did the player complete this encounter? if (this.currentEncounter.Data.EncounterType == EncounterTypes.Store || this.currentEncounter.Data.EncounterType == EncounterTypes.Hero) { this.currentEncounter.playerCompleted = true; } else if (this.currentEncounter.Data.EncounterType.ToString().Contains(GlobalStrings.ENCOUNTER_CREEP)) { if (this.currentEncounter.Data.Vitals.Health <= 0) { // enemy died this.currentEncounter.playerCompleted = true; if (this.currentEncounter.Data.EncounterType == EncounterTypes.BossCreep) { Dictionary <string, object> eventData = new Dictionary <string, object>() { { "Boss_Name", this.currentEncounter.DisplayName }, { "Current_Quest", PF_GamePlay.ActiveQuest.levelName }, { "Character_ID", PF_PlayerData.activeCharacter.characterDetails.CharacterId } }; PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_BossKill, eventData); } } else if (this.currentPlayer.PlayerVitals.Health <= 0) { // player died this.currentEncounter.playerCompleted = false; } } if (this.currentEncounter.playerCompleted) { LogCompletedEncounterStats(); if (this.currentEncounter.isEndOfAct) { CompleteAct(); return; } //TODO make this work for complex goals // else if(this.gameplayController.AreQuestGoalsComplete()) // { // GameplayController.RaiseGameplayEvent("Quest Complete", PF_GamePlay.GameplayEventTypes.EndQuest); // } CycleNextEncounter(); } else { //trigger game over GameplayController.RaiseGameplayEvent(GlobalStrings.PLAYER_DIED_EVENT, PF_GamePlay.GameplayEventTypes.PlayerDied); Debug.Log("Player Died..."); PF_GamePlay.QuestProgress.Deaths++; Dictionary <string, object> eventData = new Dictionary <string, object>() { { "Killed_By", this.currentEncounter.DisplayName }, { "Enemy_Health", this.currentEncounter.Data.Vitals.Health }, { "Current_Quest", PF_GamePlay.ActiveQuest.levelName }, { "Character_ID", PF_PlayerData.activeCharacter.characterDetails.CharacterId } }; PF_Bridge.LogCustomEvent(PF_Bridge.CustomEventTypes.Client_PlayerDied, eventData); return; } }
private static void OnUpdateUserStatisticsError(PlayFabError error) { PF_Bridge.RaiseCallbackError(error.ErrorMessage, PlayFabAPIMethods.UpdateUserStatistics, MessageDisplayStyle.error); }
private static void OnGetUserAccountInfoSuccess(GetPlayerCombinedInfoResult result) { playerInventory.Clear(); foreach (var eachItem in result.InfoResultPayload.UserInventory) { playerInventory.Add(eachItem); } accountInfo = result.InfoResultPayload.AccountInfo; if (result.InfoResultPayload.UserData.ContainsKey("IsRegisteredForPush")) { isRegisteredForPush = result.InfoResultPayload.UserData["IsRegisteredForPush"].Value == "1"; } else { isRegisteredForPush = false; } if (result.InfoResultPayload.UserData.ContainsKey("ShowAccountOptionsOnLogin") && result.InfoResultPayload.UserData["ShowAccountOptionsOnLogin"].Value == "0") { showAccountOptionsOnLogin = false; } else //if (PF_Authentication.hasLoggedInOnce == false) { //PF_Authentication.hasLoggedInOnce = true; DialogCanvasController.RequestAccountSettings(); } inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { if (inventoryByCategory.ContainsKey(item.ItemId)) { continue; } var catalogItem = PF_GameData.GetCatalogItemById(item.ItemId); if (catalogItem == null) { continue; } var items = new List <ItemInstance>(playerInventory.FindAll((x) => { return(x.ItemId.Equals(item.ItemId)); })); var customIcon = PF_GameData.GetIconByItemById(catalogItem.ItemId); var icon = GameController.Instance.iconManager.GetIconById(customIcon, IconManager.IconTypes.Item); inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalogItem, items, icon)); } } if (PF_Authentication.GetDeviceId(true)) { Debug.Log("Mobile Device ID Found!"); var deviceId = string.IsNullOrEmpty(PF_Authentication.android_id) ? PF_Authentication.ios_id : PF_Authentication.android_id; PlayerPrefs.SetString("LastDeviceIdUsed", deviceId); } else { Debug.Log("Custom Device ID Found!"); if (string.IsNullOrEmpty(PF_Authentication.custom_id)) { PlayerPrefs.SetString("LastDeviceIdUsed", PF_Authentication.custom_id); } } virtualCurrency.Clear(); foreach (var eachPair in result.InfoResultPayload.UserVirtualCurrency) { virtualCurrency.Add(eachPair.Key, eachPair.Value); } PF_Bridge.RaiseCallbackSuccess("Player Account Info Loaded", PlayFabAPIMethods.GetAccountInfo, MessageDisplayStyle.none); }
/// <summary> /// Logins the with device identifier (iOS & Android only). /// </summary> public static void LoginWithDeviceId(bool createAcount, UnityAction errCallback) { Action <bool> processResponse = (bool response) => { if (response && GetDeviceId()) { if (!string.IsNullOrEmpty(android_id)) { Debug.Log("Using Android Device ID: " + android_id); var request = new LoginWithAndroidDeviceIDRequest { AndroidDeviceId = android_id, TitleId = PlayFabSettings.TitleId, CreateAccount = createAcount }; DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin); PlayFabClientAPI.LoginWithAndroidDeviceID(request, OnLoginResult, (PlayFabError error) => { if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound) { errCallback(); PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none); } else { OnLoginError(error); } }); } else if (!string.IsNullOrEmpty(ios_id)) { Debug.Log("Using IOS Device ID: " + ios_id); var request = new LoginWithIOSDeviceIDRequest { DeviceId = ios_id, TitleId = PlayFabSettings.TitleId, CreateAccount = createAcount }; DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin); PlayFabClientAPI.LoginWithIOSDeviceID(request, OnLoginResult, (PlayFabError error) => { if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound) { errCallback(); PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none); } else { OnLoginError(error); } }); } } else { Debug.Log("Using custom device ID: " + custom_id); var request = new LoginWithCustomIDRequest { CustomId = custom_id, TitleId = PlayFabSettings.TitleId, CreateAccount = createAcount }; DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GenericLogin); PlayFabClientAPI.LoginWithCustomID(request, OnLoginResult, error => { if (errCallback != null && error.Error == PlayFabErrorCode.AccountNotFound) { errCallback(); PF_Bridge.RaiseCallbackError("Account not found, please select a login method to continue.", PlayFabAPIMethods.GenericLogin, MessageDisplayStyle.none); } else { OnLoginError(error); } }); } }; processResponse(true); //DialogCanvasController.RequestConfirmationPrompt("Login With Device ID", "Logging in with device ID has some issue. Are you sure you want to contine?", processResponse); }
/// <summary> /// Raises the buy store item success event. /// </summary> /// <param name="result">Result.</param> private static void OnBuyStoreItemSuccess(PurchaseItemResult result) { PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.MakePurchase, MessageDisplayStyle.none); Debug.Log(string.Format("{0} Items Purchased!", result.Items.Count)); GameController.CharacterSelectDataRefresh(); }
private void OnConsumePurchaseSucceeded(Purchase purchase) { Debug.Log("Consume purchase succeded: " + purchase.ToString()); //_processingPayment = false; PF_Bridge.RaiseCallbackSuccess("Consume IAB Purchase Success", PlayFabAPIMethods.Generic, MessageDisplayStyle.none); }
private static void OnGetOffersCatalogSuccess(GetCatalogItemsResult result) { offersCataogItems = result.Catalog; PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GetOffersCatalog, MessageDisplayStyle.none); }
public static void GetUserInventory(Action callback = null) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetUserInventory); PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), (GetUserInventoryResult result) => { virtualCurrency = result.VirtualCurrency; playerInventory = result.Inventory; inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { //if (item.CatalogVersion == "Offers") //{ // OfferContainers.Add(item); // continue; //} if (!inventoryByCategory.ContainsKey(item.ItemId)) { CatalogItem catalog = PF_GameData.catalogItems.Find((x) => { return(x.ItemId.Contains(item.ItemId)); }); List <ItemInstance> items = new List <ItemInstance>(playerInventory.FindAll((x) => { return(x.ItemId.Equals(item.ItemId)); })); try { if (catalog != null) { Dictionary <string, string> customAttributes = new Dictionary <string, string>(); string customIcon = "Defaut"; // here we can process the custom data and apply the propper treatment (eg assign icons) if (catalog.CustomData != null && catalog.CustomData != "null") //TODO update once the bug is fixed on the null value { customAttributes = PlayFabSimpleJson.DeserializeObject <Dictionary <string, string> >(catalog.CustomData); if (customAttributes.ContainsKey("icon")) { customIcon = customAttributes["icon"]; } } Sprite icon = GameController.Instance.iconManager.GetIconById(customIcon); if (catalog.Consumable.UsageCount > 0) { inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalog, items, icon, true, customAttributes)); } else { inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalog, items, icon, customAttributes)); } } } catch (System.Exception e) { Debug.LogWarning(item.ItemId + " -- " + e.Message); continue; } } } //if (OfferContainers.Count > 0) //{ // DialogCanvasController.RequestOfferPrompt(); //} } if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetUserInventory, MessageDisplayStyle.none); }, PF_Bridge.PlayFabErrorCallback); }
public static void OnGetPlayerCharactersSuccess(ListUsersCharactersResult result) { playerCharacters = result.Characters; PF_Bridge.RaiseCallbackSuccess("Player Characters Retrieved", PlayFabAPIMethods.GetAllUsersCharacters, MessageDisplayStyle.none); }
/// <summary> /// Raises the retrieve store items success event. /// </summary> /// <param name="result">Result.</param> private static void OnRetrieveStoreItemsSuccess(GetStoreItemsResult result) { mostRecentStore = result.Store; PF_Bridge.RaiseCallbackSuccess("Store Retrieved", PlayFabAPIMethods.GetStoreItems, MessageDisplayStyle.none); }
public static void GetCharacterData(Action callback = null) { playerCharacterData.Clear(); characterEquipedItem.Clear(); //characterAchievements.Clear(); int remainingCallbacks = playerCharacters.Count; if (remainingCallbacks == 0) { PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetCharacterReadOnlyData, MessageDisplayStyle.none); return; } else { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetCharacterReadOnlyData); } foreach (var character in playerCharacters) { GetCharacterDataRequest request = new GetCharacterDataRequest(); //request.PlayFabId = PlayFabSettings.PlayerId; request.CharacterId = character.CharacterId; request.Keys = new List <string>() { "CharacterData" }; PlayFabClientAPI.GetCharacterReadOnlyData(request, (result) => { // OFFERS //if (result.Data.ContainsKey("Achievements")) //{ // characterAchievements.Add(result.CharacterId, PlayFab.SimpleJson.DeserializeObject<List<string>>(result.Data["Achievements"].Value)); //} if (result.Data.ContainsKey("CharacterData")) { playerCharacterData.Add(result.CharacterId, PlayFabSimpleJson.DeserializeObject <FG_CharacterData>(result.Data["CharacterData"].Value)); #region setup equipment if (playerCharacterData[result.CharacterId].EquipedWeapon != null) { if (!characterEquipedItem.Contains(playerCharacterData[result.CharacterId].EquipedWeapon.EquipmentId)) { characterEquipedItem.Add(playerCharacterData[result.CharacterId].EquipedWeapon.EquipmentId); } } if (playerCharacterData[result.CharacterId].EquipedArmor != null) { if (!characterEquipedItem.Contains(playerCharacterData[result.CharacterId].EquipedArmor.EquipmentId)) { characterEquipedItem.Add(playerCharacterData[result.CharacterId].EquipedArmor.EquipmentId); } } if (playerCharacterData[result.CharacterId].EquipedJewelry != null) { if (!characterEquipedItem.Contains(playerCharacterData[result.CharacterId].EquipedJewelry.EquipmentId)) { characterEquipedItem.Add(playerCharacterData[result.CharacterId].EquipedJewelry.EquipmentId); } } #endregion remainingCallbacks--; if (remainingCallbacks == 0) { if (callback != null) { callback(); } PF_Bridge.RaiseCallbackSuccess("", PlayFabAPIMethods.GetCharacterReadOnlyData, MessageDisplayStyle.none); } } //Debug.Log(result.Data["CharacterData"].Value); }, PF_Bridge.PlayFabErrorCallback); } }
public static void OnGetPlayerAccountInfoSuccess(GetPlayerCombinedInfoResult result) { playerInventory = result.InfoResultPayload.UserInventory; accountInfo = result.InfoResultPayload.AccountInfo; //UserData = result.InfoResultPayload.UserData; if (result.InfoResultPayload.UserData.ContainsKey("IsRegisteredForPush")) { if (result.InfoResultPayload.UserData["IsRegisteredForPush"].Value == "1") { PF_PlayerData.isRegisteredForPush = true; } else { PF_PlayerData.isRegisteredForPush = false; } } else { PF_PlayerData.isRegisteredForPush = false; } if (result.InfoResultPayload.UserData.ContainsKey("ShowAccountOptionsOnLogin") && result.InfoResultPayload.UserData["ShowAccountOptionsOnLogin"].Value == "0") { PF_PlayerData.showAccountOptionsOnLogin = false; } else //if (PF_Authentication.hasLoggedInOnce == false) { //DialogCanvasController.RequestAccountSettings();//modifing } inventoryByCategory.Clear(); if (PF_GameData.catalogItems.Count > 0) { foreach (var item in playerInventory) { //if (item.CatalogVersion == "Offers") //{ // OfferContainers.Add(item); // continue; //} if (!inventoryByCategory.ContainsKey(item.ItemId)) { CatalogItem catalog = PF_GameData.catalogItems.Find((x) => { return(x.ItemId.Contains(item.ItemId)); }); List <ItemInstance> items = new List <ItemInstance>(playerInventory.FindAll((x) => { return(x.ItemId.Equals(item.ItemId)); })); try { if (catalog != null) { string customIcon = "Defaut"; Dictionary <string, string> customAttributes = new Dictionary <string, string>(); // here we can process the custom data and apply the propper treatment (eg assign icons) if (catalog.CustomData != null && catalog.CustomData != "null") //TODO update once the bug is fixed on the null value { //Dictionary<string, string> customAttributes = PlayFabSimpleJson.DeserializeObject<Dictionary<string, string>>(catalog.CustomData); customAttributes = PlayFabSimpleJson.DeserializeObject <Dictionary <string, string> >(catalog.CustomData); if (customAttributes.ContainsKey("icon")) { customIcon = customAttributes["icon"]; } } Sprite icon = GameController.Instance.iconManager.GetIconById(customIcon); if (catalog.Consumable.UsageCount > 0) { inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalog, items, icon, true, customAttributes)); } else { inventoryByCategory.Add(item.ItemId, new InventoryCategory(item.ItemId, catalog, items, icon, customAttributes)); } } } catch (System.Exception e) { Debug.LogWarning(item.ItemId + " -- " + e.Message); continue; } } } } if (PF_Authentication.GetDeviceId(true)) { //Debug.Log("Mobile Device ID Found!"); string deviceID = string.IsNullOrEmpty(PF_Authentication.android_id) ? PF_Authentication.ios_id : PF_Authentication.android_id; PlayerPrefs.SetString("LastDeviceIdUsed", deviceID); } else { //Debug.Log("Custom Device ID Found!"); if (string.IsNullOrEmpty(PF_Authentication.custom_id)) { PlayerPrefs.SetString("LastDeviceIdUsed", PF_Authentication.custom_id); } } virtualCurrency = result.InfoResultPayload.UserVirtualCurrency; if (result.InfoResultPayload.UserData.ContainsKey("Teams")) { PF_PlayerData.MyTeamsCharacterId = PlayFabSimpleJson.DeserializeObject <Dictionary <string, List <string> > >(result.InfoResultPayload.UserData["Teams"].Value); } PF_Bridge.RaiseCallbackSuccess("Player Account Info Loaded", PlayFabAPIMethods.GetAccountInfo, MessageDisplayStyle.none); }
private static void OnLinkSuccess(LinkFacebookAccountResult result) { Debug.Log("Facebook Linked Account!"); PlayerPrefs.SetInt("LinkedFacebook", 1); PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.LinkFacebookId, MessageDisplayStyle.none); }
private static void OnUpdateUserStatisticsSuccess(UpdatePlayerStatisticsResult result) { PF_Bridge.RaiseCallbackSuccess("User Statistics Loaded", PlayFabAPIMethods.UpdateUserStatistics, MessageDisplayStyle.none); GetCharacterStatistics(); // Refresh stats that we just updated }
public static void BuildCDNRequests() { List <AssetBundleHelperObject> requests = new List <AssetBundleHelperObject>(); string mime = "application/x-gzip"; string keyPrefix = string.Empty; if (Application.platform == RuntimePlatform.Android) { keyPrefix = "Android/"; } else if (Application.platform == RuntimePlatform.IPhonePlayer) { keyPrefix = "iOS/"; } foreach (var sale in Sales) { if (sale.Value.PromoType == PromotionType.Promoted) { requests.Add(new AssetBundleHelperObject() { MimeType = mime, ContentKey = keyPrefix + sale.Value.BundleId, FileName = sale.Key, Unpacked = new UB_UnpackedAssetBundle(), }); } } foreach (var ev in Events) { if (ev.Value.PromoType == PromotionType.Promoted && !string.IsNullOrEmpty(ev.Value.BundleId)) { requests.Add(new AssetBundleHelperObject() { MimeType = mime, ContentKey = keyPrefix + ev.Value.BundleId, FileName = ev.Key, Unpacked = new UB_UnpackedAssetBundle() }); } } GameController.Instance.cdnController.assets = requests; UnityAction <bool> afterCDNRequest = (bool response) => { if (response == true) { PF_Bridge.RaiseCallbackSuccess(string.Empty, PlayFabAPIMethods.GetCDNConent, MessageDisplayStyle.none); Debug.Log("CDN Retrieved!"); } PF_GameData.PromoAssets.Clear(); foreach (var obj in requests) { if (obj.IsUnpacked == true) { PF_GameData.PromoAssets.Add(obj.Unpacked); } } GameController.Instance.cdnController.isInitalContentUnpacked = true; }; if (GameController.Instance.cdnController.isInitalContentUnpacked == false && GameController.Instance.cdnController.useCDN == true) { DialogCanvasController.RequestLoadingPrompt(PlayFabAPIMethods.GetCDNConent); GameController.Instance.cdnController.KickOffCDNGet(requests, afterCDNRequest); } }
public void TransferVC() { // specify Currency Code // enter currency amount // select recipient string cCode = ""; int amount = 0; //if player, show picker for valid characters //if character, show picker for valid characters + Player List <string> transOptions = new List <string>(); UnityAction <int> afterSelect = (int response) => { if (this.activeMode == InventoryMode.Character && response == 0) // stand alone { // send this to the player account Debug.Log("Moved " + amount + cCode + " to Player"); PF_PlayerData.TransferVcToPlayer(PF_PlayerData.activeCharacter.characterDetails.CharacterId, cCode, amount, RefreshInventory); } else { string sourceType = "Player"; if (this.activeMode == InventoryMode.Character) // stand alone { // remove the player option since 0 was not selected transOptions.RemoveAt(0); response--; sourceType = "Character"; } Debug.Log("Moved " + amount + cCode + " to Character: " + transOptions[response] + " -- " + PF_PlayerData.playerCharacters[response].CharacterId); PF_PlayerData.TransferVCToCharacter(PF_PlayerData.activeCharacter.characterDetails.CharacterId, sourceType, cCode, amount, PF_PlayerData.playerCharacters[response].CharacterId, RefreshInventory); } }; Action <string> afterSetAmount = (string response) => { if (string.IsNullOrEmpty(response)) { return; //user canceled. } if (!Int32.TryParse(response, out amount) || response == "0") { PF_Bridge.RaiseCallbackError("Please enter an interger > 0 for VC amount", PlayFabAPIMethods.Generic, MessageDisplayStyle.error); } else { if (this.activeMode == InventoryMode.Character) { transOptions.Add("Player"); } foreach (var c in PF_PlayerData.playerCharacters) { if (this.activeMode == InventoryMode.Character && c.CharacterId == PF_PlayerData.activeCharacter.characterDetails.CharacterId) { //Probably better logic for this, and I should feel sad (but i dont). } else { transOptions.Add(c.CharacterName); } } DialogCanvasController.RequestSelectorPrompt("Choose a recipient", transOptions, afterSelect); } }; UnityAction <int> afterSelectCC = (int response) => { cCode = this.currenciesInUse[response]; DialogCanvasController.RequestTextInputPrompt("Set an amount to transfer:", "Enter the amount that you wish to send.", afterSetAmount, "0"); }; DialogCanvasController.RequestSelectorPrompt("Select a VC:", this.currenciesInUse, afterSelectCC); }