69 lines
2.1 KiB
TypeScript
Raw Normal View History

2023-11-22 03:51:37 +08:00
import { JNSyncFrameEvent } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
2023-11-20 18:25:50 +08:00
import { app } from "../App";
2023-11-22 03:51:37 +08:00
import { Env, EnvCurrent } from "../Env";
2023-11-20 18:25:50 +08:00
import GBattleModeManager, { BattleMode } from "../battle/GBattleModeManager";
import { GAction } from "../consts/GAction";
import { GActionType } from "../consts/GActionType";
import { GUI } from "../ui/UIConfig";
import BaseAction from "./BaseAction";
export interface GPVPStart{
2023-11-21 01:57:40 +08:00
leftTactical:string; //左边玩家的阵法
leftPets:{[key:number]:string}; //左边玩家的宠物
rightTactical:string; //右边玩家的阵法
rightPets:{[key:number]:string}; //左边玩家的宠物
}
export interface GPVPText{
text:string
2023-11-20 18:25:50 +08:00
}
export default class PVPAction extends BaseAction {
onInit(){
app.socket.on(GAction.C_MODE_PVP_START_WAIT,this.onModePVPStartWait,this);
app.socket.on(GAction.C_MODE_PVP_END_WAIT,this.onModePVPEndWait,this);
app.socket.on(GAction.C_MODE_PVP_START,this.onModePVPStart,this,GActionType.GPVPStart);
2023-11-21 01:57:40 +08:00
app.socket.on(GAction.C_MODE_PVP_MESSAGE,this.onModePVPMessage,this,GActionType.GPVPText);
2023-11-22 03:51:37 +08:00
if(EnvCurrent == Env.Server){
app.socket.on(GAction.CR_REFEREE_PVP_MODE,this.onCrReferee,this,GActionType.GPVPStart); //监听PVP裁决
}
2023-11-20 18:25:50 +08:00
}
//PVP开始等待
onModePVPStartWait(){
//PVP 匹配页面
app.layer.Open(GUI.PVPModeMatchView);
}
//PVP结束等待
onModePVPEndWait(){
//PVP 匹配页面
app.layer.Close(GUI.PVPModeMatchView);
}
//开始PVP
onModePVPStart(info:GPVPStart){
console.log("开始PVP",info);
2023-11-21 01:57:40 +08:00
GBattleModeManager.getIns().Open(BattleMode.PVP,true,info);
}
2023-11-22 03:51:37 +08:00
//裁决运行
onCrReferee(info:GPVPStart){
console.log("开始PVP裁决",info);
GBattleModeManager.getIns().Open(BattleMode.PVP,false,info);
GBattleModeManager.getIns().setAuto(true,true);
}
2023-11-21 01:57:40 +08:00
//提示
onModePVPMessage(info:GPVPText){
console.log("提示PVP",info);
app.layer.Open(GUI.Tips,{text:info.text})
2023-11-20 18:25:50 +08:00
}
}