| 
									
										
										
										
											2024-03-09 13:17:48 +08:00
										 |  |  | import { _decorator, Component, director, instantiate, Node, Prefab, resources, Scene } from 'cc'; | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  | import { GlobalAudio } from '../../GlobalScript/GlobalAudio/GlobalAudio'; | 
					
						
							|  |  |  | import { ImagePack } from '../../GlobalScript/ImagePack/ImagePack'; | 
					
						
							|  |  |  | import { GameScript } from '../../GlobalScript/GameScript/GameScript'; | 
					
						
							| 
									
										
										
										
											2024-03-09 13:17:48 +08:00
										 |  |  | import { UIRoot } from '../../Script/UIRoot'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  | 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; | 
					
						
							| 
									
										
										
										
											2024-03-09 13:17:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-09 19:39:20 +08:00
										 |  |  |     NpkImgCount = 0 | 
					
						
							|  |  |  |     NpkImgLoadCount = 0 | 
					
						
							|  |  |  |     NpkInitFlag = false; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  |     start() { | 
					
						
							|  |  |  |         //初始化音频Map
 | 
					
						
							|  |  |  |         GlobalAudio.getInstance().Init(() => { | 
					
						
							|  |  |  |             this.AudioManage = true; | 
					
						
							|  |  |  |         }); | 
					
						
							|  |  |  |         //初始化Npk
 | 
					
						
							|  |  |  |         ImagePack.getInstance().init(() => { | 
					
						
							|  |  |  |             this.NpkManage = true; | 
					
						
							| 
									
										
										
										
											2024-03-09 19:39:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |             this.NpkImgCount = ImagePack.getInstance().ReadNpkFile("!幻想模拟战", (img) => { | 
					
						
							|  |  |  |                 this.NpkImgLoadCount++; | 
					
						
							|  |  |  |                 if (this.NpkImgLoadCount >= this.NpkImgCount) this.NpkInitFlag = true; | 
					
						
							|  |  |  |             }); | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  |         }); | 
					
						
							|  |  |  |         //初始化Pvf
 | 
					
						
							|  |  |  |         GameScript.getInstance().Init(() => { | 
					
						
							|  |  |  |             this.PvfManage = true; | 
					
						
							|  |  |  |         }); | 
					
						
							| 
									
										
										
										
											2024-03-09 13:17:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-09 19:39:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     CheckInitState() { | 
					
						
							|  |  |  |         if (!this.NpkManage | 
					
						
							|  |  |  |             || !this.PvfManage) | 
					
						
							|  |  |  |             return false; | 
					
						
							|  |  |  |         else return true; | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-09 13:17:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  |     update(deltaTime: number) { | 
					
						
							| 
									
										
										
										
											2024-03-09 19:39:20 +08:00
										 |  |  |         if (this.CheckInitState() && !this.InitFlag && this.LogoFlag && this.NpkInitFlag) { | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |             this.scheduleOnce(function () { | 
					
						
							|  |  |  |                 // director.loadScene("LoginGame");
 | 
					
						
							| 
									
										
										
										
											2024-03-09 19:39:20 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |                 director.preloadScene("main", () => { | 
					
						
							| 
									
										
										
										
											2024-03-09 13:17:48 +08:00
										 |  |  |                     director.loadScene("main"); | 
					
						
							|  |  |  |                 }); | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  |             }, 0); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |             this.InitFlag = true; | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |             //每帧调用
 | 
					
						
							|  |  |  |             GameScript.getInstance().Update(); | 
					
						
							| 
									
										
										
										
											2024-03-09 19:39:20 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-07 13:32:04 +08:00
										 |  |  |         } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 |