GS2-Showcase
GS2-SDK for Game Engine のリファレンス
ゲームエンジン向けSDK
モデル
EzSalesItem
陳列棚
商品を購入するために必要となる対価と商品を購入したときに得られる報酬を設定します。
型 | 説明 | |
---|---|---|
name | string | 商品名 |
metadata | string | メタデータ |
consumeActions | List<EzConsumeAction> | 消費アクションリスト |
acquireActions | List<EzAcquireAction> | 入手アクションリスト |
EzSalesItemGroup
商品グループ
商品グループは陳列棚に陳列するためのエンティティです。
商品グループには複数の商品を所属させることができ、所属している商品の先頭から順番に購入可能かを判定し、一番最初に購入可能だと判定された商品が実際に陳列されます。
初回のみ割引する商品や、ステップアップガチャのように購入回数によって商品の内容が変化する仕組みに使用できます。
型 | 説明 | |
---|---|---|
name | string | 商品グループ名 |
metadata | string | メタデータ |
salesItems | List<EzSalesItem> | 商品グループに含める商品 |
EzShowcase
陳列棚
陳列棚には販売期間を設定できます。
型 | 説明 | |
---|---|---|
name | string | 商品名 |
metadata | string | メタデータ |
displayItems | List<EzDisplayItem> | 陳列された商品リスト |
EzDisplayItem
型 | 説明 | |
---|---|---|
displayItemId | string | 陳列商品ID |
type | enum ['salesItem', 'salesItemGroup'] | 種類 |
salesItem | EzSalesItem | 陳列する商品 |
salesItemGroup | EzSalesItemGroup | 陳列する商品グループ |
EzConfig
型 | 説明 | |
---|---|---|
key | string | 名前 |
value | string | 値 |
EzConsumeAction
型 | 説明 | |
---|---|---|
action | enum [] | スタンプタスクで実行するアクションの種類 |
request | string | 入手リクエストのJSON |
EzAcquireAction
型 | 説明 | |
---|---|---|
action | enum [] | スタンプシートを使用して実行するアクションの種類 |
request | string | リクエストのJSON |
メソッド
buy
buy
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->showcase.buy(
[](gs2::ez::account::AsyncEzBuyResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "showcase.buy failed.");
}
else
{
Item = r.getResult()->getItem();
TransactionId = r.getResult()->getTransactionId();
StampSheet = r.getResult()->getStampSheet();
StampSheetEncryptionKeyId = r.getResult()->getStampSheetEncryptionKeyId();
AutoRunStampSheet = r.getResult()->getAutoRunStampSheet();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace1"), // namespaceName
TCHAR_TO_ANSI("showcase-0001"), // showcaseName
TCHAR_TO_ANSI("display-item-0001"), // displayItemId
null // quantity,
null // config
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Showcase.Namespace(
namespaceName: "namespace1"
).Me(
gameSession: gameSession
).Showcase(
showcaseName: "showcase-0001"
);
var result = await domain.BuyAsync(
displayItemId: "display-item-0001",
quantity: null,
config: null
);
// New Experience ではスタンプシートはSDKレベルで自動的に実行されます。
// エラーが発生すると TransactionException がスローされます。
// TransactionException::Retry() でリトライが可能です。
// In New Experience, stamp sheets are automatically executed at the SDK level.
// If an error occurs, a TransactionException is thrown.
// you can retry with TransactionException::Retry().
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzBuyResult> asyncResult = null;
var current = gs2.Showcase.Buy(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace1",
showcaseName: "showcase-0001",
displayItemId: "display-item-0001",
quantity: null,
config: null
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
var transactionId = result.TransactionId;
var stampSheet = result.StampSheet;
var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
var autoRunStampSheet = result.AutoRunStampSheet;
}
商品を購入します
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
showcaseName | string | ✓ | ~ 128文字 | 商品名 | |
accessToken | string | ✓ | ~ 128文字 | ユーザーID | |
displayItemId | string | ✓ | UUID | ~ 36文字 | 陳列商品ID |
quantity | int | ✓ | 1 | 1 ~ 1000 | 購入数量 |
config | List<EzConfig> | [] | スタンプシートの変数に適用する設定値 |
Result
型 | 説明 | |
---|---|---|
item | EzSalesItem | 商品 |
transactionId | string | 発行されたスタンプシートのトランザクションID |
stampSheet | string | 購入処理の実行に使用するスタンプシート |
stampSheetEncryptionKeyId | string | スタンプシートの署名計算に使用した暗号鍵GRN |
autoRunStampSheet | bool | スタンプシートの自動実行が有効か |
getShowcase
getShowcase
ProfilePtr = std::make_shared<gs2::ez::Profile>(
TCHAR_TO_ANSI(*ClientId),
TCHAR_TO_ANSI(*ClientSecret),
gs2::ez::Gs2BasicReopener()
);
ClientPtr = std::make_shared<gs2::ez::Client>(
*ProfilePtr
);
ProfilePtr->initialize(
[this](gs2::ez::Profile::AsyncInitializeResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "profile.initialize failed.");
}
else
{
AccountCreate();
}
}
);
// Up to this line is the initialization process.
ClientPtr->showcase.getShowcase(
[](gs2::ez::account::AsyncEzGetShowcaseResult r)
{
if (r.getError())
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "showcase.getShowcase failed.");
}
else
{
Item = r.getResult()->getItem();
}
},
ProfilePtr->getGs2Session(),
TCHAR_TO_ANSI("namespace1"), // namespaceName
TCHAR_TO_ANSI("showcase-0001") // showcaseName
);
///////////////////////////////////////////////////////////////
// New Experience (Enabled UniTask)
///////////////////////////////////////////////////////////////
using Gs2.Unity.Util;
#if GS2_ENABLE_UNITASK
using Cysharp.Threading.Tasks;
using Cysharp.Threading.Tasks.Linq;
#endif
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
await profile.InitializeAsync();
var gs2 = new Gs2.Unity.Core.Gs2Domain(profile);
// Up to this line is the initialization process.
{
var domain = gs2.Showcase.Namespace(
namespaceName: "namespace1"
).Me(
gameSession: gameSession
).Showcase(
showcaseName: "showcase-0001"
);
var item = await domain.ModelAsync();
}
///////////////////////////////////////////////////////////////
// Legacy Experience
///////////////////////////////////////////////////////////////
using Gs2.Core.AsyncResult;
using Gs2.Gs2Account.Unity.Result;
using Gs2.Unity.Util;
var profile = new Profile(
clientId: "your client id",
clientSecret: "your client secret",
reopener: new Gs2BasicReopener()
);
{
AsyncResult<object> asyncResult = null;
var current = profile.Initialize(
r => { asyncResult = r; }
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
}
var gs2 = new Gs2.Unity.Client(profile);
// Up to this line is the initialization process.
{
AsyncResult<EzGetShowcaseResult> asyncResult = null;
var current = gs2.Showcase.GetShowcase(
callback: r => { asyncResult = r; },
session: session,
namespaceName: "namespace1",
showcaseName: "showcase-0001"
);
yield return current;
if (asyncResult.Error != null)
{
OnError(asyncResult.Error);
yield break;
}
var result = asyncResult.Result;
var item = result.Item;
}
商品棚を取得
Request
型 | 必須 | デフォルト | 値の制限 | 説明 | |
---|---|---|---|---|---|
namespaceName | string | ✓ | ~ 32文字 | ネームスペース名 | |
accessToken | string | ✓ | ~ 128文字 | ユーザーID | |
showcaseName | string | ✓ | ~ 128文字 | 商品名 |
Result
型 | 説明 | |
---|---|---|
item | EzShowcase | 陳列棚 |