Inheritance: PlayFab.SharedModels.PlayFabResultCommon
Exemplo n.º 1
0
	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();
	}
	// 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;
            }
        }
    }
Exemplo n.º 3
0
    private void Callback_GetInventory_Success(PlayFab.ClientModels.GetUserInventoryResult result)
    {
        cardInventory.Clear();
        foreach (PlayFab.ClientModels.ItemInstance item in result.Inventory)
        {
            if (cardDatabase.ContainsKey(item.ItemId))
            {
                //Create new inventory item if card does not already exist
                if (!cardInventory.ContainsKey(item.ItemId))
                {
                    cardInventory[item.ItemId] = new Inventory_Item()
                    {
                        card = cardDatabase[item.ItemId]
                    };
                    cardInventory[item.ItemId].card.ID = item.ItemId;
                    cardInventory[item.ItemId].count   = (int)item.RemainingUses;
                }
            }
        }
        loadingState = enum_loadingState.Done;

        //Update User Currency
        userCurrency = result.VirtualCurrency;
    }
Exemplo n.º 4
0
	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();
	}
	void OnGetInventoryCallback(GetUserInventoryResult result)
	{
		Debug.Log(string.Format("Inventory retrieved. You have {0} items.", result.Inventory.Count));
		
		int gmBalance;
		result.VirtualCurrency.TryGetValue(gmCode, out gmBalance);
		Debug.Log(string.Format("You have {0} Gems.", gmBalance));
		this.gemsValue.text = string.Format("x{0}", gmBalance);
		
		int lvBalance;
		result.VirtualCurrency.TryGetValue(lvCode, out lvBalance);
		Debug.Log(string.Format("You have {0} Lives", lvBalance));
		this.livesValue.text = string.Format("x{0}", lvBalance);
		
		VirtualCurrencyRechargeTime rechargeDetails;
		if(result.VirtualCurrencyRechargeTimes.TryGetValue(lvCode, out rechargeDetails))
		{
			string textOut = string.Empty;
			if(lvBalance < rechargeDetails.RechargeMax)
			{
				this.nextFreeTicket = DateTime.Now.AddSeconds(rechargeDetails.SecondsToRecharge);
				textOut = string.Format("Next life in: {0:n0} seconds", rechargeDetails.SecondsToRecharge);
				this.livesRegen.text = textOut;
				this.areLivesCapped = false;
			}
			else
			{
				textOut = string.Format("Lives only regenerate to a maximum of {0}, and you currently have {1}.", rechargeDetails.RechargeMax, lvBalance);
				this.livesRegen.text = string.Empty;
				this.areLivesCapped = true;
			}
			Debug.Log(textOut);
			
		}
		UnlockUI();
	}