Sfoglia il codice sorgente

修复MKSystem的bug

zouyong 5 anni fa
parent
commit
cca4e809fc
2 ha cambiato i file con 92 aggiunte e 74 eliminazioni
  1. 91 74
      assets/script/mk/system/MKSystem.ts
  2. 1 0
      assets/script/mk/system/PoolSystem.ts

+ 91 - 74
assets/script/mk/system/MKSystem.ts

@@ -25,97 +25,114 @@ import PoolSystem from "./PoolSystem";
  */
 class MKSystem {
     constructor() {
-        
+
     }
 
     /** 工具 */
-    _time: TimeUtil;
-    public get time():TimeUtil{
-        return this._time || new TimeUtil();
-    }
-    _file: FileUtil;
-    public get file():FileUtil{
-        return this._file || new FileUtil();
-    }
-    _encrypt: EncryptUtil;
-    public get encrypt():EncryptUtil{
-        return this._encrypt || new EncryptUtil();
-    }
-    _console: LogUtil;
-    public get console():LogUtil{
-        return this._console || new LogUtil();
-    }
-    _game: GameUtil;
-    public get game():GameUtil{
-        return this._game || new GameUtil();
-    }
-    _loader: LoadResUtil;
-    public get loader():LoadResUtil{
-        return this._loader || new LoadResUtil();
-    }
-    _storage: StorageUtil;
-    public get storage():StorageUtil{
-        return this._storage || new StorageUtil();
-    }
-    _math: MathUtil;
-    public get math():MathUtil{
-        return this._math || new MathUtil();
+    private _time: TimeUtil;
+    public get time(): TimeUtil {
+        if (!this._time) this._time = new TimeUtil();
+        return this._time;
+    }
+    private _file: FileUtil;
+    public get file(): FileUtil {
+        if(!this._file) this._file = new FileUtil();
+        return this._file;
+    }
+    private _encrypt: EncryptUtil;
+    public get encrypt(): EncryptUtil {
+        if(!this._encrypt) this._encrypt = new EncryptUtil();
+        return this._encrypt;
+    }
+    private _console: LogUtil;
+    public get console(): LogUtil {
+        if(!this._console) this._console = new LogUtil();
+        return this._console;
+    }
+    private _game: GameUtil;
+    public get game(): GameUtil {
+        if(!this._game) this._game = new GameUtil();
+        return this._game;
+    }
+    private _loader: LoadResUtil;
+    public get loader(): LoadResUtil {
+        if(!this._loader) this._loader = new LoadResUtil();
+        return this._loader;
+    }
+    private _storage: StorageUtil;
+    public get storage(): StorageUtil {
+        if(!this._storage) this._storage = new StorageUtil();
+        return this._storage;
+    }
+    private _math: MathUtil;
+    public get math(): MathUtil {
+        if(!this._math) this._math = new MathUtil();
+        return this._math;
     }
 
     /** SDK */
-    _bugly: BuglySDK;
-    public get bugly():BuglySDK{
-        return this._bugly || new BuglySDK();
+    private _bugly: BuglySDK;
+    public get bugly(): BuglySDK {
+        if(!this._bugly) this._bugly = new BuglySDK();
+        return this._bugly;
     }
 
 
     /** 系统管理 */
-    _data: DataSystem;
-    public get data():DataSystem{
-        return this._data || new DataSystem();
-    }
-    _ad: AdSystem;
-    public get ad():AdSystem{
-        return this._ad || new AdSystem(ATSDKMgr.getInstance());
-    }
-    _jsb: JsbSystem;
-    public get jsb():JsbSystem{
-        return this._jsb || new JsbSystem();
-    }
-    _http: HttpSystem;
-    public get http():HttpSystem{
-        return this._http || new HttpSystem();
-    }
-    _audio: AudioSystem;
-    public get audio():AudioSystem{
-        return this._audio || new AudioSystem();
-    }
-    _timer: TimerSystem;
-    public get timer():TimerSystem{
-        return this._timer || new TimerSystem();
-    }
-    _event: EventSystem;
-    public get event():EventSystem{
-        return this._event || new EventSystem();
-    }
-    _pool:PoolSystem;
-    public get pool():PoolSystem{
-        return this._pool || new PoolSystem();
+    private _data: DataSystem;
+    public get data(): DataSystem {
+        if(!this._data) this._data = new DataSystem();
+        return this._data;
+    }
+    private _ad: AdSystem;
+    public get ad(): AdSystem {
+        if(!this._ad) this._ad = new AdSystem(ATSDKMgr.getInstance());
+        return this._ad;
+    }
+    private _jsb: JsbSystem;
+    public get jsb(): JsbSystem {
+        if(!this._jsb) this._jsb = new JsbSystem();
+        return this._jsb;
+    }
+    private _http: HttpSystem;
+    public get http(): HttpSystem {
+        if(!this._http) this._http = new HttpSystem();
+        return this._http;
+    }
+    private _audio: AudioSystem;
+    public get audio(): AudioSystem {
+        if(!this._audio) this._audio = new AudioSystem();
+        return this._audio;
+    }
+    private _timer: TimerSystem;
+    public get timer(): TimerSystem {
+        if(!this._timer) this._timer = new TimerSystem();
+        return this._timer;
+    }
+    private _event: EventSystem;
+    public get event(): EventSystem {
+        if(!this._event) this._event = new EventSystem();
+        return this._event;
+    }
+    private _pool: PoolSystem;
+    public get pool(): PoolSystem {
+        if(!this._pool) this._pool = new PoolSystem();
+        return this._pool;
     }
 
     /** 挂载在MainScene的界面上,不需要new */
-    _ui: UISystem;
-    public get ui():UISystem{
-        return this._ui || new UISystem();
+    private _ui: UISystem;
+    public get ui(): UISystem {
+        return this._ui;
     }
-    public set ui(v:UISystem){
+    public set ui(v: UISystem) {
         this._ui = v;
     }
-    _tip:TipSystem;
-    public get tip():TipSystem{
-        return this._tip || new TipSystem();
+    private _tip: TipSystem;
+    public get tip(): TipSystem {
+        return this._tip;
     }
-    public set tip(v:TipSystem){
+    public set tip(v: TipSystem) {
         this._tip = v;
     }
 }

+ 1 - 0
assets/script/mk/system/PoolSystem.ts

@@ -4,6 +4,7 @@
  */
 export default class PoolSystem {
     constructor() {
+        console.log("PoolSystem:", new Date().getTime());
 
     }