GameApplctionMono.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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. LogTool.Error("没有获取到网络时间,不记录挂机时间!");
  61. return;
  62. }
  63. if (!hasFocus && PlayerManager.Instance.isLogin)
  64. {
  65. // 退出时记录时间
  66. AccountFileInfo.Instance.playerData.ExitTime = TimeHelper.ClientNow();
  67. AccountFileInfo.Instance.SavePlayerData();
  68. }
  69. else if (PlayerManager.Instance.isLogin)
  70. {
  71. PlayerManager.Instance.CalculateOfflineRewards();
  72. }
  73. }
  74. private void OnApplicationQuit()
  75. {
  76. if (!TimeHelper.IsNetworkTimeReady)
  77. {
  78. return;
  79. }
  80. // 退出时记录时间
  81. AccountFileInfo.Instance.playerData.ExitTime = TimeHelper.ClientNow();
  82. AccountFileInfo.Instance.SavePlayerData();
  83. // if (hasFocus)
  84. // {
  85. //
  86. // }
  87. // else
  88. // {
  89. // PlayerManager.Instance.CalculateOfflineRewards();
  90. // }
  91. }
  92. // private void OnApplicationPause(bool pauseStatus)
  93. // {
  94. // throw new NotImplementedException();
  95. // }
  96. // public async void OnApplicationPause(bool pauseStatus)
  97. // {
  98. // }
  99. public void LateUpdate()
  100. {
  101. EventSystem.Instance.LateUpdate();
  102. }
  103. }
  104. }