// void OnApplicationQuit() // { // DestroyLife(); // } void OnApplicationPause(bool pause) { int lives = UpdateLives(false); int oldLives = lives; //TODO TALIN - !!! if (pause) { if (canDestroyLife) { Debug.Log("Destroying life"); lives = Mathf.Max(0, lives - 1); pauseLifeDestroyed = true; } } else if (pauseLifeDestroyed) { Debug.Log("Restoring life"); lives = Mathf.Min(LivesSystem.maxLives, lives + 1); pauseLifeDestroyed = false; } if (lives != oldLives) { Debug.Log("Saving new lives"); // LivesSystem.SaveLivesAndNotify(lives, long.Parse(PlayerPrefs.GetString(LivesSystem.livesTimeKey, LivesSystem.TimeSeconds().ToString()))); LivesSystem.SaveLivesAndNotify(lives, UserManagerCloud.Instance.CurrentUser.LivesTime != 0 ? UserManagerCloud.Instance.CurrentUser.LivesTime : LivesSystem.TimeSeconds()); PlayerPrefs.Save(); } }
// Use this for initialization void Awake () { instance = this; lifeRefillTime = TweaksSystem.Instance.intValues["LifeRefillTime"]; //TODO TALIN: very easy to modify this property by the user if it's stored in playerprefs (save to binary file?) // Lives = PlayerPrefs.GetInt(livesKey, maxLives); Lives = UserManagerCloud.Instance.CurrentUser.NumsLiveLeft; Debug.LogWarning("[LivesSystem]Loaded lives: " + lives); long time = TimeSeconds(); // waitTime = System.Math.Min(long.Parse(PlayerPrefs.GetString(livesTimeKey, time.ToString())), time); waitTime = UserManagerCloud.Instance.CurrentUser.LivesTime == 0 ? time : UserManagerCloud.Instance.CurrentUser.LivesTime; //TODO: user modify time to get live. will not charge live. if(PlayerPrefs.HasKey(timeModifyKey)) { Debug.Log("[LivesSystem]The time of system has been modified!!" + PlayerPrefs.GetInt(timeModifyKey)); } else { Debug.Log("[LivesSystem]Cannot get the timeModify flag!"); } if(PlayerPrefs.GetInt(timeModifyKey, 0) != 0 && PlayerPrefs.GetInt("cheat", 0) == 0) { waitTime = TimeSeconds(); UserManagerCloud.Instance.CurrentUser.LivesTime = waitTime; // Update user.data UserCloud.Serialize(UserManagerCloud.FILE_NAME_LOCAL); PlayerPrefs.SetInt(timeModifyKey, 0); } }
void Awake() { lifeSystem = LivesSystem.Instance; LivesStandard info = JsonUtility.FromJson <LivesStandard>(PlayerPrefs.GetString(SAVESTRING)); lifeSystem.FeedDeserializeInfo(info); UpdateNumberOfLives(); }
private void Awake() { if (respawnPoint == null && respawnable) { Debug.LogError("No hay punto de respawn! Agrega uno!", gameObject); } hm = GetComponent <HealthManager>(); lm = GetComponent <LivesSystem>(); }
IEnumerator UpdateTimer() { WaitForSeconds waiter = new WaitForSeconds(0.05f); while (LivesSystem.lives < 5) { myLabel.text = LivesSystem.GetTimerString(); yield return(waiter); } }
// Use this for initialization void Awake() { long start = LivesSystem.TimeSeconds(); Resources.UnloadUnusedAssets(); GC.Collect(); long end = LivesSystem.TimeSeconds(); Debug.Log(" gc time:" + (end - start).ToString()); // CmBillingAndroid.Instance.test2 (); }
public IEnumerator FreeMemory() { long start = LivesSystem.TimeSeconds(); GameObject obj1 = GameObject.Find("MFPFreeMemory"); PlayMakerFSM fsm = obj1.GetComponent <PlayMakerFSM>(); fsm.SendEvent("FreeMemory"); long end = LivesSystem.TimeSeconds(); Debug.Log("YU JIAN Freee memory = " + (end - start).ToString()); yield return(""); }
void InitSystems() { _engine = new Engine(); _aiSystem = new AIThinkSystem(_engine); _inputSystem = new InputSystem(_engine); _paddleSystem = new PaddleSystem(_engine); _ballMovementSystem = new BallMovementSystem(_engine); _goalSystem = new GoalSystem(_engine); _livesSystem = new LivesSystem(_engine); _renderSystem = new RenderSystem(GameManager.GraphicsDevice, _engine); _livesSystem.RegisterEventListeners(); }
void Start() { long curTime = LivesSystem.TimeSeconds(); Debug.Log("CurTime = " + curTime.ToString() + ", lastFreeMemoryTime = " + lastFreeMemoryTime.ToString()); if (curTime - lastFreeMemoryTime > 5 * 60) { if (lastFreeMemoryTime != 0) { Debug.Log("YU JIAN: start free memory"); StartCoroutine(FreeMemory()); } lastFreeMemoryTime = curTime; } }
void Start() { // Add systems here LivesSystem ls = new LivesSystem(); AddSystem(ls); StreakSystem ss = new StreakSystem(); AddSystem(ss); ScoreSystem scs = new ScoreSystem(); AddSystem(scs); ColoringSystem cs = new ColoringSystem(); AddSystem(cs); TouchSystem ts = new TouchSystem(); AddSystem(ts); GameSystem gs = new GameSystem(); AddSystem(gs); TutorialSystem tus = new TutorialSystem(); AddSystem(tus); AnimationSystem ans = new AnimationSystem(); AddSystem(ans); UISystem uis = new UISystem(); AddSystem(uis); PauseSystem ps = new PauseSystem(); AddSystem(ps); DestroySystem ds = new DestroySystem(); AddSystem(ds); AdSystem ads = new AdSystem(); AddSystem(ads); Enable(); this.initializeGame = true; ExtraSetup(); }
int UpdateLives(bool save, bool updateNotifications = false) { LivesSystem.lifeRefillTime = TweaksSystem.Instance.intValues["LifeRefillTime"]; long time = LivesSystem.TimeSeconds(); // int lives = PlayerPrefs.GetInt(LivesSystem.livesKey, LivesSystem.maxLives); int lives = UserManagerCloud.Instance.CurrentUser.NumsLiveLeft; // long waitTime = lives < LivesSystem.maxLives ? long.Parse(PlayerPrefs.GetString(LivesSystem.livesTimeKey, time.ToString())) : time; long waitTime = lives < LivesSystem.maxLives ? UserManagerCloud.Instance.CurrentUser.LivesTime : time; int newLives = (int)(time - waitTime) / (int)LivesSystem.lifeRefillTime; if (PlayerPrefs.HasKey(LivesSystem.timeModifyKey) && PlayerPrefs.GetInt(LivesSystem.timeModifyKey, 0) != 0 && PlayerPrefs.GetInt("cheat", 0) == 0) { newLives = 0; } if (newLives + lives >= LivesSystem.maxLives) { waitTime = time; lives = LivesSystem.maxLives; } else { lives += newLives; waitTime += newLives * LivesSystem.lifeRefillTime; } LivesSystem.SaveLivesAndNotify(lives, waitTime, false); if (save) { PlayerPrefs.Save(); } return(lives); }
// Use this for initialization void Awake() { instance = this; lifeRefillTime = TweaksSystem.Instance.intValues["LifeRefillTime"]; //TODO TALIN: very easy to modify this property by the user if it's stored in playerprefs (save to binary file?) // Lives = PlayerPrefs.GetInt(livesKey, maxLives); Lives = UserManagerCloud.Instance.CurrentUser.NumsLiveLeft; Debug.LogWarning("[LivesSystem]Loaded lives: " + lives); long time = TimeSeconds(); // waitTime = System.Math.Min(long.Parse(PlayerPrefs.GetString(livesTimeKey, time.ToString())), time); waitTime = UserManagerCloud.Instance.CurrentUser.LivesTime == 0 ? time : UserManagerCloud.Instance.CurrentUser.LivesTime; //TODO: user modify time to get live. will not charge live. if (PlayerPrefs.HasKey(timeModifyKey)) { Debug.Log("[LivesSystem]The time of system has been modified!!" + PlayerPrefs.GetInt(timeModifyKey)); } else { Debug.Log("[LivesSystem]Cannot get the timeModify flag!"); } if (PlayerPrefs.GetInt(timeModifyKey, 0) != 0 && PlayerPrefs.GetInt("cheat", 0) == 0) { waitTime = TimeSeconds(); UserManagerCloud.Instance.CurrentUser.LivesTime = waitTime; // Update user.data UserCloud.Serialize(UserManagerCloud.FILE_NAME_LOCAL); PlayerPrefs.SetInt(timeModifyKey, 0); } }
public void DestroyLife() { if (!canDestroyLife) { return; } if (Match3BoardRenderer.levelIdx >= LoadLevelButton.lastUnlockedLevel) { int times = PlayerPrefs.GetInt(BIModel.ChallengeTimesKey, 0) + 1; PlayerPrefs.SetInt(BIModel.ChallengeTimesKey, times); } canDestroyLife = false; int lives = UpdateLives(false); lives = Mathf.Max(0, lives - 1); // LivesSystem.SaveLivesAndNotify(lives, long.Parse(PlayerPrefs.GetString(LivesSystem.livesTimeKey, LivesSystem.TimeSeconds().ToString()))); LivesSystem.SaveLivesAndNotify(lives, UserManagerCloud.Instance.CurrentUser.LivesTime != 0 ? UserManagerCloud.Instance.CurrentUser.LivesTime : LivesSystem.TimeSeconds()); PlayerPrefs.Save(); }
// Use this for initialization void Start() { //int x = PlayerPrefs.GetInt("TUTORIAL_TORCH_ITEM", 0); //PlayerPrefs.SetInt("TUTORIAL_TORCH_ITEM", 1); // OutputLevelScores //PlayerPrefs.SetInt("key_360", 1); // record that user has already get to map level QihooSnsModel.Instance.goToMapLevelOnce = true; if (QihooSnsModel.Instance.Using360Login) { //UserSNSManager.Instance.showFloatWnd(); } // [1] sync cached high scores HighScoreModel.Instance.Deserialize(); Dictionary <int, int> cachedHighScores = HighScoreModel.Instance._highScores; if (cachedHighScores != null && cachedHighScores.Count > 0) { Dictionary <string, object> data = new Dictionary <string, object> (); data["cmd"] = "saveData"; data["deviceId"] = SystemInfo.deviceUniqueIdentifier; data["platformId"] = QihooSnsModel.Instance.UserID; data["levelScore"] = HighScoreModel.Instance._highScores; HttpRequestService.sendRequest(data, new HttpRequestService.RequestSuccessDelegate(onGetNoticesSuccess), null); } // [2] sync user friend scores Dictionary <string, object> data1 = new Dictionary <string, object> (); data1["cmd"] = "getFriend"; data1["platformIds"] = QihooSnsModel.Instance.FriendListStr; //data1["platformIds"] ="599315361,29886669,384531921,630180399,291875798,291201194"; //data1["platformIds"] = "622792586,384531921,291201194,291257815,371301281"; //data1["platformIds"] = "612146777,291201194,404357426,317138868,291257815,401061065,622792586,599315361,371301281,29886669,626838463,271149288"; long curTime = LivesSystem.TimeSeconds(); if (data1["platformIds"] != "" && curTime - QihooSnsModel.Instance.LastGetFriendTime > 300) { // no secode get friend service in 5 minutes QihooSnsModel.Instance.LastGetFriendTime = LivesSystem.TimeSeconds(); HttpRequestService.sendRequest(data1, new HttpRequestService.RequestSuccessDelegate(onGetFriendScoreSuccess), new HttpRequestService.RequestFailDelegate(onGetFriendScoreFailure)); } else { UpdateFriendNameInMap(); } /* * if (QihooSnsModel.Instance.FriendListStr == "") * { * data1["platformIds"] = QihooSnsModel.Instance.FriendListStr + "1,2,3,4,5,6,7"; * } * else * { * data1["platformIds"] = QihooSnsModel.Instance.FriendListStr + ",1,2,3,4,5,6,7"; * } */ // [3] sync current level with 360 if (QihooSnsModel.Instance.Using360Login) { UserSNSManager.Instance.UploadData(QihooSnsModel.Instance.UserID, UserManagerCloud.Instance.CurrentUser.LastFinishedLvl.ToString()); } }
protected override void Awake() { base.Awake(); rs = GetComponent <RespawnSystem>(); lm = GetComponent <LivesSystem>(); }
private void Start() { heart = FindObjectOfType <LivesSystem>(); heart.CountHearts(); }