MKSystem.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import BuglySDK from "../sdk/BuglySDK";
  2. import FileUtil from "../utils/FileUtil";
  3. import TimeUtil from "../utils/TimeUtil";
  4. import DataSystem from "./DataSystem";
  5. import HttpSystem from "./HttpSystem";
  6. import LoadResUtil from "../utils/LoadResUtil";
  7. import LogUtil from "../utils/LogUtil";
  8. import { EncryptUtil } from "../utils/EncryptUtil";
  9. import GameUtil from "../utils/GameUtil";
  10. import UISystem from "./UISystem";
  11. import StorageUtil from "../utils/StorageUtil";
  12. import TimerSystem from "./TimerSystem";
  13. import EventSystem from "./EventSystem";
  14. import MathUtil from "../utils/MathUtil";
  15. import AdSystem from "./AdSystem";
  16. import JsbSystem from "./JsbSystem";
  17. import ATSDKMgr from "../sdk/ad/toppon/AnyThinkAdsMgr/ATSDKMgr";
  18. import AudioSystem from "./AudioSystem";
  19. import TipSystem from "./TipSystem";
  20. import PoolSystem from "./PoolSystem";
  21. /**
  22. * @description mk系统
  23. * @author 邹勇,冯聪,薛鸿潇,kaka
  24. */
  25. class MKSystem {
  26. constructor() {
  27. }
  28. /** 工具 */
  29. private _time: TimeUtil;
  30. public get time(): TimeUtil {
  31. if (!this._time) this._time = new TimeUtil();
  32. return this._time;
  33. }
  34. private _file: FileUtil;
  35. public get file(): FileUtil {
  36. if(!this._file) this._file = new FileUtil();
  37. return this._file;
  38. }
  39. private _encrypt: EncryptUtil;
  40. public get encrypt(): EncryptUtil {
  41. if(!this._encrypt) this._encrypt = new EncryptUtil();
  42. return this._encrypt;
  43. }
  44. private _console: LogUtil;
  45. public get console(): LogUtil {
  46. if(!this._console) this._console = new LogUtil();
  47. return this._console;
  48. }
  49. private _game: GameUtil;
  50. public get game(): GameUtil {
  51. if(!this._game) this._game = new GameUtil();
  52. return this._game;
  53. }
  54. private _loader: LoadResUtil;
  55. public get loader(): LoadResUtil {
  56. if(!this._loader) this._loader = new LoadResUtil();
  57. return this._loader;
  58. }
  59. private _storage: StorageUtil;
  60. public get storage(): StorageUtil {
  61. if(!this._storage) this._storage = new StorageUtil();
  62. return this._storage;
  63. }
  64. private _math: MathUtil;
  65. public get math(): MathUtil {
  66. if(!this._math) this._math = new MathUtil();
  67. return this._math;
  68. }
  69. /** SDK */
  70. private _bugly: BuglySDK;
  71. public get bugly(): BuglySDK {
  72. if(!this._bugly) this._bugly = new BuglySDK();
  73. return this._bugly;
  74. }
  75. /** 系统管理 */
  76. private _data: DataSystem;
  77. public get data(): DataSystem {
  78. if(!this._data) this._data = new DataSystem();
  79. return this._data;
  80. }
  81. private _ad: AdSystem;
  82. public get ad(): AdSystem {
  83. if(!this._ad) this._ad = new AdSystem(ATSDKMgr.getInstance());
  84. return this._ad;
  85. }
  86. private _jsb: JsbSystem;
  87. public get jsb(): JsbSystem {
  88. if(!this._jsb) this._jsb = new JsbSystem();
  89. return this._jsb;
  90. }
  91. private _http: HttpSystem;
  92. public get http(): HttpSystem {
  93. if(!this._http) this._http = new HttpSystem();
  94. return this._http;
  95. }
  96. private _audio: AudioSystem;
  97. public get audio(): AudioSystem {
  98. if(!this._audio) this._audio = new AudioSystem();
  99. return this._audio;
  100. }
  101. private _timer: TimerSystem;
  102. public get timer(): TimerSystem {
  103. if(!this._timer) this._timer = new TimerSystem();
  104. return this._timer;
  105. }
  106. private _event: EventSystem;
  107. public get event(): EventSystem {
  108. if(!this._event) this._event = new EventSystem();
  109. return this._event;
  110. }
  111. private _pool: PoolSystem;
  112. public get pool(): PoolSystem {
  113. if(!this._pool) this._pool = new PoolSystem();
  114. return this._pool;
  115. }
  116. /** 挂载在MainScene的界面上,不需要new */
  117. private _ui: UISystem;
  118. public get ui(): UISystem {
  119. return this._ui;
  120. }
  121. public set ui(v: UISystem) {
  122. this._ui = v;
  123. }
  124. private _tip: TipSystem;
  125. public get tip(): TipSystem {
  126. return this._tip;
  127. }
  128. public set tip(v: TipSystem) {
  129. this._tip = v;
  130. }
  131. }
  132. declare global {
  133. const mk: MKSystem;
  134. }
  135. window['mk'] = new MKSystem();