1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- using System;
- using UnityEngine;
- using System.Collections;
- public class NoLivesLeftDetector : MonoBehaviour
- {
- public static NoLivesLeftDetector Instance;
- public ScreenBase noLivesLeftScreen;
- public ScreenBase noLivesLeftScreenTime;
- public ScreenBase NoLivesAddFriendForOneLiveGameOver;
- void Awake()
- {
- Instance = this;
- NotificationCenter.AddListener(OnTriedPlayingWithoutLivesLeft, NotificationType.TriedPlayingWithoutLivesLeft);
- }
- void OnDestroy()
- {
- NotificationCenter.RemoveListener(OnTriedPlayingWithoutLivesLeft, NotificationType.TriedPlayingWithoutLivesLeft);
- }
- void OnTriedPlayingWithoutLivesLeft(Notification note)
- {
-
- var curLive = LivesManager.Instance.Lives;
- //Debug.Log(curLive);
- if (curLive == 0)
- {
- var countLifeInDay = PlayerPrefs.GetInt("CounterLifeInDay");
- Debug.Log("countLifeInDay " + countLifeInDay);
- if (countLifeInDay < 1)
- {
- NoLivesLeftDetector.Instance.NoLivesAddFriendForOneLiveGameOver.Show();
- }
- else if (countLifeInDay == 1)
- {
- MenuManager._instance.NoLivesShowAdInGame.Show();
- }
- else
- {
- LivesManager.Instance.AddLife();
- PlayerPrefs.SetInt("CounterLifeInDay",0);
- PlayerPrefs.SetInt("Level", 1);
- PlayerPrefs.Save();
- //LivesManager.Instance.RechargeLife();
- }
- //FacebookHelper.Instance.commonInfoDialog.SetTitleAndText("wait.title".ToUpper(), string.Format(Localization.instance.Get("wait.text"),LivesManager.Instance.TimeForLife.Hours, LivesManager.Instance.TimeForLife.Minutes));
- //FacebookHelper.Instance.commonInfoDialog.Show();
- //MenuManager._instance.NoLivesShowAdInGame.Show();
- }
- else if (curLive == 1)
- {
- noLivesLeftScreen.Show();
- MenuManager._instance.UpdateCircle();
- //PlayerPrefs.SetInt("Live", 2);
- }
- else
- {
- LivesManager.Instance.RechargeLife();
- //PlayerPrefs.SetInt("Level", 0);
- PlayerPrefs.SetInt("Live", 0);
-
- PlayerPrefs.Save();
- noLivesLeftScreenTime.Show();
- }
-
- }
- }
|