GameApplctionMono.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. using System;
  2. using Excel2Json;
  3. using Fort23.Core;
  4. using Fort23.UTool;
  5. using UnityEditor;
  6. using UnityEngine;
  7. namespace GameUI
  8. {
  9. public class GameApplctionMono : MonoBehaviour
  10. {
  11. public GameApplction GameApplction;
  12. public void Update()
  13. {
  14. #if UNITY_EDITOR
  15. // if (EditorApplication.isPaused)
  16. // {
  17. // return;
  18. // }
  19. #endif
  20. EventSystem.Instance.Update();
  21. AssetBundleLoadManager.Instance.UpdateBundle();
  22. TimeHelper.clientFrame = TimeHelper.ClientFrame() + (long)(Time.deltaTime * 1000);
  23. }
  24. private class TestHERO
  25. {
  26. public int level;
  27. public int exp;
  28. public void AddExp(int e)
  29. {
  30. this.exp += e;
  31. HeroPowerUpConfig allPowerUp = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  32. while (exp > allPowerUp.levelUpExp && allPowerUp.levelUpExp > 0)
  33. {
  34. exp = exp - allPowerUp.levelUpExp;
  35. level++;
  36. allPowerUp = ConfigComponent.Instance.Get<HeroPowerUpConfig>(level);
  37. }
  38. }
  39. }
  40. // [ContextMenu("monster")]
  41. // public void Test()
  42. // {
  43. // LevelBattleConfig[] levelBattleConfigs = ConfigComponent.Instance.GetAll<LevelBattleConfig>();
  44. // TestHERO testHero = new TestHERO();
  45. // testHero.level = 1;
  46. // string m = "";
  47. // for (int i = 0; i < levelBattleConfigs.Length; i++)
  48. // {
  49. // LevelBattleConfig levelBattleConfig = levelBattleConfigs[i];
  50. // int jy = levelBattleConfig.exp * levelBattleConfig.miniExpAndGold[0] / 4;
  51. // testHero.AddExp(jy);
  52. // m += testHero.level + "\n";
  53. // }
  54. // Debug.Log(m);
  55. // }
  56. private void OnApplicationFocus(bool hasFocus)
  57. {
  58. if (!TimeHelper.IsNetworkTimeReady)
  59. {
  60. return;
  61. }
  62. if (hasFocus && PlayerManager.Instance.isLogin)
  63. {
  64. // 退出时记录时间
  65. AccountFileInfo.Instance.playerData.ExitTime = TimeHelper.ClientNow();
  66. AccountFileInfo.Instance.SavePlayerData();
  67. }
  68. else if(PlayerManager.Instance.isLogin)
  69. {
  70. PlayerManager.Instance.CalculateOfflineRewards();
  71. }
  72. }
  73. private void OnApplicationQuit()
  74. {
  75. if (!TimeHelper.IsNetworkTimeReady)
  76. {
  77. return;
  78. }
  79. // 退出时记录时间
  80. AccountFileInfo.Instance.playerData.ExitTime = TimeHelper.ClientNow();
  81. AccountFileInfo.Instance.SavePlayerData();
  82. // if (hasFocus)
  83. // {
  84. //
  85. // }
  86. // else
  87. // {
  88. // PlayerManager.Instance.CalculateOfflineRewards();
  89. // }
  90. }
  91. // private void OnApplicationPause(bool pauseStatus)
  92. // {
  93. // throw new NotImplementedException();
  94. // }
  95. // public async void OnApplicationPause(bool pauseStatus)
  96. // {
  97. // }
  98. public void LateUpdate()
  99. {
  100. EventSystem.Instance.LateUpdate();
  101. }
  102. }
  103. }