MKSystem.ts 4.4 KB

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