using System; using System.Collections.Generic; using UnityEngine; using UnityEngine.SceneManagement; public class GameManager : D_MonoSingleton { //for debug public BlockManager CurrentPlayerBlockMgr; public BlockManager CurrentEnemyBlockMgr; public Camera CurrentGameCam; public int GameSpeed { get => mGameSpeed; set { mGameSpeed = value; Utils.SetGameSpeed(mGameSpeed); } } private int mGameSpeed = 1; protected override void Initialize() { #if USE_IAP IAPTool.Instance.OnPurchaseDone += OnPurchaseResult; IAPTool.Instance.OnRestoreDone += OnRestoreResult; #endif } protected override void Dispose() { #if USE_IAP IAPTool.Instance.OnPurchaseDone -= OnPurchaseResult; IAPTool.Instance.OnRestoreDone -= OnRestoreResult; #endif } private void OnPurchaseResult(string pID, bool pResult) { #if USE_IAP if (pID.Equals(IAPProducts.NoAds)) { if (pResult) { PlayerData.Instance.IsNoAds = true; } UIUtils.ShowTips(LanguageConfig.Instance.GetText(pResult ? "BuyNoAdsSucceed" : "BuyNoAdsFail")); } UIManager.Instance.CloseUI(); #endif } private void OnRestoreResult(bool pResult) { UIUtils.ShowTips(LanguageConfig.Instance.GetText(pResult ? "RestoreSucceed" : "RestoreFail")); } public void LoadGame() { GameSpeed = 1; TimerManager.Instance.ClearAll(); SceneManager.LoadScene("Game"); } }