Do-37 [Style] 애드매니저 주석 변경
This commit is contained in:
parent
a9bd5a5364
commit
71c77ae0c8
@ -43,7 +43,7 @@ public class AdManager : MonoBehaviour
|
||||
{
|
||||
if (rewardedInterstitialAd != null && rewardedInterstitialAd.CanShowAd())
|
||||
{
|
||||
rewardedInterstitialAd.Show((Reward reward) =>
|
||||
rewardedInterstitialAd.Show((Reward reward) => //서버에서 500코인을 고정으로 반환하기 때문에 reward는 사용하지 않음.
|
||||
{
|
||||
// 코인 지급 로직
|
||||
GrantReward();
|
||||
|
@ -375,4 +375,62 @@ public class NetworkManager : Singleton<NetworkManager>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//코인 구매 함수
|
||||
public void PurchaseCoins(Action<int> success, Action failure)
|
||||
{
|
||||
StartCoroutine(PurchaseCoinsCoroutine(success, failure));
|
||||
}
|
||||
|
||||
private IEnumerator PurchaseCoinsCoroutine(Action<int> success, Action failure)
|
||||
{
|
||||
string jsonString = "{\"adCompleted\": true}"; //테스트를 위해 ture로 설정
|
||||
byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(jsonString);
|
||||
|
||||
using (UnityWebRequest www =
|
||||
new UnityWebRequest(Constants.ServerURL + "/coins/recharge/ad", UnityWebRequest.kHttpVerbPOST))
|
||||
{
|
||||
www.uploadHandler = new UploadHandlerRaw(bodyRaw);
|
||||
www.downloadHandler = new DownloadHandlerBuffer();
|
||||
www.SetRequestHeader("Content-Type", "application/json");
|
||||
|
||||
string sid = PlayerPrefs.GetString("sid", "");
|
||||
if (!string.IsNullOrEmpty(sid))
|
||||
{
|
||||
www.SetRequestHeader("Cookie", sid);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("SID 값이 없습니다. 로그인 정보가 없습니다.");
|
||||
failure?.Invoke();
|
||||
yield break;
|
||||
}
|
||||
|
||||
yield return www.SendWebRequest();
|
||||
|
||||
if (www.result == UnityWebRequest.Result.ConnectionError ||
|
||||
www.result == UnityWebRequest.Result.ProtocolError)
|
||||
{
|
||||
Debug.Log("광고 시청 후 코인 충전 실패: " + www.error);
|
||||
failure?.Invoke();
|
||||
}
|
||||
else
|
||||
{
|
||||
var result = www.downloadHandler.text;
|
||||
var rechargeResult = JsonUtility.FromJson<CoinsAdResult>(result);
|
||||
|
||||
if (rechargeResult.result == "SUCCESS")
|
||||
{
|
||||
Debug.Log("광고 시청으로 코인 충전 완료: " + rechargeResult.recharged);
|
||||
UserManager.Instance.SetCoinsInfo();
|
||||
success?.Invoke(rechargeResult.recharged);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("광고 시청 후 충전 실패: " + rechargeResult.result);
|
||||
failure?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -27,5 +27,9 @@ public class ShopItemController : MonoBehaviour
|
||||
//보상형 전면 광고 로드
|
||||
FindObjectOfType<AdManager>().ShowRewardedInterstitialAd(); //Todo FindOf 함수 수정
|
||||
}
|
||||
else
|
||||
{
|
||||
//todo 가격별로 구매하기
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user