NoLivesLeftDetector.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using UnityEngine;
  2. using System.Collections;
  3. public class NoLivesLeftDetector : MonoBehaviour
  4. {
  5. public static NoLivesLeftDetector Instance;
  6. public ScreenBase noLivesLeftScreen;
  7. public ScreenBase noLivesLeftScreenTime;
  8. public ScreenBase NoLivesAddFriendForOneLiveGameOver;
  9. void Awake()
  10. {
  11. Instance = this;
  12. NotificationCenter.AddListener(OnTriedPlayingWithoutLivesLeft, NotificationType.TriedPlayingWithoutLivesLeft);
  13. }
  14. void OnDestroy()
  15. {
  16. NotificationCenter.RemoveListener(OnTriedPlayingWithoutLivesLeft, NotificationType.TriedPlayingWithoutLivesLeft);
  17. }
  18. void OnTriedPlayingWithoutLivesLeft(Notification note)
  19. {
  20. var curLive = LivesManager.Instance.Lives;
  21. //Debug.Log(curLive);
  22. if (curLive == 0)
  23. {
  24. MenuManager._instance.NoLivesShowAdInGame.Show();
  25. }
  26. else if (curLive == 1)
  27. {
  28. noLivesLeftScreen.Show();
  29. MenuManager._instance.UpdateCircle();
  30. //PlayerPrefs.SetInt("Live", 2);
  31. }
  32. else
  33. {
  34. LivesManager.Instance.RechargeLife();
  35. //PlayerPrefs.SetInt("Level", 0);
  36. PlayerPrefs.SetInt("Live", 0);
  37. PlayerPrefs.Save();
  38. noLivesLeftScreenTime.Show();
  39. }
  40. }
  41. }