mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 10:16:14 +00:00
提交完美的无头模式
This commit is contained in:
@@ -28,10 +28,10 @@ import AppAction from "./AppAction";
|
||||
|
||||
// let APIPath = `http://localhost:8080`
|
||||
// let WsPath = `ws://localhost:8080/websocket`
|
||||
let APIPath = `http://192.168.1.23:8080`
|
||||
let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||
// let APIPath = `http://192.168.0.174:8080`
|
||||
// let WsPath = `ws://192.168.0.174:8080/websocket`
|
||||
// let APIPath = `http://192.168.1.23:8080`
|
||||
// let WsPath = `ws://192.168.1.23:8080/websocket`
|
||||
let APIPath = `http://192.168.0.123:8080`
|
||||
let WsPath = `ws://192.168.0.123:8080/websocket`
|
||||
// let APIPath = `https://api.pet.jisol.cn`
|
||||
// let WsPath = `wss://api.pet.jisol.cn/websocket`
|
||||
|
||||
@@ -231,8 +231,8 @@ export const app = {
|
||||
}
|
||||
|
||||
app.api.addRequestInterceptors((config:JAPIConfig) => {
|
||||
// //设置Token
|
||||
// if(StorageData.get(StorageEnum.Token))
|
||||
// config.headers["Token"] = StorageData.get(StorageEnum.Token);
|
||||
//设置Token
|
||||
if(StorageData.get(StorageEnum.Token))
|
||||
config.headers["Token"] = StorageData.get(StorageEnum.Token);
|
||||
return true;
|
||||
})
|
@@ -1,3 +1,5 @@
|
||||
|
||||
|
||||
//打包环境
|
||||
export enum Env{
|
||||
Server, //服务器模式
|
||||
@@ -5,4 +7,5 @@ export enum Env{
|
||||
}
|
||||
|
||||
//当前环境
|
||||
export const EnvCurrent:Env = Env.Server;
|
||||
export const EnvCurrent:Env = Env.H5;
|
||||
|
||||
|
@@ -1,7 +1,6 @@
|
||||
import { JNSyncFrameEvent } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
import { app } from "../App";
|
||||
import { Env, EnvCurrent } from "../Env";
|
||||
import GBattleModeManager, { BattleMode } from "../battle/GBattleModeManager";
|
||||
import GBattleModeManager, { BattleMode, GBattleModeEvent } from "../battle/GBattleModeManager";
|
||||
import { GAction } from "../consts/GAction";
|
||||
import { GActionType } from "../consts/GActionType";
|
||||
import { GUI } from "../ui/UIConfig";
|
||||
@@ -12,6 +11,8 @@ export interface GPVPStart{
|
||||
leftPets:{[key:number]:string}; //左边玩家的宠物
|
||||
rightTactical:string; //右边玩家的阵法
|
||||
rightPets:{[key:number]:string}; //左边玩家的宠物
|
||||
leftPlayerId:number; //左边的玩家Id
|
||||
rightPlayerId:number; //右边的玩家Id
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +23,7 @@ export interface GPVPText{
|
||||
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);
|
||||
@@ -29,7 +31,9 @@ export default class PVPAction extends BaseAction {
|
||||
|
||||
if(EnvCurrent == Env.Server){
|
||||
app.socket.on(GAction.CR_REFEREE_PVP_MODE,this.onCrReferee,this,GActionType.GPVPStart); //监听PVP裁决
|
||||
app.event.on(GBattleModeEvent.Close,this.onBattleRefereeClose,this); //模式结束运行
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//PVP开始等待
|
||||
@@ -63,6 +67,16 @@ export default class PVPAction extends BaseAction {
|
||||
app.layer.Open(GUI.Tips,{text:info.text})
|
||||
}
|
||||
|
||||
//裁决结束返回
|
||||
onBattleRefereeClose(type:BattleMode,data?:number){
|
||||
if(type == BattleMode.PVP){
|
||||
console.log("裁决结束胜利玩家",data)
|
||||
app.socket.Send(GAction.CR_REFEREE_PVP_END,{
|
||||
winnerId:data
|
||||
},GActionType.GPVPRefereeInfo)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -37,8 +37,8 @@ export default class GBaseMode<T,DT> extends GObject<T> {
|
||||
}
|
||||
|
||||
//结束场景
|
||||
Close(){
|
||||
GBattleModeManager.getIns().Close();
|
||||
Close(data?:any){
|
||||
GBattleModeManager.getIns().Close(data);
|
||||
}
|
||||
|
||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T) {
|
||||
|
@@ -22,6 +22,12 @@ export interface GBattleModeInfo{
|
||||
root:Node, //世界场景Root
|
||||
}
|
||||
|
||||
//事件
|
||||
export enum GBattleModeEvent{
|
||||
//关闭模式
|
||||
Close = "GBattleModeEvent_Close",
|
||||
}
|
||||
|
||||
//全局战斗模式管理器
|
||||
export default class GBattleModeManager extends Singleton {
|
||||
|
||||
@@ -93,13 +99,16 @@ export default class GBattleModeManager extends Singleton {
|
||||
}
|
||||
|
||||
//关闭当前模式
|
||||
async Close(){
|
||||
async Close(data?:any){
|
||||
|
||||
//主动调用场景销毁
|
||||
app.sync.onReset();
|
||||
let current = this.current;
|
||||
this.current = null;
|
||||
this.frameNoSwitch = true;
|
||||
|
||||
//结束通知
|
||||
app.event.emit(GBattleModeEvent.Close,current,data);
|
||||
}
|
||||
|
||||
//设置自动推帧 ( 帧不由addFrame控制 管理器自动推帧)
|
||||
@@ -109,8 +118,6 @@ export default class GBattleModeManager extends Singleton {
|
||||
this.autoTime = 0;
|
||||
}
|
||||
|
||||
//设置自动追帧
|
||||
|
||||
//清除当前模式
|
||||
private clear(){
|
||||
if(!this.isInit) return;
|
||||
|
@@ -214,10 +214,14 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{
|
||||
//判断是否有队伍都死亡
|
||||
if(this.getOnesRoleAlive(GPVPModePlayerEnum.PLAYER).length == 0 || this.getOnesRoleAlive(GPVPModePlayerEnum.ENEMY).length == 0){
|
||||
this.isEndGame = true;
|
||||
let winner = this.data.leftPlayerId;
|
||||
if(this.getOnesRoleAlive(GPVPModePlayerEnum.ENEMY).length){
|
||||
winner = this.data.rightPlayerId;
|
||||
}
|
||||
//结束游戏
|
||||
JNFrameTime.getInstance().setTimeout(() => {
|
||||
console.log(this.getOnesRoleAlive(GPVPModePlayerEnum.PLAYER).length,this.getOnesRoleAlive(GPVPModePlayerEnum.ENEMY).length)
|
||||
this.Close();
|
||||
this.Close(winner);
|
||||
},3000)
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@ export enum GAction {
|
||||
|
||||
|
||||
/*************** 裁决 *********************/
|
||||
CR_REFEREE_PVP_MODE = 4001, //裁决PVP模式
|
||||
CR_REFEREE_PVP_MODE = 4001, //裁决PVP模式
|
||||
CR_REFEREE_PVP_END = 4002, //裁决PVP结束
|
||||
|
||||
}
|
@@ -15,4 +15,7 @@ export enum GActionType {
|
||||
GPVPStart = "GPVPStart", //PVP 开始
|
||||
GPVPText = "GPVPText", //PVP 提示
|
||||
|
||||
/*************** 裁决 ********************/
|
||||
GPVPRefereeInfo = "GPVPRefereeInfo" //PVP 裁决信息
|
||||
|
||||
}
|
Submodule JisolGameCocos/extensions/ngame updated: 95f8a3c6c6...e527d34fb6
@@ -9,6 +9,8 @@ message GPVPStart {
|
||||
map<int64, string> leftPets = 2; //左边的宠物 key:宠物Id value 宠物配置Id
|
||||
string rightTactical = 3; //右边的布阵
|
||||
map<int64, string> rightPets = 4; //右边的宠物 key:宠物Id value 宠物配置Id
|
||||
int64 leftPlayerId = 5; //左边的玩家Id
|
||||
int64 rightPlayerId = 6; //右边的玩家Id
|
||||
}
|
||||
|
||||
//PVP 消息提示
|
||||
@@ -16,4 +18,10 @@ message GPVPText {
|
||||
string text = 1; //消息提示
|
||||
}
|
||||
|
||||
//PVP 裁决结束返回
|
||||
message GPVPRefereeInfo{
|
||||
//获胜玩家Id
|
||||
int64 winnerId = 1;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user