你的下一项功能
玩家数值
由服务器管理的货币、计数和能量。为每个项目定义余额、优惠和经过校验的变更。
Unity

可见的结果
游戏会显示已配置的余额和优惠。购买操作会返回玩家的当前状态。
此步骤尚无视频。指南和MCP请求已可使用。
玩家数值
准备同一个项目
在仪表盘中选择与游戏配置相同的项目。
玩家数值 →在控制台表单中创建或复用这些测试条目。这些是示例值,并非项目当前数据。
- 数值
coins: initialBalance=100, maxBalance=1000000; energy: initialBalance=10, maxBalance=100- 允许直接变更
false- 优惠
energy-pack: costs=[{"key":"coins","amount":20}], rewards=[{"key":"energy","amount":5}]
每个数值键仅发放一次初始余额。直接变更默认关闭。Validated Actions 保留每局限制;每日及余额上限来自这些定义。可选上限留空表示不限。
运行示例前先保存、重新加载并核对条目。保留其他定义。
实现此功能
你可以预览指南。运行需要有效的项目密钥。 准备项目
已安装 SDK、导入项目配置,且玩家已登录。
此 SDK 示例使用 develop。请检查已安装的 SDK 是否具备所需 API。
先通过快速入门连接目标玩家,再通过明确的按钮或场景操作调用RunReviewedAction()。仅打开文件不会发送请求。
C#
1using UnityEngine;
2using PM.horizOn.Cloud.Core;
3using PM.horizOn.Cloud.Manager;
4
5// Existing SDK/project configuration and authenticated player session required.
6// Call RunReviewedAction explicitly after reviewing this example and its data.
7public sealed class PlayerValuesDemo : MonoBehaviour
8{
9 public async void RunReviewedAction()
10 {
11 var sessionUser = UserManager.Instance.CurrentUser;
12 if (sessionUser == null || !sessionUser.IsValid()) return;
13 var userId = UserManager.Instance.CurrentUser.UserId;
14 var current = await PlayerValuesManager.Instance.GetState(userId);
15 if (!current.IsSuccess) { Debug.LogWarning(current.ErrorCode); return; }
16 foreach (var value in current.State.values) Debug.Log(value.key + "=" + value.balance);
17 // This minimal first call reads authoritative balances, never a local reward delta.
18 // For purchases and original retry, import PlayerValuesExample and its
19 // PendingPlayerValuesPurchase helper from the official SDK samples.
20 // Persist the complete original user/offer/operationId before one send.
21 // An uncertain or expired original must never become a fresh purchase ID.
22 }
23}
测试你的新功能。
游戏会显示已配置的余额和优惠。购买操作会返回玩家的当前状态。
在仪表盘中选择与游戏配置相同的项目。
接口
- GET
/player-values - GET
/player-values/offers - POST
/player-values/purchase - POST
/player-values/adjust


