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);
                }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Retrieves the random drop table configuration for the title
        /// </summary>
        public static void GetRandomResultTables(GetRandomResultTablesRequest request, Action <GetRandomResultTablesResult> resultCallback, Action <PlayFabError> errorCallback, object customData = null)
        {
            if (PlayFabSettings.DeveloperSecretKey == null)
            {
                throw new Exception("Must have PlayFabSettings.DeveloperSecretKey set to call this method");
            }

            PlayFabHttp.MakeApiCall("/Admin/GetRandomResultTables", request, AuthType.DevSecretKey, resultCallback, errorCallback, customData);
        }
    public void ReadDropTableData(string dropTableId)
    {
        var getRandomResultTables = new GetRandomResultTablesRequest()
        {
            TableIDs = new List <string> {
                dropTableId
            }
        };

        PlayFabServerAPI.GetRandomResultTables(getRandomResultTables,
                                               delegate(GetRandomResultTablesResult getRandomResultTablesResult)
        {
            foreach (var result in getRandomResultTablesResult.Tables.ToList())
            {
                Debug.Log("Drop table id: " + result.Key);

                foreach (var node in result.Value.Nodes)
                {
                    Debug.Log("Id: " + node.ResultItem + ", Weight: " + node.Weight);
                }
            }
        },
                                               SharedError.OnSharedError);
    }