上传文件至「/」
This commit is contained in:
+1113
File diff suppressed because it is too large
Load Diff
+792
@@ -0,0 +1,792 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using DG.Tweening;
|
||||
using Monetization.Runtime.Ads;
|
||||
using MoreMountains.NiceVibrations;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class GameManager : Singleton<GameManager>
|
||||
{
|
||||
public PhysicsMaterial2D lineDrawPhysics2dMat;
|
||||
|
||||
public EnvironmentClass[] environmentSkinsList;
|
||||
|
||||
public static Action OnGameStarts;
|
||||
|
||||
public static Action OnStoreClosed;
|
||||
|
||||
public static Action OnLevelComplete;
|
||||
|
||||
public static Action<int> OnNewEnemyUnlocked;
|
||||
|
||||
public static Action OnGameComplete;
|
||||
|
||||
public static Action OnLevelFailed;
|
||||
|
||||
public static Action OnNoInternetAvailable;
|
||||
|
||||
public static Action OnLineDrawingStarts;
|
||||
|
||||
public static Action OnLineDrawingComplete;
|
||||
|
||||
public static Action OnEnemyHit;
|
||||
|
||||
public static Action OnPointDraw;
|
||||
|
||||
public static Action OnHintShowCalled;
|
||||
|
||||
public static Action<bool> OnHintHideCalled;
|
||||
|
||||
public static Action<int, Vector3, Action> OnCoinGrant;
|
||||
|
||||
public static List<Enemy> EnemyList = new List<Enemy>();
|
||||
|
||||
public static List<Friend> FriendList = new List<Friend>();
|
||||
|
||||
public static Action<bool> OnMusicToggle;
|
||||
|
||||
public static Action<bool> OnSoundAudioToggle;
|
||||
|
||||
public static Action OnLevelReload;
|
||||
|
||||
public static Action<int> OnShopItemSelection;
|
||||
|
||||
public static Action<int> OnEnvironmentChange;
|
||||
|
||||
public Image flashScreenPanel;
|
||||
|
||||
public Image bloodFadeOverlay;
|
||||
|
||||
private bool isInit;
|
||||
|
||||
public Button[] gameplayUiBtns;
|
||||
|
||||
public Button skinBtn;
|
||||
|
||||
public GameObject lineParentTr;
|
||||
|
||||
[Header("UI Slide Out Animation")]
|
||||
public RectTransform[] leftSideUI;
|
||||
|
||||
public RectTransform[] rightSideUI;
|
||||
|
||||
public RectTransform levelNumBar;
|
||||
|
||||
public GameObject happyEmojis;
|
||||
|
||||
public GameObject sadEmojis;
|
||||
|
||||
public Button hintBtn;
|
||||
|
||||
public GameObject hintRewardedIcon;
|
||||
|
||||
public GameObject noOfHintsObj;
|
||||
|
||||
public Text noOfHintsText;
|
||||
|
||||
public CanvasGroup hintGlowCanvasGroup;
|
||||
|
||||
public ParticleSystem hintSparkleParticles;
|
||||
|
||||
[Header("Splash Canvas (shown before interstitial ad)")]
|
||||
public GameObject splashCanvas;
|
||||
|
||||
[Header("Confetti Win GO (Is_PanelTest == 3)")]
|
||||
public GameObject confettiOnWin;
|
||||
|
||||
public static bool isGamePlayedOnce = false;
|
||||
|
||||
public static bool anyFriendDied = false;
|
||||
|
||||
private bool isEmojiSpawned;
|
||||
|
||||
public GameObject storePanelObj;
|
||||
|
||||
private bool rewardedHintVideoClicked;
|
||||
|
||||
private Color _hintGlowBaseColor;
|
||||
|
||||
private bool _hintGlowColorCached;
|
||||
|
||||
private bool isLevelFailed;
|
||||
|
||||
private bool isLevelCompleted;
|
||||
|
||||
private bool isShowingPopUp;
|
||||
|
||||
private static int lastFailedLevelNum_PanelTest4 = -1;
|
||||
|
||||
private static int _failAttemptLevel = -1;
|
||||
|
||||
private static int _failAttemptCount = 0;
|
||||
|
||||
public bool IsGameEnded => isLevelFailed || isLevelCompleted;
|
||||
|
||||
public static int FreeHintsUsed
|
||||
{
|
||||
get
|
||||
{
|
||||
if (PlayerPrefs.GetInt("FirstHintFree", 0) == 1 && PlayerPrefs.GetInt("FreeHintsMigrated", 0) == 0)
|
||||
{
|
||||
PlayerPrefs.SetInt("FreeHintsUsed", Mathf.Max(PlayerPrefs.GetInt("FreeHintsUsed", 0), 1));
|
||||
PlayerPrefs.SetInt("FreeHintsMigrated", 1);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
return PlayerPrefs.GetInt("FreeHintsUsed", 0);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool FreeHintsRemaining => FreeHintsUsed < AdConstants.free_hints_count + BonusFreeHints;
|
||||
|
||||
public static int BonusFreeHints
|
||||
{
|
||||
get
|
||||
{
|
||||
return PlayerPrefs.GetInt("BonusFreeHints", 0);
|
||||
}
|
||||
set
|
||||
{
|
||||
PlayerPrefs.SetInt("BonusFreeHints", value);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
if (!AdConstants.AdsRemoved && (AdConstants.Is_PanelTest == 2 || AdConstants.Is_PanelTest == 3 || AdConstants.Is_PanelTest == 4))
|
||||
{
|
||||
AdsManager.HideMRec();
|
||||
if (UiManager.Instance != null)
|
||||
{
|
||||
UiManager.Instance.BannerPati.SetActive(true);
|
||||
}
|
||||
}
|
||||
InitGame();
|
||||
}
|
||||
|
||||
private void InitGame()
|
||||
{
|
||||
if (isInit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
print("Game Started");
|
||||
AppConstants.IsDialogueOpened = false;
|
||||
if (PlayerPrefs.GetInt("CurrentZoneLevel" + AppConstants.currentCharacterIndex) == 0)
|
||||
{
|
||||
PlayerPrefs.SetInt("CurrentZoneLevel" + AppConstants.currentCharacterIndex, 1);
|
||||
}
|
||||
anyFriendDied = false;
|
||||
isLevelFailed = false;
|
||||
isLevelCompleted = false;
|
||||
if (hintBtn != null && PlayerPrefs.GetInt("HintBtnUnlocked", 0) == 0)
|
||||
{
|
||||
hintBtn.gameObject.SetActive(false);
|
||||
}
|
||||
RefreshHintCounterDisplay();
|
||||
Invoke("StartGame", 0.1f);
|
||||
if (isGamePlayedOnce)
|
||||
{
|
||||
if (PlayerPrefs.GetInt("IsRated") == 0 && !AppConstants.isRetryingLevel && Array.IndexOf(AppConstants.RatePanelLevels, PersistableData.Instance.itemsData.currentLevelNumProgressive) >= 0)
|
||||
{
|
||||
UiManager.Instance.ShowRatePopUp();
|
||||
}
|
||||
if (PersistableData.Instance.itemsData.currentLevelNumProgressive % AppConstants.ShowNewSkinAtLevel != 0 && LevelManager.currentLevel == 6 && PlayerPrefs.GetInt("CurrentLevelNum") == 5 && PlayerPrefs.GetInt("ShopIndicationShown") == 0)
|
||||
{
|
||||
PlayerPrefs.SetInt("ShopIndicationShown", 1);
|
||||
Invoke("OpenShopStoreWithTutorialPanel", 0.5f);
|
||||
}
|
||||
}
|
||||
isInit = true;
|
||||
}
|
||||
|
||||
private void OpenShopStoreWithTutorialPanel()
|
||||
{
|
||||
SoundManager soundManager = SoundManager.instance;
|
||||
if (soundManager != null && soundManager.gameSoundSFX != null)
|
||||
{
|
||||
soundManager.PlaySFX_UI(soundManager.gameSoundSFX.TutorialScreenAppear, 1f);
|
||||
}
|
||||
storePanelObj.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
OnLineDrawingStarts += OnHideGameUi;
|
||||
OnEnemyHit += OnEnemyHitEffect;
|
||||
OnGameComplete += OnGameCompletion;
|
||||
OnLineDrawingComplete += CheckFriendOnlyLevel;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
OnLineDrawingStarts -= OnHideGameUi;
|
||||
OnGameComplete -= OnGameCompletion;
|
||||
OnEnemyHit -= OnEnemyHitEffect;
|
||||
OnLineDrawingComplete -= CheckFriendOnlyLevel;
|
||||
}
|
||||
|
||||
public void SpawnEmoji(GameObject emojiPrefab)
|
||||
{
|
||||
if (!isEmojiSpawned)
|
||||
{
|
||||
Instantiate(emojiPrefab);
|
||||
isEmojiSpawned = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckFriendOnlyLevel()
|
||||
{
|
||||
if (LevelScript.Instance == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!LevelScript.Instance.isFriendLevel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (EnemyList.Count != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (FriendList.Count < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Invoke("TryCompleteFriendOnlyLevel", LevelScript.Instance.friendOnlyCompleteDelay);
|
||||
}
|
||||
|
||||
private void TryCompleteFriendOnlyLevel()
|
||||
{
|
||||
if (!isLevelFailed && !isLevelCompleted && !anyFriendDied)
|
||||
{
|
||||
CheckLevelComplete();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnEnemyHitEffect()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void StartGame()
|
||||
{
|
||||
OnGameStarts?.Invoke();
|
||||
}
|
||||
|
||||
public void IsObjectDropCompleted()
|
||||
{
|
||||
AppConstants.Haptic(HapticTypes.LightImpact);
|
||||
Invoke("changeAction", 1.5f);
|
||||
}
|
||||
|
||||
private void changeAction()
|
||||
{
|
||||
if (CharacterAction.EnemyAction != null)
|
||||
{
|
||||
CharacterAction.EnemyAction(3);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowHint()
|
||||
{
|
||||
if (rewardedHintVideoClicked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
UiManager.Instance.SettingPanelAnim.SetBool("SettingIn", false);
|
||||
UiManager.Instance.SettingPanelAnim.SetBool("SettingOut", true);
|
||||
UiManager.Instance.isSettingsOpen = false;
|
||||
if (FreeHintsRemaining)
|
||||
{
|
||||
int num = FreeHintsUsed + 1;
|
||||
PlayerPrefs.SetInt("FreeHintsUsed", num);
|
||||
PlayerPrefs.Save();
|
||||
LevelAnalytics.Send("Hint_Free_" + num);
|
||||
HintGranted();
|
||||
return;
|
||||
}
|
||||
LevelAnalytics.Send("Hint_Watch");
|
||||
|
||||
HintGranted();
|
||||
}
|
||||
|
||||
private void HintGranted()
|
||||
{
|
||||
if (isLevelCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AppConstants.Haptic(HapticTypes.Selection);
|
||||
SoundManager soundManager = SoundManager.instance;
|
||||
if (soundManager != null && soundManager.gameSoundSFX != null)
|
||||
{
|
||||
soundManager.PlaySFX_UI(soundManager.gameSoundSFX.hintShownSound, 1f);
|
||||
}
|
||||
OnHintShowCalled?.Invoke();
|
||||
hintBtn.transform.DOKill(false);
|
||||
hintBtn.transform.localScale = Vector3.one;
|
||||
StopHintGlowAnim();
|
||||
hintBtn.gameObject.SetActive(false);
|
||||
if (LevelManager.instance.hintTutorialObj != null)
|
||||
{
|
||||
LevelManager.instance.hintTutorialObj.SetActive(false);
|
||||
}
|
||||
if (hintRewardedIcon != null)
|
||||
{
|
||||
hintRewardedIcon.SetActive(true);
|
||||
}
|
||||
PlayerPrefs.SetInt("HintWatched_" + LevelManager.instance.currentLevelNumberToShow, 1);
|
||||
PlayerPrefs.Save();
|
||||
rewardedHintVideoClicked = false;
|
||||
}
|
||||
|
||||
private void ResetShowHintBtnClickAgain()
|
||||
{
|
||||
rewardedHintVideoClicked = false;
|
||||
}
|
||||
|
||||
public void ShowHintButton(bool playBreath = false)
|
||||
{
|
||||
hintBtn.gameObject.SetActive(true);
|
||||
hintBtn.transform.DOKill(false);
|
||||
hintBtn.transform.localScale = Vector3.one;
|
||||
bool freeHintsRemaining = FreeHintsRemaining;
|
||||
if (hintRewardedIcon != null)
|
||||
{
|
||||
hintRewardedIcon.SetActive(!freeHintsRemaining);
|
||||
}
|
||||
if (noOfHintsObj != null)
|
||||
{
|
||||
noOfHintsObj.SetActive(freeHintsRemaining);
|
||||
}
|
||||
if (noOfHintsText != null && freeHintsRemaining)
|
||||
{
|
||||
noOfHintsText.text = (BonusFreeHints + AdConstants.free_hints_count - FreeHintsUsed).ToString();
|
||||
}
|
||||
if (!freeHintsRemaining && playBreath)
|
||||
{
|
||||
StartHintBreathAnim();
|
||||
}
|
||||
else
|
||||
{
|
||||
StopHintGlowAnim();
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshHintCounterDisplay()
|
||||
{
|
||||
if (hintBtn == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
bool freeHintsRemaining = FreeHintsRemaining;
|
||||
if (hintRewardedIcon != null)
|
||||
{
|
||||
hintRewardedIcon.SetActive(!freeHintsRemaining);
|
||||
}
|
||||
if (noOfHintsObj != null)
|
||||
{
|
||||
noOfHintsObj.SetActive(freeHintsRemaining);
|
||||
}
|
||||
if (noOfHintsText != null && freeHintsRemaining)
|
||||
{
|
||||
noOfHintsText.text = (BonusFreeHints + AdConstants.free_hints_count - FreeHintsUsed).ToString();
|
||||
}
|
||||
}
|
||||
|
||||
private void StartHintBreathAnim()
|
||||
{
|
||||
if (hintGlowCanvasGroup == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hintGlowCanvasGroup.DOKill(false);
|
||||
hintGlowCanvasGroup.alpha = 1f;
|
||||
int step = 0;
|
||||
hintGlowCanvasGroup.DOFade(0f, 1f).SetLoops(-1, LoopType.Yoyo).SetEase(Ease.InOutSine)
|
||||
.OnStepComplete(delegate
|
||||
{
|
||||
step++;
|
||||
if (step % 2 == 0 && hintSparkleParticles != null)
|
||||
{
|
||||
hintSparkleParticles.Play();
|
||||
}
|
||||
});
|
||||
Image image = hintGlowCanvasGroup.GetComponent<Image>();
|
||||
if (image != null)
|
||||
{
|
||||
if (!_hintGlowColorCached)
|
||||
{
|
||||
_hintGlowBaseColor = image.color;
|
||||
_hintGlowColorCached = true;
|
||||
}
|
||||
image.DOKill(false);
|
||||
image.DOColor(new Color(Mathf.Min(_hintGlowBaseColor.r * 1.15f, 1f), Mathf.Min(_hintGlowBaseColor.g * 1.05f, 1f), Mathf.Min(_hintGlowBaseColor.b * 1.4f, 1f), _hintGlowBaseColor.a), 1f).SetLoops(-1, LoopType.Yoyo)
|
||||
.SetEase(Ease.InOutSine);
|
||||
}
|
||||
}
|
||||
|
||||
private void StopHintGlowAnim()
|
||||
{
|
||||
if (hintGlowCanvasGroup == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
hintGlowCanvasGroup.DOKill(false);
|
||||
hintGlowCanvasGroup.alpha = 1f;
|
||||
Image image = hintGlowCanvasGroup.GetComponent<Image>();
|
||||
if (image != null)
|
||||
{
|
||||
image.DOKill(false);
|
||||
if (_hintGlowColorCached)
|
||||
{
|
||||
image.color = _hintGlowBaseColor;
|
||||
}
|
||||
}
|
||||
if (hintSparkleParticles != null)
|
||||
{
|
||||
hintSparkleParticles.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowHintThroughCode()
|
||||
{
|
||||
OnHintShowCalled?.Invoke();
|
||||
hintBtn.transform.DOKill(false);
|
||||
hintBtn.transform.localScale = Vector3.one;
|
||||
StopHintGlowAnim();
|
||||
hintBtn.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnGameCompletion()
|
||||
{
|
||||
skinBtn.interactable = false;
|
||||
isLevelCompleted = true;
|
||||
}
|
||||
|
||||
private void OnHideGameUi()
|
||||
{
|
||||
for (int i = 0; i < leftSideUI.Length; i++)
|
||||
{
|
||||
RectTransform rt = leftSideUI[i];
|
||||
if (!(rt == null))
|
||||
{
|
||||
rt.DOAnchorPosX(rt.anchoredPosition.x + -500f, 0.5f).SetEase(Ease.InBack).OnComplete(delegate
|
||||
{
|
||||
rt.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
for (int j = 0; j < rightSideUI.Length; j++)
|
||||
{
|
||||
RectTransform rt2 = rightSideUI[j];
|
||||
if (!(rt2 == null))
|
||||
{
|
||||
rt2.DOAnchorPosX(rt2.anchoredPosition.x + 500f, 0.5f).SetEase(Ease.InBack).OnComplete(delegate
|
||||
{
|
||||
rt2.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
if (levelNumBar != null)
|
||||
{
|
||||
levelNumBar.DOAnchorPosY(levelNumBar.anchoredPosition.y + 500f, 0.5f).SetEase(Ease.InBack).OnComplete(delegate
|
||||
{
|
||||
levelNumBar.gameObject.SetActive(false);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckLevelFailed()
|
||||
{
|
||||
if (isLevelFailed || isLevelCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (EnemyList.Count < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AppConstants.isLevelFailedOnce = true;
|
||||
isLevelFailed = true;
|
||||
ShowLevelFailed();
|
||||
}
|
||||
|
||||
public void CheckLevelFailedFreind()
|
||||
{
|
||||
if (isLevelFailed)
|
||||
{
|
||||
return;
|
||||
}
|
||||
anyFriendDied = true;
|
||||
isLevelFailed = true;
|
||||
isLevelCompleted = true;
|
||||
CancelInvoke("ShowLevelCompleteScreen");
|
||||
CancelInvoke("ShowLevelComplete");
|
||||
Invoke("ShowLevelFailed", 0.5f);
|
||||
}
|
||||
|
||||
private void ShowLevelFailed()
|
||||
{
|
||||
OnLevelFailed?.Invoke();
|
||||
AppConstants.Haptic(HapticTypes.HeavyImpact);
|
||||
ShowLevelFailedScreen();
|
||||
if (SoundManager.instance != null)
|
||||
{
|
||||
SoundManager.instance.StopMusic();
|
||||
}
|
||||
}
|
||||
|
||||
private void ConfettiSound()
|
||||
{
|
||||
SoundManager soundManager = SoundManager.instance;
|
||||
if (soundManager != null && soundManager.gameSoundSFX != null)
|
||||
{
|
||||
soundManager.PlaySFX_UI(soundManager.gameSoundSFX.confettiSound, 1f);
|
||||
}
|
||||
Invoke("BGMUsic", 2f);
|
||||
}
|
||||
|
||||
private void BGMUsic()
|
||||
{
|
||||
SoundManager soundManager = SoundManager.instance;
|
||||
if (soundManager != null)
|
||||
{
|
||||
soundManager.ChangeMusicWithTransition(soundManager.mainMenuMusicClip);
|
||||
}
|
||||
}
|
||||
|
||||
public void CheckLevelComplete()
|
||||
{
|
||||
if (isLevelFailed || isLevelCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (anyFriendDied)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (EnemyList.Count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isLevelCompleted = true;
|
||||
OnLevelComplete?.Invoke();
|
||||
CancelInvoke("CheckLevelFailed");
|
||||
CancelInvoke("ShowLevelFailed");
|
||||
ShowLevelCompleteScreen();
|
||||
}
|
||||
|
||||
private void ShowLevelCompleteScreen()
|
||||
{
|
||||
if (isLevelFailed || anyFriendDied)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isGamePlayedOnce = true;
|
||||
OnGameComplete?.Invoke();
|
||||
CancelInvoke("CheckLevelFailed");
|
||||
CancelInvoke("ShowLevelFailed");
|
||||
SoundManager soundManager = SoundManager.instance;
|
||||
if (soundManager != null && soundManager.gameSoundSFX != null)
|
||||
{
|
||||
soundManager.PlaySFX_UI(soundManager.gameSoundSFX.winSfx, 1f);
|
||||
}
|
||||
ConfettiSound();
|
||||
ShowLevelComplete();
|
||||
}
|
||||
|
||||
private void ShowLevelComplete()
|
||||
{
|
||||
AppConstants.levelsSinceLastInterstitial++;
|
||||
LevelAnalytics.Send("Level_Comp_PT" + AdConstants.Is_PanelTest);
|
||||
AppConstants.Haptic(HapticTypes.HeavyImpact);
|
||||
if (LevelScript.Instance.levelType != LevelType.Pendulum && BeadDrawer.instance != null)
|
||||
{
|
||||
BeadDrawer.instance.SetLineStatic();
|
||||
}
|
||||
SoundManager.instance.StopMusic();
|
||||
if (AdConstants.Is_PanelTest == 3 || AdConstants.Is_PanelTest == 4)
|
||||
{
|
||||
if (confettiOnWin != null)
|
||||
{
|
||||
confettiOnWin.SetActive(true);
|
||||
}
|
||||
if (LevelManager.instance != null)
|
||||
{
|
||||
LevelManager.instance.SetupCompScreenConfettiTest();
|
||||
}
|
||||
return;
|
||||
}
|
||||
UiManager.Instance.LevelCompletePanel.gameObject.SetActive(true);
|
||||
if (!AdConstants.AdsRemoved && (AdConstants.Is_PanelTest == 2 || AdConstants.Is_PanelTest == 3) && AdConstants.ShowMrecOnPanels)
|
||||
{
|
||||
|
||||
AdsManager.HideBanner();
|
||||
if (UiManager.Instance != null)
|
||||
{
|
||||
UiManager.Instance.BannerPati.SetActive(false);
|
||||
}
|
||||
AdsManager.RepositionMRec(MRecPosition.Bottom);
|
||||
AdsManager.ShowMRec();
|
||||
}
|
||||
if (AdConstants.Is_PanelTest != 1)
|
||||
{
|
||||
LevelManager.instance.SetupCompScreenNoPanelTest();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowLevelFailedScreen()
|
||||
{
|
||||
LevelManager levelManager = LevelManager.instance;
|
||||
int currentLevelNumberToShow = levelManager.currentLevelNumberToShow;
|
||||
if (_failAttemptLevel != currentLevelNumberToShow)
|
||||
{
|
||||
_failAttemptLevel = currentLevelNumberToShow;
|
||||
_failAttemptCount = 0;
|
||||
}
|
||||
_failAttemptCount++;
|
||||
LevelAnalytics.Send("Level_Fail_PT" + AdConstants.Is_PanelTest, "Attempt_" + _failAttemptCount);
|
||||
if (AdConstants.Is_PanelTest == 4)
|
||||
{
|
||||
if (lastFailedLevelNum_PanelTest4 == LevelManager.instance.currentLevelNumberToShow)
|
||||
{
|
||||
SoundManager soundManager = SoundManager.instance;
|
||||
if (soundManager != null && soundManager.gameSoundSFX != null)
|
||||
{
|
||||
soundManager.PlaySFX_UI(soundManager.gameSoundSFX.looseSfx, 1f);
|
||||
}
|
||||
if (bloodFadeOverlay != null)
|
||||
{
|
||||
bloodFadeOverlay.gameObject.SetActive(true);
|
||||
Color color = bloodFadeOverlay.color;
|
||||
color.a = 0f;
|
||||
bloodFadeOverlay.color = color;
|
||||
bloodFadeOverlay.DOKill(false);
|
||||
bloodFadeOverlay.DOFade(0.8823529f, 1.5f).OnComplete(delegate
|
||||
{
|
||||
LevelManager.instance.ReloadLevelSilently();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
LevelManager.instance.ReloadLevelSilently();
|
||||
}
|
||||
return;
|
||||
}
|
||||
lastFailedLevelNum_PanelTest4 = LevelManager.instance.currentLevelNumberToShow;
|
||||
}
|
||||
if (LevelScript.Instance.levelType != LevelType.Pendulum && BeadDrawer.instance != null)
|
||||
{
|
||||
BeadDrawer.instance.SetLineStatic();
|
||||
}
|
||||
UiManager.Instance.LevelFailedPanel.gameObject.SetActive(true);
|
||||
if (!AdConstants.AdsRemoved && (AdConstants.Is_PanelTest == 2 || AdConstants.Is_PanelTest == 3 || AdConstants.Is_PanelTest == 4) && AdConstants.ShowMrecOnPanels)
|
||||
{
|
||||
|
||||
AdsManager.HideBanner();
|
||||
if (UiManager.Instance != null)
|
||||
{
|
||||
UiManager.Instance.BannerPati.SetActive(false);
|
||||
}
|
||||
AdsManager.RepositionMRec(MRecPosition.Bottom);
|
||||
AdsManager.ShowMRec();
|
||||
}
|
||||
if (UiManager.Instance.reloadBtnRect != null)
|
||||
{
|
||||
UiManager.Instance.reloadBtnRect.gameObject.SetActive(false);
|
||||
}
|
||||
SoundManager soundManager2 = SoundManager.instance;
|
||||
if (soundManager2 != null && soundManager2.gameSoundSFX != null)
|
||||
{
|
||||
soundManager2.PlaySFX_UI(soundManager2.gameSoundSFX.looseSfx, 1f);
|
||||
}
|
||||
PlayerPrefs.SetInt("EverFailed", 1);
|
||||
PlayerPrefs.Save();
|
||||
bool flag = LevelScript.Instance != null && LevelScript.Instance.isAutoHintLevel;
|
||||
UiManager.Instance.ShowFailButtons(flag);
|
||||
if (!flag)
|
||||
{
|
||||
PlayerPrefs.SetInt("HintBtnUnlocked", 1);
|
||||
PlayerPrefs.Save();
|
||||
if (PlayerPrefs.GetInt("HintWatched_" + LevelManager.instance.currentLevelNumberToShow, 0) != 1)
|
||||
{
|
||||
ShowHintButton(true);
|
||||
}
|
||||
}
|
||||
if (AdConstants.Is_PanelTest != 1)
|
||||
{
|
||||
LevelManager.instance.SetupFailScreenNoPanelTest();
|
||||
}
|
||||
Invoke("BGMUsic", 3f);
|
||||
}
|
||||
|
||||
public void WatchAdForHintsPanel()
|
||||
{
|
||||
LevelAnalytics.Send("HintsPanel_WatchAd");
|
||||
|
||||
OnHintsPanelRewardGranted();
|
||||
}
|
||||
|
||||
private void OnHintsPanelRewardGranted()
|
||||
{
|
||||
BonusFreeHints = BonusFreeHints + 3;
|
||||
LevelAnalytics.Send("HintsPanel_Rewarded");
|
||||
ShowHintButton(false);
|
||||
UiManager.Instance.CloseHintsPanel();
|
||||
}
|
||||
|
||||
public void ShowInterstitialTimer(string eventName, Action rewardCallBack = null)
|
||||
{
|
||||
if (PlayerPrefs.GetInt("FirstAdShown", 0) == 0)
|
||||
{
|
||||
PlayerPrefs.SetInt("FirstAdShown", 1);
|
||||
PlayerPrefs.Save();
|
||||
if (UiManager.Instance != null)
|
||||
{
|
||||
UiManager.Instance.ShowRemoveAdsBtn();
|
||||
}
|
||||
}
|
||||
else if (AdConstants.Int_Level_Gap >= 1 && AppConstants.levelsSinceLastInterstitial < AdConstants.Int_Level_Gap)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (splashCanvas != null)
|
||||
{
|
||||
splashCanvas.SetActive(true);
|
||||
}
|
||||
AdsTimerAndCallBack.Instance.SetInterstitialFirstAdsWatchedStatus(GameType.DrawToCrash);
|
||||
if (LevelManager.instance != null)
|
||||
{
|
||||
AppConstants.lastIntAdShownLevel = LevelManager.instance.currentLevelNumberToShow;
|
||||
}
|
||||
LevelAnalytics.IntAdBefore(eventName);
|
||||
|
||||
AppConstants.levelsSinceLastInterstitial = 0;
|
||||
LevelAnalytics.IntAdAfter();
|
||||
if (rewardCallBack != null)
|
||||
{
|
||||
rewardCallBack();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ShouldShowAd()
|
||||
{
|
||||
if (AdConstants.AdsRemoved)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (PlayerPrefs.GetInt("FirstAdShown", 0) != 0)
|
||||
{
|
||||
return AdsTimerAndCallBack.Instance.ShouldShowAd(AdsTimerAndCallBack.Instance.gametype);
|
||||
}
|
||||
if (LevelManager.instance != null)
|
||||
{
|
||||
return LevelManager.instance.currentLevelNumberToShow >= AdConstants.first_interstitial_level;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
+512
@@ -0,0 +1,512 @@
|
||||
using Monetization.Runtime.Ads;
|
||||
using MoreMountains.NiceVibrations;
|
||||
using PimDeWitte.UnityMainThreadDispatcher;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LevelManager : MonoBehaviour
|
||||
{
|
||||
public static LevelManager instance;
|
||||
|
||||
public string levelPrefix = "Lv";
|
||||
|
||||
private GameObject currentLevelPrefab;
|
||||
|
||||
public static int currentLevel = 1;
|
||||
|
||||
[SerializeField]
|
||||
private int maxLevels;
|
||||
|
||||
public int currentLevelNumberToShow = 1;
|
||||
|
||||
public Transform noThanksCoinPosTr;
|
||||
|
||||
public Transform GetDoubleRewardCoinTr;
|
||||
|
||||
private float rewardMultiplierCounter = 20f;
|
||||
|
||||
public Text rewardMultiplierText;
|
||||
|
||||
public int currentLevelCoinsEarned = 50;
|
||||
|
||||
public GameObject hintTutorialObj;
|
||||
|
||||
private static int lastHintsPanelShownLevel = -1;
|
||||
|
||||
[Header("No Panel Test — Button Refs")]
|
||||
public GameObject noThanksBtn_Comp;
|
||||
|
||||
public GameObject retryBtn_Comp;
|
||||
|
||||
public GameObject skipBtn_Fail;
|
||||
|
||||
public GameObject retryBtn_Fail;
|
||||
|
||||
public Animator meterArrowAnimator;
|
||||
|
||||
private bool rewardedGetDoubleVideoClicked;
|
||||
|
||||
private bool rewardedVideoClicked;
|
||||
|
||||
private bool isBtnClicked;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
instance = this;
|
||||
}
|
||||
|
||||
public void UpdateRewardMultiplier(int rewardMultiplier)
|
||||
{
|
||||
if (rewardMultiplierText)
|
||||
{
|
||||
rewardMultiplierText.text = rewardMultiplier.ToString("F0");
|
||||
}
|
||||
rewardMultiplierCounter = rewardMultiplier;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
currentLevelNumberToShow = PersistableData.Instance.itemsData.currentLevelNumProgressive;
|
||||
if (FirebaseInitialize.RemoteLevelOrder != null && FirebaseInitialize.RemoteLevelOrder.Count > 0)
|
||||
{
|
||||
currentLevel = FirebaseInitialize.RemoteLevelOrder[(currentLevelNumberToShow - 1) % FirebaseInitialize.RemoteLevelOrder.Count];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLevel++;
|
||||
if (currentLevel > maxLevels)
|
||||
{
|
||||
currentLevel = Random.Range(1, maxLevels + 1);
|
||||
}
|
||||
}
|
||||
Resources.UnloadUnusedAssets();
|
||||
SpawnLevel(currentLevel);
|
||||
if (FirebaseInitialize.AutoHintListLoaded && LevelScript.Instance != null)
|
||||
{
|
||||
LevelScript.Instance.isAutoHintLevel = FirebaseInitialize.AutoHintLevels.Contains(currentLevel);
|
||||
}
|
||||
if (currentLevelNumberToShow > maxLevels && currentLevel != 7 && currentLevel != 10)
|
||||
{
|
||||
Random.Range(0, 7);
|
||||
}
|
||||
if ((LevelScript.Instance != null && LevelScript.Instance.isAutoHintLevel) || (AppConstants.isRetryingLevel && PlayerPrefs.GetInt("HintWatched_" + currentLevelNumberToShow) == 1))
|
||||
{
|
||||
GameManager.Instance.ShowHintThroughCode();
|
||||
}
|
||||
bool flag = AppConstants.isRetryingAfterFail;
|
||||
bool flag2 = LevelScript.Instance != null && LevelScript.Instance.isAutoHintLevel;
|
||||
if (flag2 || !AppConstants.isRetryingAfterFail)
|
||||
{
|
||||
if (hintTutorialObj != null)
|
||||
{
|
||||
hintTutorialObj.SetActive(false);
|
||||
}
|
||||
}
|
||||
else if (hintTutorialObj != null)
|
||||
{
|
||||
hintTutorialObj.SetActive(GameManager.FreeHintsRemaining);
|
||||
}
|
||||
AppConstants.isRetryingAfterFail = false;
|
||||
if (PlayerPrefs.GetInt("EverFailed", 0) == 1)
|
||||
{
|
||||
UiManager.Instance.ShowFailButtons(flag2);
|
||||
}
|
||||
int num = PlayerPrefs.GetInt("HintWatched_" + currentLevelNumberToShow, 0);
|
||||
int num2 = PlayerPrefs.GetInt("HintBtnUnlocked", 0);
|
||||
if (num != 1 && !flag2 && num2 == 1)
|
||||
{
|
||||
GameManager.Instance.ShowHintButton(flag && !GameManager.FreeHintsRemaining);
|
||||
}
|
||||
LevelManager.instance.currentLevelCoinsEarned = 0;
|
||||
if (AppConstants.shouldShowRemoveAdsOnStart)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = false;
|
||||
AppConstants.removeAdsPanelFromLevelFlow = true;
|
||||
Invoke("ShowRemoveAdsPanelFirstTime", 0.5f);
|
||||
}
|
||||
else if (!AdConstants.AdsRemoved && !AppConstants.isRetryingLevel && System.Array.IndexOf(AppConstants.RemoveAdsPanelLevels, currentLevelNumberToShow) >= 0 && AppConstants.lastIntAdShownLevel == currentLevelNumberToShow - 1)
|
||||
{
|
||||
Invoke("ShowRemoveAdsPanelFromList", 0.5f);
|
||||
}
|
||||
if (flag && !flag2 && num != 1 && !GameManager.FreeHintsRemaining && lastHintsPanelShownLevel != currentLevelNumberToShow && System.Array.IndexOf(AppConstants.HintsPanelLevels, currentLevelNumberToShow) >= 0)
|
||||
{
|
||||
lastHintsPanelShownLevel = currentLevelNumberToShow;
|
||||
Invoke("ShowHintsPanelFromList", 0.5f);
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowRemoveAdsPanelFromList()
|
||||
{
|
||||
UiManager.Instance.ShowRemoveAdPanelAtLevel();
|
||||
}
|
||||
|
||||
private void ShowHintsPanelFromList()
|
||||
{
|
||||
UiManager.Instance.OpenHintsPanel();
|
||||
}
|
||||
|
||||
private void ShowRemoveAdsPanelFirstTime()
|
||||
{
|
||||
UiManager.Instance.ShowRemoveAdPanelFromFlow();
|
||||
}
|
||||
|
||||
private void SpawnLevel(int levelNumber)
|
||||
{
|
||||
if (levelNumber > maxLevels)
|
||||
{
|
||||
Debug.Log("All levels completed!");
|
||||
return;
|
||||
}
|
||||
string levelName = levelPrefix + currentLevel;
|
||||
GameObject gameObject = Resources.Load<GameObject>("Levels/" + levelName);
|
||||
if (gameObject == null)
|
||||
{
|
||||
Debug.Log("Level prefab not found: " + levelName);
|
||||
return;
|
||||
}
|
||||
if (currentLevelPrefab != null)
|
||||
{
|
||||
Destroy(currentLevelPrefab);
|
||||
}
|
||||
LevelAnalytics.Send(new string[1] { "Start" });
|
||||
currentLevelPrefab = Instantiate(gameObject);
|
||||
currentLevelPrefab.name = levelName;
|
||||
}
|
||||
|
||||
private void LoadNextLevel()
|
||||
{
|
||||
if (FirebaseInitialize.RemoteLevelOrder != null && FirebaseInitialize.RemoteLevelOrder.Count > 0)
|
||||
{
|
||||
currentLevel = FirebaseInitialize.RemoteLevelOrder[PersistableData.Instance.itemsData.currentLevelNumProgressive % FirebaseInitialize.RemoteLevelOrder.Count];
|
||||
}
|
||||
else
|
||||
{
|
||||
currentLevel++;
|
||||
if (currentLevel > maxLevels)
|
||||
{
|
||||
currentLevel = Random.Range(1, maxLevels + 1);
|
||||
}
|
||||
}
|
||||
AppConstants.isRetryingAfterFail = false;
|
||||
AppConstants.isRetryingLevel = false;
|
||||
PlayerPrefs.DeleteKey("HintWatched_" + currentLevelNumberToShow);
|
||||
PersistableData.Instance.IncreaseLevelNumber(currentLevel);
|
||||
SoundManager.instance.StopSoundFxSource();
|
||||
FadeSceneLoader.instance.LoadScene("Gameplay");
|
||||
}
|
||||
|
||||
private void ResetClaimDoubleCoinsClickAgain()
|
||||
{
|
||||
rewardedGetDoubleVideoClicked = false;
|
||||
}
|
||||
|
||||
private void DoubleRewardGranted()
|
||||
{
|
||||
UnityMainThreadDispatcher.Instance().Enqueue(delegate
|
||||
{
|
||||
rewardedGetDoubleVideoClicked = false;
|
||||
AppConstants.Haptic(HapticTypes.MediumImpact);
|
||||
SoundManager.instance.PlaySFX_UI(SoundManager.instance.gameSoundSFX.buttonClickSfx, 1f);
|
||||
if (isBtnClicked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isBtnClicked = true;
|
||||
GameManager.OnCoinGrant((int)rewardMultiplierCounter, GetDoubleRewardCoinTr.position, delegate
|
||||
{
|
||||
Invoke("LoadNextLevel", 0.1f);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public void SkipLevelLvlFailed()
|
||||
{
|
||||
LevelAnalytics.Send(new string[2]
|
||||
{
|
||||
"Level_Fail_PT" + AdConstants.Is_PanelTest,
|
||||
"Skip_Level"
|
||||
});
|
||||
|
||||
SkipLevelGranted();
|
||||
}
|
||||
|
||||
public void SkipLevelGameplay()
|
||||
{
|
||||
UiManager.Instance.SettingPanelAnim.SetBool("SettingIn", false);
|
||||
UiManager.Instance.SettingPanelAnim.SetBool("SettingOut", true);
|
||||
UiManager.Instance.isSettingsOpen = false;
|
||||
LevelAnalytics.Send(new string[1] { "Skip_Level" });
|
||||
|
||||
SkipLevelGranted();
|
||||
}
|
||||
|
||||
private void SkipLevelGranted()
|
||||
{
|
||||
if (isBtnClicked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isBtnClicked = true;
|
||||
AppConstants.Haptic(HapticTypes.MediumImpact);
|
||||
LoadNextLevel();
|
||||
rewardedVideoClicked = false;
|
||||
}
|
||||
|
||||
private void ResetSkipLevelClickAgain()
|
||||
{
|
||||
rewardedVideoClicked = false;
|
||||
}
|
||||
|
||||
public void NoThanksGetDefaultCoins()
|
||||
{
|
||||
AppConstants.Haptic(HapticTypes.MediumImpact);
|
||||
SoundManager.instance.PlaySFX_UI(SoundManager.instance.gameSoundSFX.buttonClickSfx, 1f);
|
||||
if (isBtnClicked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isBtnClicked = true;
|
||||
if (AdsManager.HasInterstitialFixed() && !AdConstants.AdsRemoved && GameManager.Instance.ShouldShowAd())
|
||||
{
|
||||
if (AdConstants.EnableRemoveAdsFlow && PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 0)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.ShowInterstitialTimer("Comp_Next", LoadNextLevel);
|
||||
Invoke("LoadNextLevel", 1f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
LoadNextLevel();
|
||||
}
|
||||
|
||||
public void ReloadLevelGameplay()
|
||||
{
|
||||
SoundManager.instance.StopSoundFxSource();
|
||||
SoundManager.instance.StopMusic();
|
||||
GameManager.OnLevelReload?.Invoke();
|
||||
AppConstants.isRetryingLevel = true;
|
||||
LevelAnalytics.Send(new string[1] { "In_Game_Replay_Btn" });
|
||||
ReloadLevel();
|
||||
}
|
||||
|
||||
public void RetryLevelFailScreen()
|
||||
{
|
||||
AppConstants.isRetryingAfterFail = LevelScript.Instance == null || !LevelScript.Instance.isAutoHintLevel;
|
||||
AppConstants.isRetryingLevel = true;
|
||||
if (AdConstants.show_interstitial_on_fail && AdsManager.HasInterstitialFixed() && !AdConstants.AdsRemoved && GameManager.Instance.ShouldShowAd())
|
||||
{
|
||||
if (AdConstants.EnableRemoveAdsFlow && PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 0)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.ShowInterstitialTimer("Fail_Retry", ReloadLevel);
|
||||
Invoke("ReloadLevel", 1f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ReloadLevel();
|
||||
}
|
||||
|
||||
public void RetryLevelCompScreen()
|
||||
{
|
||||
AppConstants.isRetryingLevel = true;
|
||||
AppConstants.isRetryingAfterFail = false;
|
||||
LevelAnalytics.Send(new string[2]
|
||||
{
|
||||
"Level_Comp_PT" + AdConstants.Is_PanelTest,
|
||||
"Try_Again"
|
||||
});
|
||||
if (AdsManager.HasInterstitialFixed() && !AdConstants.AdsRemoved && GameManager.Instance.ShouldShowAd())
|
||||
{
|
||||
if (AdConstants.EnableRemoveAdsFlow && PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 0)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
GameManager.Instance.ShowInterstitialTimer("Comp_Retry", ReloadLevel);
|
||||
Invoke("ReloadLevel", 1f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
ReloadLevel();
|
||||
}
|
||||
|
||||
private void ReloadLevel()
|
||||
{
|
||||
if (!AdConstants.AdsRemoved && (AdConstants.Is_PanelTest == 2 || AdConstants.Is_PanelTest == 3 || AdConstants.Is_PanelTest == 4))
|
||||
{
|
||||
|
||||
AdsManager.HideMRec();
|
||||
UiManager.Instance.BannerPati.SetActive(true);
|
||||
}
|
||||
AppConstants.Haptic(HapticTypes.MediumImpact);
|
||||
SoundManager.instance.PlaySFX_UI(SoundManager.instance.gameSoundSFX.buttonClickSfx, 1f);
|
||||
if (isBtnClicked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isBtnClicked = true;
|
||||
SoundManager.instance.StopSoundFxSource();
|
||||
FadeSceneLoader.instance.LoadScene("Gameplay");
|
||||
}
|
||||
|
||||
public void ReloadLevelSilently()
|
||||
{
|
||||
if (isBtnClicked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isBtnClicked = true;
|
||||
AppConstants.isRetryingAfterFail = LevelScript.Instance == null || !LevelScript.Instance.isAutoHintLevel;
|
||||
AppConstants.isRetryingLevel = true;
|
||||
if (!AdConstants.AdsRemoved)
|
||||
{
|
||||
|
||||
AdsManager.HideMRec();
|
||||
UiManager.Instance.BannerPati.SetActive(true);
|
||||
}
|
||||
FadeSceneLoader.instance.LoadScene("Gameplay");
|
||||
}
|
||||
|
||||
public void SetupFailScreenNoPanelTest()
|
||||
{
|
||||
if (skipBtn_Fail != null)
|
||||
{
|
||||
skipBtn_Fail.SetActive(false);
|
||||
}
|
||||
if (retryBtn_Fail != null)
|
||||
{
|
||||
retryBtn_Fail.SetActive(false);
|
||||
}
|
||||
if (UiManager.Instance.reloadBtnRect != null)
|
||||
{
|
||||
UiManager.Instance.reloadBtnRect.gameObject.SetActive(false);
|
||||
}
|
||||
Invoke("AutoRetryAfterFail_NoPanel", 1.5f);
|
||||
}
|
||||
|
||||
private void AutoRetryAfterFail_NoPanel()
|
||||
{
|
||||
if (!AdConstants.AdsRemoved)
|
||||
{
|
||||
|
||||
AdsManager.HideMRec();
|
||||
AdsManager.ShowBanner();
|
||||
}
|
||||
bool flag = LevelScript.Instance != null && LevelScript.Instance.isAutoHintLevel;
|
||||
AppConstants.isRetryingAfterFail = !flag;
|
||||
AppConstants.isRetryingLevel = true;
|
||||
LevelAnalytics.Send(new string[2]
|
||||
{
|
||||
"Level_Fail_PT" + AdConstants.Is_PanelTest,
|
||||
"Auto_Retry"
|
||||
});
|
||||
if (AdConstants.show_interstitial_on_fail && AdsManager.HasInterstitialFixed() && !AdConstants.AdsRemoved && GameManager.Instance.ShouldShowAd())
|
||||
{
|
||||
if (AdConstants.EnableRemoveAdsFlow && PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 0)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
UiManager.Instance.LevelFailedPanel.gameObject.SetActive(false);
|
||||
SoundManager.instance.StopSoundFxSource();
|
||||
GameManager.Instance.ShowInterstitialTimer("Fail_AutoRetry_NoPanel", null);
|
||||
}
|
||||
}
|
||||
if (!AdConstants.AdsRemoved)
|
||||
{
|
||||
|
||||
AdsManager.HideMRec();
|
||||
AdsManager.ShowBanner();
|
||||
}
|
||||
ReloadLevel();
|
||||
}
|
||||
|
||||
public void SetupCompScreenConfettiTest()
|
||||
{
|
||||
if (UiManager.Instance.reloadBtnRect != null)
|
||||
{
|
||||
UiManager.Instance.reloadBtnRect.gameObject.SetActive(false);
|
||||
}
|
||||
Invoke("AutoNextAfterComp_ConfettiTest", 1.5f);
|
||||
}
|
||||
|
||||
private void AutoNextAfterComp_ConfettiTest()
|
||||
{
|
||||
LevelAnalytics.Send(new string[2]
|
||||
{
|
||||
"Level_Comp_PT" + AdConstants.Is_PanelTest,
|
||||
"Confetti_AutoContinue"
|
||||
});
|
||||
if (AdsManager.HasInterstitialFixed() && !AdConstants.AdsRemoved && GameManager.Instance.ShouldShowAd())
|
||||
{
|
||||
if (AdConstants.EnableRemoveAdsFlow && PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 0)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (GameManager.Instance.confettiOnWin != null)
|
||||
{
|
||||
GameManager.Instance.confettiOnWin.SetActive(false);
|
||||
}
|
||||
SoundManager.instance.StopSoundFxSource();
|
||||
GameManager.Instance.ShowInterstitialTimer("Comp_Confetti_AutoNext", null);
|
||||
}
|
||||
}
|
||||
LoadNextLevel();
|
||||
}
|
||||
|
||||
public void SetupCompScreenNoPanelTest()
|
||||
{
|
||||
if (noThanksBtn_Comp != null)
|
||||
{
|
||||
noThanksBtn_Comp.SetActive(false);
|
||||
}
|
||||
if (retryBtn_Comp != null)
|
||||
{
|
||||
retryBtn_Comp.SetActive(false);
|
||||
}
|
||||
if (UiManager.Instance.reloadBtnRect != null)
|
||||
{
|
||||
UiManager.Instance.reloadBtnRect.gameObject.SetActive(false);
|
||||
}
|
||||
Invoke("AutoNextAfterComp_NoPanel", 1.5f);
|
||||
}
|
||||
|
||||
private void AutoNextAfterComp_NoPanel()
|
||||
{
|
||||
LevelAnalytics.Send(new string[2]
|
||||
{
|
||||
"Level_Comp_PT" + AdConstants.Is_PanelTest,
|
||||
"NoPanel_AutoContinue"
|
||||
});
|
||||
if (AdsManager.HasInterstitialFixed() && !AdConstants.AdsRemoved && GameManager.Instance.ShouldShowAd())
|
||||
{
|
||||
if (AdConstants.EnableRemoveAdsFlow && PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 0)
|
||||
{
|
||||
AppConstants.shouldShowRemoveAdsOnStart = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
UiManager.Instance.LevelCompletePanel.gameObject.SetActive(false);
|
||||
SoundManager.instance.StopSoundFxSource();
|
||||
GameManager.Instance.ShowInterstitialTimer("Comp_AutoNext_NoPanel", null);
|
||||
}
|
||||
}
|
||||
if (!AdConstants.AdsRemoved)
|
||||
{
|
||||
|
||||
AdsManager.HideMRec();
|
||||
AdsManager.ShowBanner();
|
||||
}
|
||||
LoadNextLevel();
|
||||
}
|
||||
}
|
||||
+357
@@ -0,0 +1,357 @@
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UiManager : Singleton<UiManager>
|
||||
{
|
||||
public Transform settingsPanel;
|
||||
|
||||
public Transform getCoinsPanel;
|
||||
|
||||
public Transform shopPanel;
|
||||
|
||||
public Transform newSkinUnlockPanel;
|
||||
|
||||
public Transform removeAdPanel;
|
||||
|
||||
public Transform noInternetAvailable;
|
||||
|
||||
public Transform ratePanel;
|
||||
|
||||
public Transform exitPanel;
|
||||
|
||||
public Transform hintsPanel;
|
||||
|
||||
public Transform LevelCompletePanel;
|
||||
|
||||
public Transform LevelFailedPanel;
|
||||
|
||||
public Text levelNumTextGameplay;
|
||||
|
||||
public Text levelNumTextGameover;
|
||||
|
||||
public Transform levelNumTag;
|
||||
|
||||
public Image currentBallImg;
|
||||
|
||||
public Animator SettingPanelAnim;
|
||||
|
||||
public GameObject RemoveAdsBtn;
|
||||
|
||||
public GameObject BannerPati;
|
||||
|
||||
private float currentBallInitialScale;
|
||||
|
||||
public bool isSettingsOpen;
|
||||
|
||||
[Header("Progressive UI Unlock")]
|
||||
public GameObject topUISkipLevelBtn;
|
||||
|
||||
public GameObject[] iconsUnlockedAfterAd;
|
||||
|
||||
[Header("Reload Button")]
|
||||
public RectTransform reloadBtnRect;
|
||||
|
||||
private Vector2 _reloadBtnHidePos;
|
||||
|
||||
private readonly Vector2 _reloadBtnShowPos = new Vector2(20f, -7f);
|
||||
|
||||
private bool isGameCompleted;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
|
||||
MonetizationServices.Ads.ShowBanner();
|
||||
if (RemoveAdsBtn != null)
|
||||
{
|
||||
RemoveAdsBtn.SetActive(false);
|
||||
}
|
||||
if (topUISkipLevelBtn != null)
|
||||
{
|
||||
topUISkipLevelBtn.SetActive(false);
|
||||
}
|
||||
for (int i = 0; i < iconsUnlockedAfterAd.Length; i++)
|
||||
{
|
||||
if (iconsUnlockedAfterAd[i] != null)
|
||||
{
|
||||
iconsUnlockedAfterAd[i].SetActive(false);
|
||||
}
|
||||
}
|
||||
if (PlayerPrefs.GetInt("FirstAdShown", 0) == 1)
|
||||
{
|
||||
ShowRemoveAdsBtn();
|
||||
}
|
||||
if (PlayerPrefs.GetInt("RemoveAdsPanelShown", 0) == 1)
|
||||
{
|
||||
ShowPostAdIcons();
|
||||
}
|
||||
if (AdConstants.AdsRemoved && RemoveAdsBtn != null)
|
||||
{
|
||||
RemoveAdsBtn.SetActive(false);
|
||||
}
|
||||
if (PlayerPrefs.GetInt("EverFailed", 0) == 1)
|
||||
{
|
||||
if (LevelScript.Instance != null)
|
||||
{
|
||||
ShowFailButtons(false);
|
||||
}
|
||||
}
|
||||
if (reloadBtnRect != null)
|
||||
{
|
||||
_reloadBtnHidePos = reloadBtnRect.anchoredPosition;
|
||||
reloadBtnRect.gameObject.SetActive(false);
|
||||
}
|
||||
Input.multiTouchEnabled = false;
|
||||
currentBallInitialScale = currentBallImg.transform.localScale.x;
|
||||
levelNumTag.localScale = Vector3.one;
|
||||
levelNumTextGameplay.text = "Level " + PersistableData.Instance.itemsData.currentLevelNumProgressive;
|
||||
levelNumTag.DOScale(0.5f, 1f);
|
||||
UpdateBallImgIcon(PersistableData.Instance.shopItemSprite[PersistableData.Instance.itemsData.currentShopItemId]);
|
||||
}
|
||||
|
||||
public void UpdateBallImgIcon(Sprite ballSprite)
|
||||
{
|
||||
currentBallImg.sprite = ballSprite;
|
||||
currentBallImg.transform.DOKill();
|
||||
currentBallImg.transform.localScale = Vector3.one * currentBallInitialScale;
|
||||
currentBallImg.transform.DOPunchScale(Vector3.one * currentBallInitialScale * 0.5f, 0.5f, 1, 1f).OnComplete(delegate
|
||||
{
|
||||
currentBallImg.transform.localScale = Vector3.one * currentBallInitialScale;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
GameManager.OnGameComplete += OnGameComplete;
|
||||
GameManager.OnLineDrawingStarts += OnLineDrawingStarts;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
GameManager.OnGameComplete -= OnGameComplete;
|
||||
GameManager.OnLineDrawingStarts -= OnLineDrawingStarts;
|
||||
}
|
||||
|
||||
private void OnGameComplete()
|
||||
{
|
||||
isGameCompleted = true;
|
||||
if (reloadBtnRect != null)
|
||||
{
|
||||
reloadBtnRect.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnLineDrawingStarts()
|
||||
{
|
||||
if (reloadBtnRect == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
reloadBtnRect.anchoredPosition = _reloadBtnHidePos;
|
||||
reloadBtnRect.gameObject.SetActive(true);
|
||||
reloadBtnRect.DOAnchorPos(_reloadBtnShowPos, 0.7f).SetEase(Ease.OutBack);
|
||||
}
|
||||
|
||||
public void OpenSettingsPanel()
|
||||
{
|
||||
if (isGameCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
isSettingsOpen = !isSettingsOpen;
|
||||
SettingPanelAnim.enabled = true;
|
||||
if (isSettingsOpen)
|
||||
{
|
||||
SettingPanelAnim.SetBool("SettingIn", true);
|
||||
SettingPanelAnim.SetBool("SettingOut", false);
|
||||
}
|
||||
else
|
||||
{
|
||||
SettingPanelAnim.SetBool("SettingIn", false);
|
||||
SettingPanelAnim.SetBool("SettingOut", true);
|
||||
}
|
||||
LevelAnalytics.Send(new string[] { "SettingPanel" });
|
||||
}
|
||||
|
||||
public void ShowRatePopUp()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
ratePanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void CloseRatePanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
ratePanel.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void OpenShopPanel()
|
||||
{
|
||||
if (isGameCompleted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
shopPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowRemoveAdPanelAtLevel()
|
||||
{
|
||||
if (PersistableData.Instance != null && PersistableData.Instance.itemsData.isRemoveAdPurchased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
AppConstants.removeAdsPanelFromLevelFlow = false;
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
removeAdPanel.gameObject.SetActive(true);
|
||||
LevelAnalytics.Send(new string[] { "RemoveAds_LevelShow" });
|
||||
}
|
||||
|
||||
public void ShowRemoveAdPanel()
|
||||
{
|
||||
SettingPanelAnim.SetBool("SettingIn", false);
|
||||
SettingPanelAnim.SetBool("SettingOut", true);
|
||||
isSettingsOpen = false;
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
removeAdPanel.gameObject.SetActive(true);
|
||||
if (PersistableData.Instance.itemsData.isRemoveAdPurchased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
LevelAnalytics.Send(new string[] { "RemoveAds_Screen" });
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
ShowExitPanel();
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowExitPanel()
|
||||
{
|
||||
SettingPanelAnim.SetBool("SettingIn", false);
|
||||
SettingPanelAnim.SetBool("SettingOut", true);
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
exitPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void CloseExitPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
exitPanel.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void CloseShopPanel()
|
||||
{
|
||||
shopPanel.gameObject.GetComponent<DialogueBaseClass>().ClosePanel();
|
||||
}
|
||||
|
||||
public void OpenNotEnoughCoinsPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
getCoinsPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void CloseNotEnoughCoinsPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
getCoinsPanel.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowNoInternetPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
noInternetAvailable.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void CloseNoInternetPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
noInternetAvailable.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void ShowNewSkinPopUp()
|
||||
{
|
||||
newSkinUnlockPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void ShowFailButtons(bool isAutoHintLevel)
|
||||
{
|
||||
if (topUISkipLevelBtn != null)
|
||||
{
|
||||
topUISkipLevelBtn.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowRemoveAdsBtn()
|
||||
{
|
||||
if (!AdConstants.AdsRemoved && RemoveAdsBtn != null)
|
||||
{
|
||||
RemoveAdsBtn.SetActive(true);
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowPostAdIcons()
|
||||
{
|
||||
if (!AdConstants.AdsRemoved && RemoveAdsBtn != null)
|
||||
{
|
||||
RemoveAdsBtn.SetActive(true);
|
||||
}
|
||||
for (int i = 0; i < iconsUnlockedAfterAd.Length; i++)
|
||||
{
|
||||
if (iconsUnlockedAfterAd[i] != null)
|
||||
{
|
||||
iconsUnlockedAfterAd[i].SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowRemoveAdPanelFromFlow()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
removeAdPanel.gameObject.SetActive(true);
|
||||
LevelAnalytics.Send(new string[] { "RemoveAds_FirstTime" });
|
||||
}
|
||||
|
||||
public void CloseRemoveAdPanel_NoThanks()
|
||||
{
|
||||
if (AppConstants.removeAdsPanelFromLevelFlow)
|
||||
{
|
||||
AppConstants.removeAdsPanelFromLevelFlow = false;
|
||||
PlayerPrefs.SetInt("RemoveAdsPanelShown", 1);
|
||||
PlayerPrefs.Save();
|
||||
LevelAnalytics.Send(new string[] { "RemoveAds_NoThanks" });
|
||||
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
removeAdPanel.gameObject.SetActive(false);
|
||||
ShowPostAdIcons();
|
||||
}
|
||||
else
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
removeAdPanel.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void CloseRemoveAdPanel_IAPSuccess()
|
||||
{
|
||||
AppConstants.removeAdsPanelFromLevelFlow = false;
|
||||
PlayerPrefs.SetInt("RemoveAdsPanelShown", 1);
|
||||
PlayerPrefs.Save();
|
||||
ShowPostAdIcons();
|
||||
}
|
||||
|
||||
public void OpenHintsPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = true;
|
||||
hintsPanel.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void CloseHintsPanel()
|
||||
{
|
||||
AppConstants.IsAnyPanelOpen = false;
|
||||
hintsPanel.gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user