플레이어 잔액
Use the SDK to manage player currency balances.
읽는 시간 1분최근 업데이트: 17일 전
PlayerBalancesGetBalancesAsync
현재 사용자의 재화 잔액을 가져옵니다. 필요에 따라GetBalancesOptionsGetBalancesOptions이 메서드는// Optional, defaults to 20GetBalancesOptions options = new GetBalancesOptions{ ItemsPerFetch = 5};GetBalancesResult getBalancesResult = await EconomyService.Instance.PlayerBalances.GetBalancesAsync(options);List<PlayerBalance> firstFiveBalances = getBalancesResult.Balances;// do something with your balancesif (getBalancesResult.HasNext) { getBalancesResult = await getBalancesResult.GetNextAsync(options.ItemsPerFetch); List<PlayerBalance> nextFiveBalances = getBalancesResult.Balances; // do something with your balances}
GetBalancesResultGetBalancesOptions
GetBalancesAsync- : 정수입니다. 기본값은 20입니다. 이 필드를 사용하여 1~100까지 호출당 가져올 최대 잔액 수를 설정합니다.
ItemsPerFetch
GetBalancesResult
GetBalancesResult- :
Balances와 현재 가져온 잔액이 있습니다.List<PlayerBalance>
- : 이 메서드는 비동기식으로 더 많은 결과를 가져옵니다. 여기에는 필요에 따라 가져오는 결과를 제한하는 파라미터 1개가 포함됩니다. 1~100으로 설정할 수 있으며 기본값은 20입니다.
GetNextAsync(int itemsToFetch = 20)목록에는 원래 아이템과 새로 가져온 아이템이 모두 포함된 새 결과가 반환됩니다.Balances
SetBalanceAsync
특정 재화의 잔액을 특정 값으로 설정합니다. 이 메서드는 필요에 따라 쓰기 잠금을 설정하는 데 사용되는SetBalancesOptionswriteLockwriteLockwriteLockstring currencyID = "GOLD_BARS";int newAmount = 1000;string writeLock = "someLockValueFromPreviousRequest";SetBalanceOptions options = new SetBalanceOptions{ WriteLock = writeLock};PlayerBalance newBalance = await EconomyService.Instance.PlayerBalances.SetBalanceAsync(currencyID, newAmount);// ORPlayerBalance otherNewBalance = await EconomyService.Instance.PlayerBalances.SetBalanceAsync(currencyID, newAmount, options);
SetBalanceOptions
SetBalanceAsync- : 문자열이며, 기본값은
WriteLock입니다. 이 문자열을 사용하여 낙관적 동시성을 위한 쓰기 잠금을 설정합니다. 쓰기 잠금을 참고하십시오.null
IncrementBalanceAsync
특정 재화의 잔액을 특정 값에 따라 증액합니다. 이 메서드는 필요에 따라 쓰기 잠금을 설정하는 데 사용되는IncrementBalancesOptionswriteLockwriteLockwriteLockstring currencyID = "GOLD_BARS";int incrementAmount = 1000;string writeLock = "someLockValueFromPreviousRequest";IncrementBalanceOptions options = new IncrementBalanceOptions{ WriteLock = writeLock};PlayerBalance newBalance = await EconomyService.Instance.PlayerBalances.IncrementBalanceAsync(currencyID, newAmount);// ORPlayerBalance otherNewBalance = await EconomyService.Instance.PlayerBalances.IncrementBalanceAsync(currencyID, newAmount, options);
IncrementBalanceOptions
IncrementBalanceAsync- : 문자열이며, 기본값은
WriteLock입니다. 이 문자열을 사용하여 낙관적 동시성을 위한 쓰기 잠금을 설정합니다. 쓰기 잠금을 참고하십시오.null
DecrementBalanceAsync
특정 재화의 잔액을 특정 값에 따라 감액합니다. 이 메서드는 필요에 따라 쓰기 잠금을 설정하는 데 사용되는DecrementBalanceOptionswriteLockwriteLockwriteLockstring currencyID = "GOLD_BARS";int decrementAmount = 1000;string writeLock = "someLockValueFromPreviousRequest";DecrementBalanceOptions options = new DecrementBalanceOptions{ WriteLock = writeLock};PlayerBalance newBalance = await EconomyService.Instance.PlayerBalances.DecrementBalanceAsync(currencyID, newAmount);// ORPlayerBalance otherNewBalance = await EconomyService.Instance.PlayerBalances.DecrementBalanceAsync(currencyID, newAmount, options);
DecrementBalanceOptions
DecrementBalanceAsync- : 문자열이며, 기본값은
WriteLock입니다. 이 문자열을 사용하여 낙관적 동시성을 위한 쓰기 잠금을 설정합니다. 쓰기 잠금을 참고하십시오.null
PlayerBalance
플레이어 잔액은 플레이어의 단일 재화 잔액을 나타냅니다. 포함되는 필드는 다음과 같습니다.- : 이 잔액이 나타내는 재화의 ID입니다.
CurrencyId - : 플레이어가 보유한 이 재화의 금액(정수)입니다.
Balance - : 현재
WriteLock문자열입니다.writeLock - : 이 잔액이 생성된 날짜입니다. EconomyDate 오브젝트입니다.
Created - : 이 잔액이 수정된 날짜입니다. EconomyDate 오브젝트입니다.
Modified
GetCurrencyDefinitionAsync
이 잔액과 연결된 재화의 재화 정의를 가져올 수 있는 간편한 메서드입니다. CurrencyDefinition이 반환됩니다.PlayerBalance myPlayerBalance = ... // Get a player balance from one of the above methodsCurrencyDefinition currencyDefForMyPlayerBalance = myPlayerBalance.GetCurrencyDefinitionAsync();
BalanceUpdated
이 이벤트를 구독하면 SDK에서 특정 재화의 잔액이 업데이트될 때 알림을 받을 수 있습니다. 구독자에게는 업데이트된 잔액의 재화 ID가 전달됩니다.EconomyService.Instance.PlayerBalances.BalanceUpdated += currencyID => { Debug.Log($"The currency that was updated was {currencyID}");};