mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-12-08 14:00:02 +00:00
简单的PVP
This commit is contained in:
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
//自动推帧
|
||||
|
||||
Reference in New Issue
Block a user