Exemple #1
0
        // NOTE: If there is an existing catalog with the version number in question, it will be deleted and replaced with only the items specified in this call.
        async public static Task <bool> UpdateCatalogData(string titleId, string catalogVersion, bool isDefault, List <PlayFab.AdminModels.CatalogItem> catalog)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            var result = await PlayFabAdminAPI.SetCatalogItemsAsync(new PlayFab.AdminModels.UpdateCatalogItemsRequest()
            {
                Catalog             = catalog,
                CatalogVersion      = catalogVersion,
                SetAsDefaultCatalog = isDefault
            });

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(false);
            }
            return(true);
        }
Exemple #2
0
        public async Task SetCatalogItems(List <FutbolPlayer> players)
        {
            var items = new List <CatalogItem> {
            };

            foreach (var player in players)
            {
                items.Add(new CatalogItem
                {
                    ItemId                = player.ID,
                    DisplayName           = $"{player.Name} {player.LastName}",
                    VirtualCurrencyPrices = new Dictionary <string, uint>()
                    {
                        { configuration.Currency, player.Price }
                    },
                    CustomData = JsonConvert.SerializeObject(player)
                });
            }

            var reqUpdateCatalogItems = new UpdateCatalogItemsRequest
            {
                CatalogVersion = configuration.CatalogName,
                Catalog        = items
            };

            var result = await PlayFabAdminAPI.SetCatalogItemsAsync(reqUpdateCatalogItems);

            if (result.Error != null)
            {
                Console.WriteLine(result.Error.ErrorMessage);
            }
        }
Exemple #3
0
        public static void UpdateCatalogData(string titleId, string catalogVersion, bool isDefault, List <PlayFab.AdminModels.CatalogItem> catalog, Action <bool> callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;
            var task = PlayFabAdminAPI.SetCatalogItemsAsync(new PlayFab.AdminModels.UpdateCatalogItemsRequest()
            {
                Catalog             = catalog,
                CatalogVersion      = catalogVersion,
                SetAsDefaultCatalog = isDefault
            })
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                if (result.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(result.Result.Error));
                    callback(false);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true);
                }
            });
        }