C# Class Soomla.Store.StoreInventory

This class will help you do your day to day virtual economy operations easily. You can give or take items from your users. You can buy items or upgrade them. You can also check their equipping status and change it.
Afficher le fichier Open project: soomla/unity3d-store Class Usage Examples

Méthodes publiques

Méthode Description
BuyItem ( string itemId ) : void

Buys the item with the given itemId.

BuyItem ( string itemId, string payload ) : void

Buys the item with the given itemId.

CanAfford ( string itemId ) : bool

Checks if there is enough funds to afford itemId.

EquipVirtualGood ( string goodItemId ) : void

Equips the virtual good with the given goodItemId. Equipping means that the user decides to currently use a specific virtual good. For more details and examples com.soomla.store.domain.virtualGoods.EquippableVG.

GetEquippedVirtualGood ( Soomla.Store.VirtualCategory category ) : Soomla.Store.EquippableVG

Checks currently equipped good in given category

GetEquippedVirtualGood ( string categoryName ) : Soomla.Store.EquippableVG

Checks currently equipped good in given category

GetGoodCurrentUpgrade ( string goodItemId ) : string

Retrieves the current upgrade of the good with the given id.

GetGoodUpgradeLevel ( string goodItemId ) : int

Retrieves the upgrade level of the virtual good with the given goodItemId. For Example: Let's say there's a strength attribute to one of the characters in your game and you provide your users with the ability to upgrade that strength on a scale of 1-3. This is what you've created: 1. SingleUseVG for "strength". 2. UpgradeVG for strength 'level 1'. 3. UpgradeVG for strength 'level 2'. 4. UpgradeVG for strength 'level 3'. In the example, this function will retrieve the upgrade level for "strength" (1, 2, or 3).

GetItemBalance ( string itemId ) : int

Retrieves the balance of the virtual item with the given itemId.

GiveItem ( string itemId, int amount ) : void

Gives your user the given amount of the virtual item with the given itemId. For example, when your user plays your game for the first time you GIVE him/her 1000 gems. NOTE: This action is different than buy - You use give(int amount) to give your user something for free. You use buy() to give your user something and you get something in return.

IsVirtualGoodEquipped ( string goodItemId ) : bool

Checks if the virtual good with the given goodItemId is currently equipped.

RefreshLocalInventory ( ) : void

This function refreshes a local set of objects that will hold your user's balances in memory for quick and more efficient fetching for your game UI. This way, we save many JNI or static calls to native platforms. NOTE: You don't need to call this function as it's automatically called when the game initializes. NOTE: This is less useful when you work in editor.

RefreshOnCurrencyBalanceChanged ( Soomla.Store.VirtualCurrency virtualCurrency, int balance, int amountAdded ) : void
RefreshOnGoodBalanceChanged ( Soomla.Store.VirtualGood good, int balance, int amountAdded ) : void
RefreshOnGoodEquipped ( Soomla.Store.EquippableVG equippable ) : void
RefreshOnGoodUnEquipped ( Soomla.Store.EquippableVG equippable ) : void
RefreshOnGoodUpgrade ( Soomla.Store.VirtualGood vg, UpgradeVG uvg ) : void
RemoveGoodUpgrades ( string goodItemId ) : void

Removes all upgrades from the virtual good with the given goodItemId.

TakeItem ( string itemId, int amount ) : void

Takes from your user the given amount of the virtual item with the given itemId. For example, when your user requests a refund, you need to TAKE the item he/she is returning from him/her.

UnEquipVirtualGood ( string goodItemId ) : void

Unequips the virtual good with the given goodItemId. Unequipping means that the user decides to stop using the virtual good he/she is currently using. For more details and examples com.soomla.store.domain.virtualGoods.EquippableVG.

UpgradeGood ( string goodItemId ) : void

Upgrades the virtual good with the given goodItemId by doing the following: 1. Checks if the good is currently upgraded or if this is the first time being upgraded. 2. If the good is currently upgraded, upgrades to the next upgrade in the series. In case there are no more upgrades available(meaning the current upgrade is the last available), the function returns. 3. If the good has never been upgraded before, the function upgrades it to the first available upgrade with the first upgrade of the series.

Private Methods

Méthode Description
UpdateLocalBalance ( string itemId, int balance ) : void

Method Details

BuyItem() public static méthode

Buys the item with the given itemId.
Thrown if the item to be bought is not found. Thrown if the user does not have enough funds.
public static BuyItem ( string itemId ) : void
itemId string id of item to be bought
Résultat void

BuyItem() public static méthode

Buys the item with the given itemId.
Thrown if the item to be bought is not found. Thrown if the user does not have enough funds.
public static BuyItem ( string itemId, string payload ) : void
itemId string id of item to be bought
payload string a string you want to be assigned to the purchase. This string /// is saved in a static variable and will be given bacl to you when the purchase is completed.
Résultat void

CanAfford() public static méthode

Checks if there is enough funds to afford itemId.
public static CanAfford ( string itemId ) : bool
itemId string id of item to be checked
Résultat bool

EquipVirtualGood() public static méthode

Equips the virtual good with the given goodItemId. Equipping means that the user decides to currently use a specific virtual good. For more details and examples com.soomla.store.domain.virtualGoods.EquippableVG.
Thrown if the item is not found.
public static EquipVirtualGood ( string goodItemId ) : void
goodItemId string Id of the good to be equipped.
Résultat void

GetEquippedVirtualGood() public static méthode

Checks currently equipped good in given category
public static GetEquippedVirtualGood ( Soomla.Store.VirtualCategory category ) : Soomla.Store.EquippableVG
category Soomla.Store.VirtualCategory Category we want to check
Résultat Soomla.Store.EquippableVG

GetEquippedVirtualGood() public static méthode

Checks currently equipped good in given category
public static GetEquippedVirtualGood ( string categoryName ) : Soomla.Store.EquippableVG
categoryName string
Résultat Soomla.Store.EquippableVG

GetGoodCurrentUpgrade() public static méthode

Retrieves the current upgrade of the good with the given id.
Thrown if the item is not found.
public static GetGoodCurrentUpgrade ( string goodItemId ) : string
goodItemId string Id of the good whose upgrade we want to fetch.
Résultat string

GetGoodUpgradeLevel() public static méthode

Retrieves the upgrade level of the virtual good with the given goodItemId. For Example: Let's say there's a strength attribute to one of the characters in your game and you provide your users with the ability to upgrade that strength on a scale of 1-3. This is what you've created: 1. SingleUseVG for "strength". 2. UpgradeVG for strength 'level 1'. 3. UpgradeVG for strength 'level 2'. 4. UpgradeVG for strength 'level 3'. In the example, this function will retrieve the upgrade level for "strength" (1, 2, or 3).
Thrown if the item is not found.
public static GetGoodUpgradeLevel ( string goodItemId ) : int
goodItemId string Good item identifier.
Résultat int

GetItemBalance() public static méthode

Retrieves the balance of the virtual item with the given itemId.
Thrown if the item is not found.
public static GetItemBalance ( string itemId ) : int
itemId string Id of the virtual item to be fetched.
Résultat int

GiveItem() public static méthode

Gives your user the given amount of the virtual item with the given itemId. For example, when your user plays your game for the first time you GIVE him/her 1000 gems. NOTE: This action is different than buy - You use give(int amount) to give your user something for free. You use buy() to give your user something and you get something in return.
Thrown if the item is not found.
public static GiveItem ( string itemId, int amount ) : void
itemId string Id of the item to be given.
amount int Amount of the item to be given.
Résultat void

IsVirtualGoodEquipped() public static méthode

Checks if the virtual good with the given goodItemId is currently equipped.
Thrown if the item is not found.
public static IsVirtualGoodEquipped ( string goodItemId ) : bool
goodItemId string Id of the virtual good who we want to know if is equipped.
Résultat bool

RefreshLocalInventory() public static méthode

This function refreshes a local set of objects that will hold your user's balances in memory for quick and more efficient fetching for your game UI. This way, we save many JNI or static calls to native platforms. NOTE: You don't need to call this function as it's automatically called when the game initializes. NOTE: This is less useful when you work in editor.
public static RefreshLocalInventory ( ) : void
Résultat void

RefreshOnCurrencyBalanceChanged() public static méthode

public static RefreshOnCurrencyBalanceChanged ( Soomla.Store.VirtualCurrency virtualCurrency, int balance, int amountAdded ) : void
virtualCurrency Soomla.Store.VirtualCurrency
balance int
amountAdded int
Résultat void

RefreshOnGoodBalanceChanged() public static méthode

public static RefreshOnGoodBalanceChanged ( Soomla.Store.VirtualGood good, int balance, int amountAdded ) : void
good Soomla.Store.VirtualGood
balance int
amountAdded int
Résultat void

RefreshOnGoodEquipped() public static méthode

public static RefreshOnGoodEquipped ( Soomla.Store.EquippableVG equippable ) : void
equippable Soomla.Store.EquippableVG
Résultat void

RefreshOnGoodUnEquipped() public static méthode

public static RefreshOnGoodUnEquipped ( Soomla.Store.EquippableVG equippable ) : void
equippable Soomla.Store.EquippableVG
Résultat void

RefreshOnGoodUpgrade() public static méthode

public static RefreshOnGoodUpgrade ( Soomla.Store.VirtualGood vg, UpgradeVG uvg ) : void
vg Soomla.Store.VirtualGood
uvg UpgradeVG
Résultat void

RemoveGoodUpgrades() public static méthode

Removes all upgrades from the virtual good with the given goodItemId.
Thrown if the item is not found.
public static RemoveGoodUpgrades ( string goodItemId ) : void
goodItemId string Id of the good whose upgrades are to be removed.
Résultat void

TakeItem() public static méthode

Takes from your user the given amount of the virtual item with the given itemId. For example, when your user requests a refund, you need to TAKE the item he/she is returning from him/her.
Thrown if the item is not found.
public static TakeItem ( string itemId, int amount ) : void
itemId string Item identifier.
amount int Amount.
Résultat void

UnEquipVirtualGood() public static méthode

Unequips the virtual good with the given goodItemId. Unequipping means that the user decides to stop using the virtual good he/she is currently using. For more details and examples com.soomla.store.domain.virtualGoods.EquippableVG.
Thrown if the item is not found.
public static UnEquipVirtualGood ( string goodItemId ) : void
goodItemId string Id of the good to be unequipped.
Résultat void

UpgradeGood() public static méthode

Upgrades the virtual good with the given goodItemId by doing the following: 1. Checks if the good is currently upgraded or if this is the first time being upgraded. 2. If the good is currently upgraded, upgrades to the next upgrade in the series. In case there are no more upgrades available(meaning the current upgrade is the last available), the function returns. 3. If the good has never been upgraded before, the function upgrades it to the first available upgrade with the first upgrade of the series.
Thrown if the item is not found.
public static UpgradeGood ( string goodItemId ) : void
goodItemId string Good item identifier.
Résultat void