50 lines
1.3 KiB
TypeScript
Raw Normal View History

2023-11-05 03:26:09 +08:00
import { ProgressBar } from "cc";
import { _decorator } from "cc";
import { Label } from "cc";
import { GUI } from "../UIConfig";
2023-11-14 18:52:25 +08:00
import NoviceManager from "../../manager/NoviceManager";
2023-11-15 02:32:00 +08:00
import { JNGLayerBase } from "../../components/JNComponent";
import { app } from "../../App";
2023-11-21 18:52:01 +08:00
import { lerp } from "cc";
2023-11-22 03:51:37 +08:00
import { Env, EnvCurrent } from "../../Env";
2023-11-05 03:26:09 +08:00
const { ccclass, property } = _decorator;
@ccclass('LoadingView')
export default class LoadingView extends JNGLayerBase {
@property(ProgressBar)
progress:ProgressBar;
@property(Label)
label:Label;
//是否加载成功
isOk:boolean = false;
update(dt:number){
if(app.loading.getCurrentInfo())
this.label.string = app.loading.getCurrentInfo().title;
2023-11-21 18:52:01 +08:00
this.progress.progress = lerp(this.progress.progress,app.loading.progress(),dt);
2023-11-05 03:26:09 +08:00
if(!this.isOk && app.loading.isAllSuccess()){
this.isOk = true;
this.onSuccess();
}
}
async onSuccess(){
2023-11-10 03:56:07 +08:00
await NoviceManager.getIns().onStart();
2023-11-05 03:26:09 +08:00
//关闭加载页
2023-11-22 03:51:37 +08:00
if(EnvCurrent == Env.Server){
//打开服务器主页
await app.layer.Open(GUI.ServerMain);
}else{
await app.layer.Open(GUI.Main);
}
2023-11-05 03:26:09 +08:00
app.layer.Close(GUI.Loading);
}
}