void InventoryResult(GetUserInventoryResult result) { Debug.Log("Inventory result count is " + result.Inventory.Count); this.result = result; GetComponent <PlayerInventory>().SetInventoryPlayFab(result); }
private void GetInventoryCallback(GetUserInventoryResult result) { Debug.Log($"Inventory retrieved. You have {result.Inventory.Count} items."); int stBalance; result.VirtualCurrency.TryGetValue("ST", out stBalance); string nextTicketDisplay = "Capped"; if (result.VirtualCurrencyRechargeTimes.TryGetValue("ST", out var rechargeDetails)) { if (stBalance < rechargeDetails.RechargeMax) { var nextTicketTime = new DateTime(); nextTicketTime = DateTime.Now.AddSeconds(rechargeDetails.SecondsToRecharge); Debug.Log($"You have {stBalance} Spin Tickets."); Debug.Log($"Your next free ticket will arrive at {nextTicketTime}"); nextTicketDisplay = nextTicketTime.ToString(); } else { Debug.Log($"Tickets only go up to a maximum of {rechargeDetails.RechargeMax}, and you currently have {stBalance}"); } } SetUI(stBalance, result.Inventory.Count, nextTicketDisplay); UnlockUI(); }
void FreeLifeTimeCallback(GetUserInventoryResult result) { VirtualCurrencyRechargeTime rechargeDetails; int livesBalance; result.VirtualCurrency.TryGetValue(LIVES_CODE, out livesBalance); if (result.VirtualCurrencyRechargeTimes.TryGetValue(LIVES_CODE, out rechargeDetails)) { string timeText = string.Empty; if (livesBalance < rechargeDetails.RechargeMax) { nextFreeLife = DateTime.Now.AddSeconds(rechargeDetails.SecondsToRecharge); string minutes = Mathf.Floor(rechargeDetails.SecondsToRecharge / 60).ToString("00"); string seconds = (rechargeDetails.SecondsToRecharge % 60).ToString("00"); timeText = string.Format("{0}:{1}", minutes, seconds); OnReceivedRechargeTime(timeText); livesCapped = false; } else { timeText = "You are at the max amount."; OnReceivedRechargeTime(string.Empty); livesCapped = true; } } }
private void OnGetUserInventory(GetUserInventoryResult result) { InventoryConsumed = Inventory = result.Inventory; VirtualCurrency = result.VirtualCurrency; PlayFabGameBridge.consumableItems = new Dictionary <string, int?>(); PlayFabGameBridge.consumableItemsConsumed = new Dictionary <string, int?>(); for (int i = 0; i < Inventory.Count; i++) { if (Inventory [i].RemainingUses != null) { Debug.Log("Adding " + Inventory[i].RemainingUses + " of class " + Inventory[i].ItemClass); if (PlayFabGameBridge.consumableItems.ContainsKey(Inventory[i].ItemClass)) { PlayFabGameBridge.consumableItems[Inventory[i].ItemClass] += Inventory[i].RemainingUses; } else { PlayFabGameBridge.consumableItems.Add(Inventory[i].ItemClass, Inventory[i].RemainingUses); PlayFabGameBridge.consumableItemsConsumed.Add(Inventory[i].ItemClass, 0); } } } InventoryLoaded = true; }
//玩家仓库数据获取成功时调用 void OnGetUserInventory(GetUserInventoryResult result) { Debug.Log("User Inventory Loaded"); //显示玩家的金币、钻石数量 goldCurrencyCount.text = "金币 : " + result.VirtualCurrency ["JB"].ToString(); //检测玩家是否拥有装备道具 bool hasEquipedWeapon = false; foreach (ItemInstance i in result.Inventory) { if (i.ItemId == PlayFabUserData.equipedWeapon) { hasEquipedWeapon = true; break; } } //如果玩家未拥有装备的道具(超出使用期限) if (!hasEquipedWeapon) { PlayFabUserData.equipedWeapon = "NornalCannon"; //更新玩家属性Player Data“EquipedWeapon” UpdateUserDataRequest request = new UpdateUserDataRequest(); request.Data = new Dictionary <string, string>(); request.Data.Add("EquipedWeapon", PlayFabUserData.equipedWeapon); PlayFabClientAPI.UpdateUserData(request, OnUpdateUserData, OnPlayFabError); } else { OnMessageResponse(); Debug.Log("User Data Saved"); } OnMessageResponse(); //PlayFab的数据是否接收完毕 }
private void SetCurrencyAccount(GetUserInventoryResult result) { dataManager.SetRuneFragment(result.VirtualCurrency["RF"]); dataManager.SetIRLMonney(result.VirtualCurrency["MI"]); Debug.Log(dataManager.GetRuneFragment()); Debug.Log(dataManager.GetIRLMonney()); }
public void OnUpdateUserInventory(GetUserInventoryResult result) { inventory = result.Inventory; if (inventory.Count == 0) { Debug.Log("GrantItemAtInventory"); GrantItems(); } for (int i = 0; i < inventory.Count; i++) { ItemInstance itemInstance = inventory[i]; if (itemInstance.ItemClass == "Skin" && !PlayFabGameBridge.Instance.boughtSkins.ContainsKey(itemInstance.ItemId)) { PlayFabGameBridge.Instance.boughtSkins.Add(itemInstance.ItemId, itemInstance); } else if (itemInstance.ItemClass == "Missile" && !PlayFabGameBridge.Instance.boughtMissiles.ContainsKey(itemInstance.ItemId)) { PlayFabGameBridge.Instance.boughtMissiles.Add(itemInstance.ItemId, itemInstance); } } if (inventory.Count == (PlayFabGameBridge.Instance.boughtSkins.Count + PlayFabGameBridge.Instance.boughtMissiles.Count)) { InventoryLoaded = true; PurchaseDone(); } if (InventoryLoaded) { InitializationEventManager.OnNextInitialization(); } }
/// <summary> /// 仮想通貨の情報の取得に成功 /// </summary> /// <param name="result">実行結果</param> private void OnSuccessGet(GetUserInventoryResult result) { //result.Inventoryがインベントリの情報 Debug.Log($"仮想通貨の情報の取得に成功"); // 通信終了 waitConnect.RemoveWait(gameObject.name); foreach (var virtualCurrency in result.VirtualCurrency) { //所持している仮想通貨の情報をログで表示 Debug.Log($"仮想通貨 {virtualCurrency.Key} : {virtualCurrency.Value}"); // 仮想通貨をクラス内に格納する if (!m_DicVirtualCurrency.ContainsKey(virtualCurrency.Key)) { m_DicVirtualCurrency.Add(virtualCurrency.Key, virtualCurrency.Value); } else { m_DicVirtualCurrency[virtualCurrency.Key] = virtualCurrency.Value; } } isGet = true; }
void GetInventoryCallback(GetUserInventoryResult result) { Debug.Log(string.Format("Inventory retrieved. You have {0} items.", result.Inventory.Count)); int stBalance; result.VirtualCurrency.TryGetValue("ST", out stBalance); VirtualCurrencyRechargeTime rechargeDetails; string freeTicketDisplay = string.Format("Capped"); if (result.VirtualCurrencyRechargeTimes.TryGetValue("ST", out rechargeDetails)) { if (stBalance < rechargeDetails.RechargeMax) { DateTime nextFreeTicket = new DateTime(); nextFreeTicket = DateTime.Now.AddSeconds(rechargeDetails.SecondsToRecharge); Debug.Log(string.Format("You have {0} Spin Tickets.", stBalance)); Debug.Log(string.Format("Your next free ticket will arrive at: {0}", nextFreeTicket)); freeTicketDisplay = string.Format("{0}", nextFreeTicket); } else { Debug.Log(string.Format("Tickets only regenerate to a maximum of {0}, and you currently have {1}.", rechargeDetails.RechargeMax, stBalance)); } } SetUI(stBalance, result.Inventory.Count, freeTicketDisplay); UnlockUI(); }
// If a valid response is returned, parse the inventory information. private void OnGetUserInventory(GetUserInventoryResult result) { Debug.Log("Getting user inventory..."); // Store the list of ItemInstances. In other words, your inventory. Debug.Log("Retrieved " + result.Inventory.Count + " items from PlayFab."); InventoryConsumed = Inventory = result.Inventory; Debug.Log("Stored " + Inventory.Count + " items from PlayFab."); // Store the virutal currency. VirtualCurrency = result.VirtualCurrency; // For storage of consumable items information in PlayFabGameBridge class. PlayFabGameBridge.consumableItems = new Dictionary <string, int?>(); // For storage of consumption of items in PlayFabGameBridge class. PlayFabGameBridge.consumableItemsConsumed = new Dictionary <string, int?>(); // Go through inventory and populate. for (int i = 0; i < Inventory.Count; i++) { // Consumable items population and storage in PlayFabGameBridge container if (Inventory[i].RemainingUses != null) { Debug.Log("Adding " + Inventory[i].RemainingUses + " of class " + Inventory[i].ItemClass); if (PlayFabGameBridge.consumableItems.ContainsKey(Inventory[i].ItemClass)) { PlayFabGameBridge.consumableItems[Inventory[i].ItemClass] += Inventory[i].RemainingUses; } else { PlayFabGameBridge.consumableItems.Add(Inventory[i].ItemClass, Inventory[i].RemainingUses); PlayFabGameBridge.consumableItemsConsumed.Add(Inventory[i].ItemClass, 0); } } } UpdateInventoryMenu(); InventoryLoaded = true; }
private void LoadLoot(GetUserInventoryResult result) { //urodziny CardsPacks.Clear (); AllItems = result.Inventory; foreach (ItemInstance item in result.Inventory) { Debug.Log("New inventory item:" + item.DisplayName + " class:" + item.ItemClass + " uses:" + item.RemainingUses); if (item.ItemClass != null) { if (item.ItemClass.Equals("CardsPack")) { CardsPacks.Add(item); //item.Annotation = item.RemainingUses.GetValueOrDefault (1).ToString(); ShowNewRewardsNotify(true, item.RemainingUses.GetValueOrDefault(1).ToString()); if (LootMenuObject != null) { LootMenuObject.GetComponent <LootMenu> ().SetMainMenuComponent(this.GetComponent <MainMenu> ()); } } else { DeckBaseComponent.CardsBaseComponent.LoadUserCard(item); } } } }
private void parseItems(GetUserInventoryResult result, Action <List <RawPlayerItem>, RawCurrencySet> successHandler) { List <RawPlayerItem> rawPlayerItems = new List <RawPlayerItem>(); for (int i = 0; i < result.Inventory.Count; i++) { ItemInstance itemInstance = result.Inventory[i]; RawPlayerItem rawPlayerItem = new RawPlayerItem(); rawPlayerItem.ID = int.Parse(itemInstance.ItemId); rawPlayerItem.InstanceID = itemInstance.ItemInstanceId; rawPlayerItem.StackedCount = itemInstance.RemainingUses == null ? 1 : (int)itemInstance.RemainingUses; string levelZeroBased = null; if (itemInstance.CustomData != null) { itemInstance.CustomData.TryGetValue(LEVEL_ZERO_BASED_PROP, out levelZeroBased); } rawPlayerItem.Level_ZeroBased = string.IsNullOrEmpty(levelZeroBased) ? 0 : int.Parse(levelZeroBased); rawPlayerItem.CustomData = itemInstance.CustomData; rawPlayerItems.Add(rawPlayerItem); } RawCurrencySet currencySet = new RawCurrencySet(); result.VirtualCurrency.TryGetValue(CurrencySymbol.GC.ToString(), out currencySet.Gold); result.VirtualCurrency.TryGetValue(CurrencySymbol.XP.ToString(), out currencySet.Experience); successHandler(rawPlayerItems, currencySet); }
public void SetInventoryPlayFab(GetUserInventoryResult result) { int pistolCount = 0; int shotgunCount = 0; foreach (ItemInstance item in result.Inventory) { if (item.ItemId == WeaponIds.pistolID) { for (int i = 0; i < item.RemainingUses; i++) { pistolCount++; objectsInSpawnOrder.Add(weapons.Pistol); } } if (item.ItemId == WeaponIds.shotgunID) { for (int i = 0; i < item.RemainingUses; i++) { shotgunCount++; objectsInSpawnOrder.Add(weapons.Shotgun); } } } weapons.shotgunCount = shotgunCount; weapons.pistolCount = pistolCount; GetComponentInChildren <InventorySpawner>().InstantiateCells(); }
private void OnGetInventorySuccess(GetUserInventoryResult result) { //Debug //Debug.Log("PlayFab - GetInventorySuccess"); DebugText.text += "\nPlayFab - GetInventorySuccess"; //Set Virtual currecy & Items owned CharacterReferences.instance.playerInfo.SetCurrency(result.VirtualCurrency["CO"], result.VirtualCurrency["GE"]); CharacterReferences.instance.charactersInfo.CheckCharacters(result.Inventory); EnvironmentController ec = EnvironmentController.instance; ec.setsList = new List <EnvironmentSet>(); EnvironmentPrefabController temp = ec.prefabsInstantiated[0]; ec.prefabsInstantiated = new List <EnvironmentPrefabController>(); Destroy(temp.gameObject); ec.GetEnvironments(); ec.SetEnvironment(); ParallaxMainController.instance.SetParallaxNewElements(); //Debug.Log("PlayFabLogin GET INVENTORY"); MMA.UpdateTexts(true); MMA.ToogleShopWindow(); ShopController.instance.InstantiateNewCharacter(); MMA.ToogleShopWindow(); isPlayFabLogged = true; }
private void ShowMyInventory(GetUserInventoryResult result) { PlayFabClientAPI.GetCatalogItems(new GetCatalogItemsRequest() { CatalogVersion = "Cards" }, result2 => { ShowMyDeck(result2, result); }, error => Debug.Log(error.GenerateErrorReport()));; }
// void OnGetUserInventory(GetUserInventoryResult result) { // 更新货币数量 goldCurrencyCount.text = "金币:" + result.VirtualCurrency ["JB"].ToString(); // 重新获取玩家道具 ShopPanelController.userItems = result.Inventory; // 更新商店列表 shopPanel.GetComponent <ShopPanelController>().ShowItems(); }
private void GetUserInvetoryResult(GetUserInventoryResult _result) { Debug.Log("GetUserInvetoryResult: "); for (int i = 0; i < _result.Inventory.Count; i++) { Debug.Log(TestUtilities.PrintItemInstance2(_result.Inventory[i])); } Debug.Log(string.Format("Virtual currency: {0}", TestUtilities.GetVirtualCurrency(_result.VirtualCurrency))); }
void GetCurrencyCallback(GetUserInventoryResult result) { int livesBalance; int coinsBalance; result.VirtualCurrency.TryGetValue(LIVES_CODE, out livesBalance); result.VirtualCurrency.TryGetValue(COINS_CODE, out coinsBalance); OnReceivedCurrency(livesBalance.ToString(), coinsBalance.ToString()); }
public void GetUserInventory(GetUserInventoryResult res) { inventoryItems.Clear(); Instance.virtualCurrency = res.VirtualCurrency; foreach (var item in res.Inventory) { inventoryItems.Add(item); } OnInventoryUpdate?.Invoke(); }
void OnGetInventoryCallback(GetUserInventoryResult result) { Debug.Log(string.Format("Inventory retrieved. You have {0} items.", result.Inventory.Count)); this.inventory = result.Inventory; int gmBalance; result.VirtualCurrency.TryGetValue("GM", out gmBalance); Debug.Log(string.Format("You have {0} Gems.", gmBalance)); UnlockUI(); }
private void SetCurrencyAccount(GetUserInventoryResult result) { dataManager.SetRuneFragment(result.VirtualCurrency["RF"]); dataManager.SetIRLMonney(result.VirtualCurrency["MI"]); gamePanel.SetActive(true); loginPanel.SetActive(false); registerPanel.SetActive(false); Debug.Log("Monnaie Load"); Debug.Log(dataManager.GetRuneFragment()); Debug.Log(dataManager.GetIRLMonney()); }
void LogSuccess(GetUserInventoryResult guir) { List <string> itemNames = new List <string>(); for (int i = 0; i < guir.Inventory.Count; i++) { Debug.Log(guir.Inventory[i].DisplayName); itemNames.Add(guir.Inventory[i].DisplayName); } showItems(itemNames); }
void OnGetUserInventory(GetUserInventoryResult result) { userItems = result.Inventory; itemsLength = userItems.Count; currentPageNumber = 1; maxPageNumber = (itemsLength - 1) / itemsPerPage + 1; pageMessage.text = currentPageNumber.ToString() + "/" + maxPageNumber.ToString(); ButtonControl(); //翻页按钮控制 ShowItems(); //显示玩家的道具列表 inventoryLoadingInfo.gameObject.SetActive(false); //仓库信息读取完毕,禁用提示面板 }
void ShowNumberBooster(GetUserInventoryResult result) { for (int i = 0; i < result.Inventory.Count; i++) { if (result.Inventory[i].ItemClass == "Booster") { numberBooster++; } } canvasBooster.SetActive(true); textNumberBooster.GetComponent <Text>().text = numberBooster.ToString(); }
//玩家仓库信息获取成功时调用 void OnGetUserInventory(GetUserInventoryResult result) { userItems = result.Inventory; //获取商城道具列表 GetCatalogItemsRequest request = new GetCatalogItemsRequest() { CatalogVersion = PlayFabUserData.catalogVersion }; PlayFabClientAPI.GetCatalogItems(request, OnGetCatalogItems, OnPlayFabError); }
private void InventorySuccess(GetUserInventoryResult result) { foreach (var item in result.VirtualCurrency) { if (item.Key == "CO") { playFabmanager.Player_Coin = item.Value; } } playFabmanager.LoadingMessage("Loading Currency Success"); GetCar(); }
//玩家仓库信息获取成功时调用,玩家道具购买完成 void OnGetUserInventory(GetUserInventoryResult result) { //更新货币数量的显示 goldCurrencyCount.text = result.VirtualCurrency["GC"].ToString(); diamondCurrencyCount.text = result.VirtualCurrency["DC"].ToString(); //提示玩家道具购买成功 purchaseLabel.text = "购买成功"; BackButton.SetActive(true); //重新获取玩家仓库 ShopPanelController.userItems = result.Inventory; //重新显示商店列表 shopPanel.GetComponent <ShopPanelController>().ShowItems(); }
// probably not the best practice to use here, maybe add another check for certain custom properties void OnUserInventoryLoaded(GetUserInventoryResult result) { for (int i = 0; i < result.Inventory.Count; i++) { if (result.Inventory[i].RemainingUses > 0) { ConsumeItemRequest request = new ConsumeItemRequest(); request.ConsumeCount = 1; request.ItemInstanceId = result.Inventory[i].ItemInstanceId; PlayFabClientAPI.ConsumeItem(request, OnItemConsumed, OnItemConsumeError); return; } } }
void RetrieveCallback(GetUserInventoryResult result) { this.Items = result.Inventory; this.VirtualCurrency = result.VirtualCurrency; if (OnRetrieved != null) { OnRetrieved(this); } Respond(null); if (IsOnline) { Save(result, FileName); } }
/// <summary> /// インベントリの取得 /// </summary> public IEnumerator PlayFabGetInventory() { if (!isLogin) { Debug.LogWarning("Error:PlayFab not Login"); yield break; } var getInventoryFunction = new CustomPlayFabFunction <GetUserInventoryRequest, GetUserInventoryResult>(); var request = new GetUserInventoryRequest(); getInventoryFunction.SetRequest = request; yield return(StartCoroutine(getInventoryFunction.ExecuteCoroutine(PlayFabClientAPI.GetUserInventory))); Debug.Log("Result:" + JsonUtility.ToJson(getInventoryFunction.GetResult)); inventory = getInventoryFunction.GetResult; }