You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/Dev/Bootstrapper.cs

70 lines
1.8 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class Bootstrapper : MonoBehaviour
{
[SerializeField] private CanvasGroup PrivacyPolicyPanel;
[SerializeField] private Slider loadingSlider;
private void Awake()
{
CheckForPrivacyPolicy();
}
public void CheckForPrivacyPolicy()
{
// Check if the key exists and its value
if (PlayerPrefs.GetInt(GameConstants.PrivacyPolicyPrefKey, 0) == 0)
{
// Show the privacy policy panel
PrivacyPolicyPanel.alpha = 0;
PrivacyPolicyPanel.gameObject.SetActive(true);
PrivacyPolicyPanel.DOFade(1, 0.5f);
}
else
{
// Hide the panel if already accepted
PrivacyPolicyPanel.gameObject.SetActive(false);
}
}
// Call this method when the user agrees to the privacy policy
public void OnAgreeButtonPressed()
{
Sound.instance.PlayButton();
PlayerPrefs.SetInt(GameConstants.PrivacyPolicyPrefKey, 1);
PlayerPrefs.Save();
// Hide the panel
PrivacyPolicyPanel.DOFade(0, 0.5f).OnComplete(() =>
{
PrivacyPolicyPanel.gameObject.SetActive(false);
});
}
public void StartGame()
{
Debug.Log("StartGame0");
loadingSlider.gameObject.SetActive(true);
loadingSlider.DOValue(100f, 2.5f).OnComplete(() =>
{
Debug.Log("StartGame1");
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex + 1);
Debug.Log("StartGame2");
});
}
public void OnPrivacyPolicyClicked()
{
Application.OpenURL(GameConstants.PrivacyPolicyLink);
}
}