Do-37 [Fix] 중복 클릭 방지
This commit is contained in:
parent
5ba44357e8
commit
2b2d4c1e9f
@ -38,14 +38,14 @@ public class AdManager : MonoBehaviour
|
||||
}
|
||||
|
||||
// 보상형 전면 광고 실행
|
||||
public void ShowRewardedInterstitialAd()
|
||||
public void ShowRewardedInterstitialAd(CanvasGroup shopPanel)
|
||||
{
|
||||
if (rewardedInterstitialAd != null && rewardedInterstitialAd.CanShowAd())
|
||||
{
|
||||
rewardedInterstitialAd.Show((Reward reward) => //서버에서 500코인을 고정으로 반환하기 때문에 reward는 사용하지 않음.
|
||||
{
|
||||
// 코인 지급 로직
|
||||
GrantReward();
|
||||
GrantReward(shopPanel);
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -62,12 +62,12 @@ public class AdManager : MonoBehaviour
|
||||
}
|
||||
|
||||
// 코인 지급 함수
|
||||
private void GrantReward()
|
||||
private void GrantReward(CanvasGroup shopPanel)
|
||||
{
|
||||
NetworkManager.Instance.WatchAdForCoins((coinsAdded) =>
|
||||
{
|
||||
// UI 업데이트
|
||||
GameManager.Instance.panelManager.UpdateCoinsPanelUI(coinsAdded);
|
||||
GameManager.Instance.panelManager.UpdateCoinsPanelUI(coinsAdded, shopPanel);
|
||||
}, () =>
|
||||
{
|
||||
Debug.Log("광고 시청 후 코인 추가 실패!");
|
||||
|
@ -56,6 +56,7 @@ MonoBehaviour:
|
||||
coinsRemoveAudioClip: {fileID: 8300000, guid: 585a9de0fb7ee4163af5c559ba5b2364, type: 3}
|
||||
coinsAddAudioClip: {fileID: 8300000, guid: 1ec44182fa76a4b3eb1459c0a6d9a8ab, type: 3}
|
||||
coinsEmptyAudioClip: {fileID: 8300000, guid: 908a78cb991984977bea42916bed8684, type: 3}
|
||||
ShopPanel: {fileID: 8190964574954487140, guid: eb257b0a685b2254f860f294ce8cba54, type: 3}
|
||||
--- !u!82 &5499754916380040505
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using UnityEngine;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.Serialization;
|
||||
using UnityEngine.UI;
|
||||
|
||||
@ -14,7 +15,7 @@ public class CoinsPanelController : MonoBehaviour
|
||||
[SerializeField] private AudioClip coinsRemoveAudioClip;
|
||||
[SerializeField] private AudioClip coinsAddAudioClip;
|
||||
[SerializeField] private AudioClip coinsEmptyAudioClip;
|
||||
|
||||
|
||||
private Color _coinsColor;
|
||||
private AudioSource _audioSource;
|
||||
private int _coinsCount;
|
||||
@ -93,11 +94,13 @@ public class CoinsPanelController : MonoBehaviour
|
||||
/// 코인 추가 함수
|
||||
/// </summary>
|
||||
/// <param name="coinsCount"> 추가할 코인 수량</param>
|
||||
/// <param name="shopPanel"></param>
|
||||
/// <param name="action">애니메이션 종료 후 동작 EX) 코인 수량 변경</param>
|
||||
public void AddCoins(int coinsCount, Action action)
|
||||
public void AddCoins(int coinsCount, CanvasGroup shopPanel,Action action)
|
||||
{
|
||||
shopPanel.blocksRaycasts = false; //코인 중복 추가 방지 코드
|
||||
|
||||
Sequence sequence = DOTween.Sequence();
|
||||
|
||||
// i += a 반복 횟수 조절, 100개 단위로 상승 차감 시 100으로 설정
|
||||
for (int i = 0; i < coinsCount; i+=500)
|
||||
{
|
||||
@ -115,6 +118,10 @@ public class CoinsPanelController : MonoBehaviour
|
||||
});
|
||||
sequence.AppendInterval(0.5f);
|
||||
}
|
||||
sequence.OnComplete(() =>
|
||||
{
|
||||
shopPanel.blocksRaycasts = true; //구매 후 클릭 활성화
|
||||
});
|
||||
}
|
||||
|
||||
public void EmptyCoins()
|
||||
|
@ -22,20 +22,23 @@ public class ShopItemController : MonoBehaviour
|
||||
|
||||
public void OnClickShopItem()
|
||||
{
|
||||
var shopPanel = GetComponentInParent<CanvasGroup>(); //코인 구매시 상점 패널의 캔버스 그룹 raycast를 비활성화하여 중복클릭 방지.
|
||||
|
||||
if (_shopItem.Price == 0)
|
||||
{
|
||||
//보상형 전면 광고 로드
|
||||
_adManager = GetComponent<AdManager>();
|
||||
_adManager.ShowRewardedInterstitialAd();
|
||||
_adManager.ShowRewardedInterstitialAd(shopPanel);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
NetworkManager.Instance.PurchaseCoins(
|
||||
_shopItem.Price, // 충전할 코인 개수
|
||||
_shopItem.Name, // 결제 ID
|
||||
"GooglePay", // 결제 방식 (GooglePay, PayPal 등)
|
||||
(coins) => {
|
||||
GameManager.Instance.panelManager.UpdateCoinsPanelUI(coins);
|
||||
GameManager.Instance.panelManager.UpdateCoinsPanelUI(coins,shopPanel);
|
||||
},
|
||||
() => {
|
||||
Debug.LogError("결제 후 코인 충전 실패!");
|
||||
|
@ -202,11 +202,11 @@ public class PanelManager : MonoBehaviour
|
||||
}
|
||||
|
||||
//코인 패널 코인 갱신
|
||||
public void UpdateCoinsPanelUI(int coinsChanged)
|
||||
public void UpdateCoinsPanelUI(int coinsChanged, CanvasGroup shopPanel)
|
||||
{
|
||||
if (_coinsPanel != null)
|
||||
{
|
||||
_coinsPanel.AddCoins(coinsChanged, () =>
|
||||
_coinsPanel.AddCoins(coinsChanged, shopPanel, () =>
|
||||
{
|
||||
|
||||
});
|
||||
|
@ -8,10 +8,10 @@ public class CoinUITestScript : MonoBehaviour
|
||||
|
||||
public void OnClickAddCoin()
|
||||
{
|
||||
coinsPanelController.AddCoins(100, () =>
|
||||
{
|
||||
Debug.Log("Add coin 후 동작");
|
||||
});
|
||||
// coinsPanelController.AddCoins(100, () =>
|
||||
// {
|
||||
// Debug.Log("Add coin 후 동작");
|
||||
// });
|
||||
}
|
||||
|
||||
public void OnClickRemoveCoin()
|
||||
|
Loading…
x
Reference in New Issue
Block a user