NAV
Unity Unreal Engine 4

GS2-Exchange

GS2-SDK for Game Engine のリファレンス

ゲームエンジン向けモデル

EzRateModel

交換レートはリソースとリソースを交換する際に使用するレートを定義するエンティティです。

直ちに交換できるレートだけでなく、現実時間で一定時間経過したのちに交換できるレートを設定できます。 現実時間での時間経過が必要な交換レートには、更に即時交換を実行するために必要なリソースを定義することが可能です。

説明
name string 交換レートの種類名
metadata string メタデータ
consumeActions ConsumeAction[] 消費アクションリスト
acquireActions AcquireAction[] 入手アクションリスト

EzAwait

現実時間の時間経過が交換条件の交換処理の実行状態を表すエンティティ。

説明
userId string ユーザーID
rateName string 交換レート名
name string 交換待機の名前
exchangedAt long 作成日時

EzConfig

説明
key string 名前
value string

EzAcquireAction

説明
action string スタンプシートで実行するアクションの種類
request string 消費リクエストのJSON

EzConsumeAction

説明
action string スタンプタスクで実行するアクションの種類
request string 入手リクエストのJSON

ゲームエンジン向けメソッド

acquire

acquire

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzAcquireResult> asyncResult = null;
    var current = gs2.Exchange.Acquire(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace2",
        rateName: "material_n_to_r",
        awaitName: "await-0001"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
    var stampSheet = result.StampSheet;
    var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
}
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->exchange.acquire(
    [](gs2::ez::account::AsyncEzAcquireResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.acquire failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
            StampSheet = r.getResult()->getStampSheet();
            StampSheetEncryptionKeyId = r.getResult()->getStampSheetEncryptionKeyId();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace2"), // namespaceName
    TCHAR_TO_ANSI("material_n_to_r"), // rateName
    TCHAR_TO_ANSI("await-0001") // awaitName
);

交換待機の報酬を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
accessToken string ~ 128文字 ユーザーID
rateName string ~ 128文字 交換レート名
awaitName string UUID ~ 36文字 交換待機の名前

Result

説明
item EzAwait 交換待機
stampSheet string 報酬取得処理の実行に使用するスタンプシート
stampSheetEncryptionKeyId string スタンプシートの署名計算に使用した暗号鍵GRN

deleteAwait

deleteAwait

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzDeleteAwaitResult> asyncResult = null;
    var current = gs2.Exchange.DeleteAwait(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace1",
        rateName: "material_n_to_r",
        awaitName: "$await1.name"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
}
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->exchange.deleteAwait(
    [](gs2::ez::account::AsyncEzDeleteAwaitResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.deleteAwait failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("material_n_to_r"), // rateName
    TCHAR_TO_ANSI("$await1.name") // awaitName
);

交換待機情報を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
accessToken string ~ 128文字 ユーザーID
rateName string ~ 128文字 交換レート名
awaitName string UUID ~ 36文字 交換待機の名前

Result

説明
item EzAwait 交換待機

getAwait

getAwait

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzGetAwaitResult> asyncResult = null;
    var current = gs2.Exchange.GetAwait(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace1",
        rateName: "material_n_to_r",
        awaitName: "$await1.name"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
}
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->exchange.getAwait(
    [](gs2::ez::account::AsyncEzGetAwaitResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.getAwait failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("material_n_to_r"), // rateName
    TCHAR_TO_ANSI("$await1.name") // awaitName
);

交換待機情報を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
accessToken string ~ 128文字 ユーザーID
rateName string ~ 128文字 交換レート名
awaitName string UUID ~ 36文字 交換待機の名前

Result

説明
item EzAwait 交換待機

listAwaits

listAwaits

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzDescribeAwaitsResult> asyncResult = null;
    var current = gs2.Exchange.DescribeAwaits(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace1",
        rateName: "material_n_to_r",
        pageToken: null
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var items = result.Items;
    var nextPageToken = result.NextPageToken;
}
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->exchange.describeAwaits(
    [](gs2::ez::account::AsyncEzDescribeAwaitsResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.describeAwaits failed.");
        }
        else
        {
            Items = r.getResult()->getItems();
            NextPageToken = r.getResult()->getNextPageToken();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace1") // namespaceName,
    TCHAR_TO_ANSI("material_n_to_r"), // rateName
    TCHAR_TO_ANSI(null) // pageToken
);

交換待機情報の一覧を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
rateName string ~ 128文字 交換レート名
accessToken string ~ 128文字 ユーザーID
pageToken string ~ 1024文字 データの取得を開始する位置を指定するトークン

Result

説明
items EzAwait[] 交換待機のリスト
nextPageToken string 次のページを取得するためのトークン

skip

skip

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzSkipResult> asyncResult = null;
    var current = gs2.Exchange.Skip(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace2",
        rateName: "material_n_to_r",
        awaitName: "await-0001"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
    var stampSheet = result.StampSheet;
    var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
}
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->exchange.skip(
    [](gs2::ez::account::AsyncEzSkipResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.skip failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
            StampSheet = r.getResult()->getStampSheet();
            StampSheetEncryptionKeyId = r.getResult()->getStampSheetEncryptionKeyId();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace2"), // namespaceName
    TCHAR_TO_ANSI("material_n_to_r"), // rateName
    TCHAR_TO_ANSI("await-0001") // awaitName
);

交換待機を対価を払ってスキップ

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
accessToken string ~ 128文字 ユーザーID
rateName string ~ 128文字 交換レート名
awaitName string UUID ~ 36文字 交換待機の名前

Result

説明
item EzAwait 交換待機
stampSheet string 報酬取得処理の実行に使用するスタンプシート
stampSheetEncryptionKeyId string スタンプシートの署名計算に使用した暗号鍵GRN

getRateModel

getRateModel

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzGetRateModelResult> asyncResult = null;
    var current = gs2.Exchange.GetRateModel(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1",
        rateName: "character-level"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
}
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->exchange.getRateModel(
    [](gs2::ez::account::AsyncEzGetRateModelResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.getRateModel failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
        }
    },
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("character-level") // rateName
);

交換レートモデル情報を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
rateName string ~ 128文字 交換レートの種類名

Result

説明
item EzRateModel 交換レートモデル

listRateModels

listRateModels

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzDescribeRateModelsResult> asyncResult = null;
    var current = gs2.Exchange.DescribeRateModels(
        callback: r => { asyncResult = r; },
        namespaceName: "namespace1"
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var items = result.Items;
}
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->exchange.describeRateModels(
    [](gs2::ez::account::AsyncEzDescribeRateModelsResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.describeRateModels failed.");
        }
        else
        {
            Items = r.getResult()->getItems();
        }
    },
    TCHAR_TO_ANSI("namespace1") // namespaceName
);

交換レートモデル情報の一覧を取得

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名

Result

説明
items EzRateModel[] 交換レートモデルのリスト

exchange

exchange

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;
    }
}

// Up to this line is the initialization process.

var gs2 = new Gs2.Unity.Client(profile);

{
    AsyncResult<EzExchangeResult> asyncResult = null;
    var current = gs2.Exchange.Exchange(
        callback: r => { asyncResult = r; },
        session: session,
        namespaceName: "namespace1",
        rateName: "rate-0001",
        count: 1,
        config: null
    );

    yield return current;
    if (asyncResult.Error != null)
    {
        OnError(asyncResult.Error);
        yield break;
    }

    var result = asyncResult.Result;
    var item = result.Item;
    var stampSheet = result.StampSheet;
    var stampSheetEncryptionKeyId = result.StampSheetEncryptionKeyId;
}
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->exchange.exchange(
    [](gs2::ez::account::AsyncEzExchangeResult r)
    {
        if (r.getError())
        {
            GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, "exchange.exchange failed.");
        }
        else
        {
            Item = r.getResult()->getItem();
            StampSheet = r.getResult()->getStampSheet();
            StampSheetEncryptionKeyId = r.getResult()->getStampSheetEncryptionKeyId();
        }
    },
    ProfilePtr->getGs2Session(),
    TCHAR_TO_ANSI("namespace1"), // namespaceName
    TCHAR_TO_ANSI("rate-0001"), // rateName
    1 // count,
    null // config
);

交換を実行

Request

必須 デフォルト 値の制限 説明
namespaceName string ~ 32文字 ネームスペース名
rateName string ~ 128文字 交換レートの種類名
accessToken string ~ 128文字 ユーザーID
count int 1 ~ 9223372036854775807 交換するロット数
config Config[] [] 設定値

Result

説明
item EzRateModel 交換レートモデル
stampSheet string 交換処理の実行に使用するスタンプシート
stampSheetEncryptionKeyId string スタンプシートの署名計算に使用した暗号鍵GRN