【发布时间】:2019-05-30 15:34:47
【问题描述】:
我不知道如何在 MonoGame 项目中使用 PlayFab。我已经阅读了一些 PlayFab 教程,但它们都是针对 Unity 的,我认为无法将 Unity 代码示例与 MonoGame 一起使用,因为我总是收到错误消息。
从这行代码。
PlayFabClientAPI.GetUserInventoryAsync(new GetUserInventoryRequest(), OnGetUserInventoryRequest, OnPlayFabInventoryError);
我在这里收到错误消息:
错误 CS1503:参数 2:无法从“方法组”转换为 '对象'
错误 CS1503:参数 3:无法从“方法组”转换为 '字典'
“OnGetUserInventoryRequest,OnPlayFabInventoryError”有问题,但我不知道我可以改变什么。
我可以进行哪些更改以使此代码与 MonoGame 一起使用?
https://api.playfab.com/documentation/client/method/GetUserInventory
示例代码
public void GetInventoryList()
{
PlayFabClientAPI.GetUserInventoryAsync(new GetUserInventoryRequest(), OnGetUserInventoryRequest, OnPlayFabInventoryError);
}
public void OnGetUserInventoryRequest(GetUserInventoryResult result)
{
Console.WriteLine(result.VirtualCurrency);
}
public void OnPlayFabInventoryError(PlayFabError result)
{
Console.WriteLine("Error");
}
编辑:
如果我想使用 VirtualCurrency 的值,我会收到一条新的错误消息。我不知道如何获取 VirtualCurrency 的值,我做错了什么?
private async Task GetInventoryList()
{
var result = await PlayFabClientAPI.GetUserInventoryAsync(new GetUserInventoryRequest());
int CurrentAmount = result.Result.VirtualCurrency;
}
错误 CS0029:无法隐式转换类型 'System.Collections.Generic.Dictionary' 到 'int'
【问题讨论】:
-
GetUserInventoryAsync 的方法签名是什么?
-
我添加了一张图片。您是指 GetUserInventoryAsync 的方法签名吗?
标签: c# unity3d xamarin monogame