protected override void getDropTables(CatalogModel catalogModel, Action <DropTableCollection> onSuccessHandler, Action onFailureHandler)
        {
            GetRandomResultTablesRequest request = new GetRandomResultTablesRequest()
            {
                CatalogVersion = catalogModel.ID
            };

            PlayFabAdminAPI.GetRandomResultTablesAsync(request).ContinueWith(t => {
                if (t.Result.Error != null)
                {
                    Log.Error("PlayFabDropTableService drop tables error: " + t.Result.Error.ErrorMessage);
                    onFailureHandler();
                }
                else
                {
                    DropTableCollection dropTableCollection = new DropTableCollection();
                    foreach (var kvp in t.Result.Result.Tables)
                    {
                        int id = int.Parse(kvp.Value.TableId);
                        DropTableModel dropTableModel = new DropTableModel(id);
                        dropTableCollection.Add(id, dropTableModel);
                        for (int i = 0; i < kvp.Value.Nodes.Count; i++)
                        {
                            int itemID          = int.Parse(kvp.Value.Nodes[i].ResultItem);
                            float weight        = kvp.Value.Nodes[i].Weight;
                            ItemModel itemModel = catalogModel.GetItemByID(itemID);
                            dropTableModel.AddItem(itemModel, weight);
                        }
                    }
                    onSuccessHandler(dropTableCollection);
                }
            });
        }
Exemple #2
0
        public static void GetDropTableData(string titleId, Action <bool, Dictionary <string, PlayFab.AdminModels.RandomResultTableListing> > callback)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var task = PlayFabAdminAPI.GetRandomResultTablesAsync(new PlayFab.AdminModels.GetRandomResultTablesRequest())
                       .ContinueWith(
                (result) =>
            {
                PlayFabSettings.TitleId            = currentPlayFabTitleId;
                PlayFabSettings.DeveloperSecretKey = currentDevKey;
                Task <PlayFabResult <PlayFab.AdminModels.GetRandomResultTablesResult> > taskC = result as Task <PlayFabResult <PlayFab.AdminModels.GetRandomResultTablesResult> >;
                if (taskC.Result.Error != null)
                {
                    Console.WriteLine(PlayFabUtil.GetErrorReport(taskC.Result.Error));
                    callback(false, null);
                    return;
                }
                if (result.IsCompleted)
                {
                    callback(true, taskC.Result.Result.Tables);
                }
            });
        }
Exemple #3
0
        async public static Task <Dictionary <string, PlayFab.AdminModels.RandomResultTableListing> > GetDropTableData(string titleId)
        {
            var currentPlayFabTitleId = PlayFabSettings.TitleId;
            var currentDevKey         = PlayFabSettings.DeveloperSecretKey;

            var title = FindTitle(titleId);

            PlayFabSettings.TitleId            = titleId;
            PlayFabSettings.DeveloperSecretKey = title.SecretKey;

            var result = await PlayFabAdminAPI.GetRandomResultTablesAsync(new PlayFab.AdminModels.GetRandomResultTablesRequest());

            PlayFabSettings.TitleId            = currentPlayFabTitleId;
            PlayFabSettings.DeveloperSecretKey = currentDevKey;
            if (result.Error != null)
            {
                Console.WriteLine(PlayFabUtil.GetErrorReport(result.Error));
                return(null);
            }

            return(result.Result.Tables);
        }