简单的PVP

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-21 01:57:40 +08:00
parent 1aa5900294
commit 074cfbd5bd
18 changed files with 3218 additions and 158 deletions

View File

@@ -46,6 +46,12 @@ export default class GBattleModeManager extends Singleton {
//默认模式
default:BattleMode = BattleMode.OnHook; //默认无限模式
//当前帧不切换模式
frameNoSwitch:boolean = false;
//模式数据
data:any;
//初始化管理器
async onInit(info:GBattleModeInfo){
@@ -62,10 +68,12 @@ export default class GBattleModeManager extends Singleton {
}
//打开指定模式
async Open(mode:BattleMode = null,isAuto:boolean = false){
async Open(mode:BattleMode = null,isAuto:boolean = false,data:any = this.data){
this.data = data;
if(!this.current && mode == null){
await this.Open(this.default,true);
await this.Open(this.default,true,data);
return;
}else if(mode == null){
return;
@@ -85,8 +93,7 @@ export default class GBattleModeManager extends Singleton {
//主动调用场景销毁
app.sync.onReset();
this.current = null;
await this.Open();
this.frameNoSwitch = true;
}
@@ -108,6 +115,7 @@ export default class GBattleModeManager extends Singleton {
if(!this.isInit || this.current == null) return;
let mode = instantiate(this.modes[this.current]);
mode.getComponent(GBaseMode).camera = this.camera;
mode.getComponent(GBaseMode).data = this.data;
this.root.addChild(mode)
}
@@ -124,6 +132,13 @@ export default class GBattleModeManager extends Singleton {
app.sync.update(dt);
//自动推帧
this.onAutoFrame(dt);
//如果当前模式是空则默认模式
if(this.current == null && !this.frameNoSwitch){
this.Open();
}
this.frameNoSwitch = false;
}
//自动推帧