跳转到主要内容

使用道具

处理玩家邮箱中保管的道具使用。

调用信息

// 使用单个道具
public void ConsumeItem (string itemKey, PlayNANOODelegate callback) {}

// 使用多个道具
public void ConsumeMultiItem (List<string> itemKeys, PlayNANOODelegate callback) {}

调用详细信息

参数说明类型
itemKey道具识别键string
itemKeys道具识别键列表List<string>
callback通信结果PlayNANOODelegate

源代码

using PlayNANOO;

public class PlayNANOOExample : MonoBehaviour
{
Plugin plugin;

void Awake()
{
plugin = Plugin.GetInstance();

// 使用单个道具
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");
}
});

// 使用多个道具
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);
}
});
}
}

通信结果

HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
"items": [
{
"item_code": "gold",
"item_count": 100
}
]
]
}

通信结果详细信息

数据键说明类型
items.item_code道具代码string
items.item_count道具数量integer