Store(Virtual Items)
This page contains details about retrieving of ids and purchase of Virtual Items
Virtual items are game items, that can be purchased using game currency or can be rewarded as completing certain threshold using Achievements
For example In
- Racing Game : It can be different type of cars.
- Puzzle game: It can be bunch of hints pack.
- Match3 game: There can be different types of power ups.
- Shooting Game: Different type of guns, Ammos etc
Virtual Items can be added in RGN Dev Dashboard. In order to retrieve list of virtual-items you can use following API.
It retrieve the list of available Virtual items in RGN Dev Dashboard.
RGNCoreBuilder.AddModule(new StoreModule());
This needs to be called only once at start and you can cache this value of
virtualItems
in a variable. StoreModule storeModule = RGNCoreBuilder.I.GetModule<StoreModule>();
RGNVirtualItems virtualItems = await storeModule.GetVirtualItems();
You will get list of
RGNVirtualItem
public class RGNVirtualItem
{
public string name;
public string description;
public string itemId; // unique id
public string currency; // Currency name. i.e. coin, rgn-coin etc.
public int price; //price amount
public string category; // category i.e Game
public string subCategory;
public string purchasableRGNAppId;
// NFT parameter
public bool isNFT;
public int purchasedQuantity; // Already purchased quantity of NFT items
public int totalQuantity; // Total number of NFT items
}
For sample implementation, refer to the StoreTestPopUp Panel in our demo scene.
In order to buy an Item, It requires to call the following function by passing Items’s unique id (string) as a parameter. (Before calling PurchaseVirtualItem, you can check the current available quantity of currency and required currency. )
StoreModule storeModule = RGNCoreBuilder.I.GetModule<StoreModule>();
RGNBuyItemData buyItemData = await storeModule.PurchaseVirtualItem(id);
Here is RGNBuyItemData, that you received in response of call. You will also get updated currencies(with deducted amount of item's price)
public class RGNBuyItemData
{
public bool isSuccess; //FALSE, Not have enough currencies
public string message;
public List<RGNCurrency> currencies = new List<RGNCurrency> ();
}
Last modified 8mo ago