93 lines
2.4 KiB
C#
93 lines
2.4 KiB
C#
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
namespace Watermelon
|
|
{
|
|
public class UINoAdsPopUp : UIPage
|
|
{
|
|
public override bool IsPopup => true;
|
|
|
|
[SerializeField] Image backgroundImage;
|
|
[SerializeField] UIScaleAnimation panelScalable;
|
|
|
|
[Space]
|
|
[SerializeField] Button backgroundCloseButton;
|
|
[SerializeField] Button smallCloseButton;
|
|
[SerializeField] IAPButton removeAdsButton;
|
|
|
|
private UIFadeAnimation backFade;
|
|
|
|
private void OnEnable()
|
|
{
|
|
IAPManager.PurchaseCompleted += OnPurchaseCompleted;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
IAPManager.PurchaseCompleted -= OnPurchaseCompleted;
|
|
}
|
|
|
|
private void OnPurchaseCompleted(ProductKeyType productKeyType)
|
|
{
|
|
if(productKeyType == ProductKeyType.NoAds)
|
|
{
|
|
AdsManager.DisableForcedAdForever();
|
|
|
|
UIController.HidePage(this);
|
|
}
|
|
}
|
|
|
|
public override void Init()
|
|
{
|
|
backFade = new UIFadeAnimation(gameObject);
|
|
|
|
if (backgroundCloseButton != null)
|
|
backgroundCloseButton.onClick.AddListener(OnBackgroundClicked);
|
|
|
|
if(smallCloseButton != null)
|
|
smallCloseButton.onClick.AddListener(OnCloseButtonClicked);
|
|
|
|
IAPManager.SubscribeOnPurchaseModuleInitted(OnPurchaseModuleInitted);
|
|
|
|
backFade.Hide(immediately: true);
|
|
panelScalable.Hide(immediately: true);
|
|
}
|
|
|
|
private void OnPurchaseModuleInitted()
|
|
{
|
|
if (removeAdsButton != null)
|
|
removeAdsButton.Init(ProductKeyType.NoAds);
|
|
}
|
|
|
|
protected override void OnShow()
|
|
{
|
|
backFade.Show(0.2f, onCompleted: () =>
|
|
{
|
|
panelScalable.Show(immediately: false, duration: 0.3f);
|
|
});
|
|
|
|
NotifyOpened();
|
|
}
|
|
|
|
protected override void OnHide()
|
|
{
|
|
backFade.Hide(0.2f);
|
|
panelScalable.Hide(immediately: false, duration: 0.4f, onCompleted: () =>
|
|
{
|
|
NotifyClosed();
|
|
});
|
|
}
|
|
|
|
private void OnCloseButtonClicked()
|
|
{
|
|
AudioController.PlaySound(AudioController.GetClip("button_sound"));
|
|
|
|
UIController.HidePage<UINoAdsPopUp>();
|
|
}
|
|
|
|
private void OnBackgroundClicked()
|
|
{
|
|
UIController.HidePage<UINoAdsPopUp>();
|
|
}
|
|
}
|
|
} |