コード例 #1
0
    /// <summary>
    /// Successfunction that is called after the combinedInfoRequest was successfull
    /// </summary>
    /// <param name="result"></param>
    public void CombinedInfoSuccess(GetPlayerCombinedInfoResult result)
    {
        CurrentPlayer        = result.InfoResultPayload.PlayerProfile;
        CurrentPlayerAccount = result.InfoResultPayload.AccountInfo;

        if (result.InfoResultPayload.UserVirtualCurrency.TryGetValue("CR", out int balance))
        {
            GameInstance.instance.credits = balance;
            Credits = balance.ToString();
        }
        else
        {
            GameInstance.instance.credits = 0;
            Credits = "0";
        }

        var statisticList = new List <StatisticModel>();

        foreach (var statisticValue in result.InfoResultPayload.PlayerStatistics)
        {
            var model = new StatisticModel
            {
                Value = statisticValue.Value,
                Name  = statisticValue.StatisticName
            };
            statisticList.Add(model);
        }

        CurrentPlayer.Statistics = statisticList;

        fullyLoaded = true;
    }
コード例 #2
0
ファイル: ValueUtil.cs プロジェクト: zimpzon/haps
    internal static GetPlayerCombinedInfoResult GetTestCombinedInfo()
    {
        GetPlayerCombinedInfoResult result = new GetPlayerCombinedInfoResult();

        result.PlayFabId         = "xxxx";
        result.InfoResultPayload = new GetPlayerCombinedInfoResultPayload();
        var pl = result.InfoResultPayload;

        pl.AccountInfo          = new UserAccountInfo();
        pl.CharacterInventories = new List <CharacterInventory>();
        pl.PlayerProfile        = new PlayerProfileModel();
        pl.PlayerStatistics     = new List <StatisticValue>();

        pl.TitleData = new Dictionary <string, string>();
        pl.TitleData.Add("donees", OfflineJson.jsonDonees);
        pl.TitleData.Add("titles", OfflineJson.jsonTitles);
        pl.TitleData.Add("gameplayFlags", OfflineJson.jsonGameplayFlags);
        pl.TitleData.Add("externalDistribution", OfflineJson.jsonExternalDistribution);

        pl.UserData         = new Dictionary <string, UserDataRecord>();
        pl.UserInventory    = new List <ItemInstance>();
        pl.UserReadOnlyData = new Dictionary <string, UserDataRecord>();
        pl.UserReadOnlyData.Add("xp", new UserDataRecord()
        {
            Value = "0"
        });

        pl.UserVirtualCurrency = new Dictionary <string, int>();
        pl.UserVirtualCurrency.Add("CR", 1000);
        pl.UserVirtualCurrency.Add("TI", 100);
        pl.UserVirtualCurrencyRechargeTimes = new Dictionary <string, VirtualCurrencyRechargeTime>();
        return(result);
    }
コード例 #3
0
 void Respond(GetPlayerCombinedInfoResult result, PlayFabError error)
 {
     if (OnResponse != null)
     {
         OnResponse(result, error);
     }
 }
コード例 #4
0
        void RetrieveCallbac(GetPlayerCombinedInfoResult result)
        {
            if (OnRetrieved != null)
            {
                OnRetrieved(result);
            }

            Respond(result, null);
        }
コード例 #5
0
    private void OnInfoRequestSuccess(GetPlayerCombinedInfoResult result)
    {
        Text userName = LoggedInDialog.GetComponent <Text>();

        if (result.InfoResultPayload.AccountInfo.TitleInfo.DisplayName == "")
        {
            userName.text = "Guest";
        }
        else
        {
            userName.text = result.InfoResultPayload.AccountInfo.TitleInfo.DisplayName;
        }
    }
コード例 #6
0
    private void OnGetUserAccountInfoSuccess(GetPlayerCombinedInfoResult result)
    {
        accountInfo = result.InfoResultPayload.AccountInfo;

        Debug.Log("Username: " + accountInfo.TitleInfo.DisplayName);
        if (accountInfo.TitleInfo.DisplayName != string.Empty && accountInfo.TitleInfo.DisplayName != null)
        {
            Loading.SetActive(false);
            Splash.SetActive(true);
        }
        else
        {
            Loading.SetActive(false);
            UpdateDisplayName.SetActive(true);
        }
    }
コード例 #7
0
    public IEnumerator InitializePlayFab()
    {
        if (PlayFabClientAPI.IsClientLoggedIn())
        {
            LoginProcessComplete = true;
            yield break; // Already logged in
        }

        Debug.Log("PlayFab: Login...");
        yield return(DoLoginCo());

        if (!PlayFabClientAPI.IsClientLoggedIn())
        {
            LoginProcessComplete = true;
            yield break;
        }

        Debug.Log("PlayFab: Get all stats...");
        yield return(GetAllStats());

        AllStats = (GetPlayerStatisticsResult)LastResult;

        Debug.Log("PlayFab: Get all data...");
        yield return(GetAllPlayerData());

        AllData = (GetPlayerCombinedInfoResult)LastResult;

        if (Application.platform == RuntimePlatform.WebGLPlayer)
        {
            Debug.Log("PlayFab: Sending WebGL url info...");
            yield return(LogPlayerData(
                             new Dictionary <string, string> {
                { "hosting_url", Application.absoluteURL },
                { "page_top_url", GetURLFromPage() }
            }));
        }

        LoginProcessComplete = true;
    }
コード例 #8
0
 private void PlayfabEvents_OnGetPlayerCombinedInfoResultEvent(GetPlayerCombinedInfoResult result)
 {
     this.UpdateCharacters(result.InfoResultPayload?.CharacterList);
 }
コード例 #9
0
 private void PlayfabEvents_OnGetPlayerCombinedInfoResultEvent(GetPlayerCombinedInfoResult result)
 {
     this.UpdateInventory(result.InfoResultPayload?.UserInventory);
 }
コード例 #10
0
    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);
    }
コード例 #11
0
    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);
    }
コード例 #12
0
        private void PlayfabEvents_OnGetPlayerCombinedInfoResultEvent(GetPlayerCombinedInfoResult result)
        {
            var payload = result.InfoResultPayload;

            this.UpdateVirtualCurrencies(payload?.UserVirtualCurrency, payload?.UserVirtualCurrencyRechargeTimes);
        }
コード例 #13
0
 private void GetPlayerCombinedInfoRequestSuccess(GetPlayerCombinedInfoResult obj)
 {
 }
コード例 #14
0
 static void OnGotAccountInfo(GetPlayerCombinedInfoResult _result)
 {
     Debug.Log("Updated account info...");
     Instance.Info = _result.InfoResultPayload;
 }