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); } }); }
private void parseItemModel <T>(ref T itemModelRef, ref ItemIDLevelPair itemIDLevelPair) where T : ItemModel { if (itemIDLevelPair.ItemModelID == PlayerModel.EMPTY_EQUIPMENT_ID) { return; } itemModelRef = (catalogModel.GetItemByID(itemIDLevelPair.ItemModelID).Clone() as T); itemModelRef.Level_ZeroBased = itemIDLevelPair.ItemLevel_ZeroBased; }
private void updateEquipmentAbilityReferences(CatalogModel catalogModel) { for (int i = 0; i < catalogModel.AllItems.Count; i++) { EquipmentItemModel equipmentItemModel = catalogModel.AllItems[i] as EquipmentItemModel; if (equipmentItemModel != null) { if (equipmentItemModel.AbilityIDs != null) { equipmentItemModel.AbilityItemModels = new AbilityItemModel[equipmentItemModel.AbilityIDs.Length]; for (int a = 0; a < equipmentItemModel.AbilityIDs.Length; a++) { equipmentItemModel.AbilityItemModels[a] = catalogModel.GetItemByID(equipmentItemModel.AbilityIDs[a]) as AbilityItemModel; } } } } }
private PlayerInventoryModel buildPlayerInventory(List <RawPlayerItem> rawPlayerItems, RawCurrencySet currencySet) { CatalogModel catalogModel = DIContainer.GetInstanceByContextID <CatalogModel>(GameContext.ID); PlayerInventoryModel playerInventory = new PlayerInventoryModel(); for (int i = 0; i < rawPlayerItems.Count; i++) { RawPlayerItem rawItem = rawPlayerItems[i]; ItemModel playerOwnedItemModel = catalogModel.GetItemByID(rawItem.ID).Clone(); playerOwnedItemModel.InstanceID = rawItem.InstanceID; playerOwnedItemModel.StackedCount = rawItem.StackedCount; playerOwnedItemModel.Level_ZeroBased = rawItem.Level_ZeroBased; playerInventory.AddItemWithStackCount(playerOwnedItemModel); } playerInventory.GoldCurrency = currencySet.Gold; playerInventory.ExperienceCurrency = currencySet.Experience; return(playerInventory); }