반응형
기본 설정
public enum MoneyType
{
Gold,
Crystal
}
public int gold = 0;
public int crystal = 0;
돈 증가
public void UpdateAddCurrency(MoneyType moneyType, int number)
{
string currentType = "";
switch (moneyType)
{
case MoneyType.Gold:
currentType = "GO";
gold += number;
break;
case MoneyType.Crystal:
currentType = "CR";
crystal += number;
break;
}
var request = new AddUserVirtualCurrencyRequest
{
VirtualCurrency = currentType,
Amount = number
};
PlayFabClientAPI.AddUserVirtualCurrency(request, OnAddCurrencySuccess, null);
}
private void OnAddCurrencySuccess(ModifyUserVirtualCurrencyResult result)
{
Debug.Log("돈 증가 완료");
}
돈 감소
public void UpdateSubtractCurrency(MoneyType moneyType, int number)
{
string currentType = "";
switch (moneyType)
{
case MoneyType.Gold:
currentType = "GO";
gold += number;
break;
case MoneyType.Crystal:
currentType = "CR";
crystal += number;
break;
}
var request = new SubtractUserVirtualCurrencyRequest
{
VirtualCurrency = currentType,
Amount = number
};
PlayFabClientAPI.SubtractUserVirtualCurrency(request, OnSubtractCurrencySuccess, null);
}
private void OnSubtractCurrencySuccess(ModifyUserVirtualCurrencyResult result)
{
Debug.Log("돈 감소 완료");
}
반응형
'개발 > Playfab' 카테고리의 다른 글
유니티 플레이팹 아이템 주기 Playfab Grant Item ToUser 간단 사용법 (0) | 2022.07.20 |
---|---|
유니티 플레이팹 아이템 구매 Playfab Shop Purchase Item 간단 사용법 (0) | 2022.07.20 |
유니티 플레이팹 친구 추가, 삭제하기 Playfab Friends Add, Delete 간단 사용법 (0) | 2022.07.19 |
유니티 플레이팹 Json으로 타이틀 데이터 저장, 불러오기 Playfab (0) | 2022.07.19 |
유니티 플레이팹 애플 로그인 Playfab Sign ln with Apple Login 간단 구현 (0) | 2022.07.19 |
유니티 플레이팹 페이스북 로그인 Playfab Sign ln with Facebook Login 간단 구현 (0) | 2022.07.19 |
유니티 플레이팹 클라우드 스크립트 사용 Playfab CloudScripts 간단 사용법 (0) | 2022.07.12 |
유니티 플레이팹 타이틀 뉴스 가져오기 Playfab ReadTitleNews 간단 사용법 (0) | 2022.07.12 |
댓글