Use Item
Uses up the item stored in the player's Inbox.
Call Information
// Use a single item
public void ConsumeItem (string itemKey, PlayNANOODelegate callback) {}
// Use multiple items
public void ConsumeMultiItem (List<string> itemKeys, PlayNANOODelegate callback) {}
Call Information Details
Parameter | Description | Type |
---|---|---|
itemKey | Item identification key | string |
itemKeys | Item identification key list | List<string> |
callback | Communication result | PlayNANOODelegate |
Source Code
using PlayNANOO;
public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;
void Awake()
{
plugin = Plugin.GetInstance();
// Use a single item
string itemKey = "ITEM_KEY";
plugin.InboxManager.ConsumeItem(itemKey, (status, error, jsonString, values) =>
{
if(status.Equals(Configure.PN_API_STATE_SUCCESS)) {
PlayNANOO.Inbox.ItemValueModel[] items = values["Items"] as PlayNANOO.Inbox.ItemValueModel[];
foreach (PlayNANOO.Inbox.ItemValueModel item in items)
{
Debug.Log(item.item_code);
Debug.Log(item.item_count);
}
} else {
Debug.Log("Fail");
}
});
// Use multiple items
List<string> itemKeys = new List<string>();
itemKeys.Add("ITEM_KEY_1");
itemKeys.Add("ITEM_KEY_2");
plugin.InboxManager.ConsumeMultiItem(itemKeys, (status, error, jsonString, values) =>
{
PlayNANOO.Inbox.ItemValueModel[] items = values["Items"] as PlayNANOO.Inbox.ItemValueModel[];
foreach (PlayNANOO.Inbox.ItemValueModel item in items)
{
Debug.Log(item.item_code);
Debug.Log(item.item_count);
}
});
}
}
Communication Result
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"items": [
{
"item_code": "gold",
"item_count": 100
}
]
]
}
Communication Result
Data Key | Description | Type |
---|---|---|
items.item_code | Item code | string |
items.item_count | Item quantity | integer |