60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
		
		
			
		
	
	
			60 lines
		
	
	
		
			1.6 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
|  | import { _decorator, Component, director, Node } from 'cc'; | ||
|  | import { GlobalAudio } from '../../GlobalScript/GlobalAudio/GlobalAudio'; | ||
|  | import { ImagePack } from '../../GlobalScript/ImagePack/ImagePack'; | ||
|  | import { GameScript } from '../../GlobalScript/GameScript/GameScript'; | ||
|  | const { ccclass, property } = _decorator; | ||
|  | 
 | ||
|  | 
 | ||
|  | @ccclass('LodingLogic') | ||
|  | export class LodingLogic extends Component { | ||
|  | 
 | ||
|  |     //Logo播放完成状态
 | ||
|  |     LogoFlag = true; | ||
|  |     //InitFlag
 | ||
|  |     InitFlag = false; | ||
|  |     //音频管理器初始化状态
 | ||
|  |     AudioManage: boolean = false; | ||
|  |     //NPK管理器初始化状态
 | ||
|  |     NpkManage: boolean = false; | ||
|  |     //Pvf管理器初始化状态
 | ||
|  |     PvfManage: boolean = false; | ||
|  |     start() { | ||
|  |         //初始化音频Map
 | ||
|  |         GlobalAudio.getInstance().Init(() => { | ||
|  |             this.AudioManage = true; | ||
|  |         }); | ||
|  |         //初始化Npk
 | ||
|  |         ImagePack.getInstance().init(() => { | ||
|  |             this.NpkManage = true; | ||
|  |         }); | ||
|  |         //初始化Pvf
 | ||
|  |         GameScript.getInstance().Init(() => { | ||
|  |             this.PvfManage = true; | ||
|  |         }); | ||
|  |     } | ||
|  | 
 | ||
|  |     CheckInitState() { | ||
|  |         if (!this.NpkManage | ||
|  |             || !this.PvfManage) | ||
|  |             return false; | ||
|  |         else return true; | ||
|  |     } | ||
|  | 
 | ||
|  |     update(deltaTime: number) { | ||
|  |         if (this.CheckInitState() && !this.InitFlag && this.LogoFlag) { | ||
|  | 
 | ||
|  |             this.scheduleOnce(function () { | ||
|  |                 // director.loadScene("LoginGame");
 | ||
|  |                 director.loadScene("main"); | ||
|  |             }, 0); | ||
|  | 
 | ||
|  |             this.InitFlag = true; | ||
|  |         } else { | ||
|  |             //每帧调用
 | ||
|  |             GameScript.getInstance().Update(); | ||
|  |         } | ||
|  |     } | ||
|  | } | ||
|  | 
 | ||
|  | 
 |