无头模式测试

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2023-11-22 03:51:37 +08:00
parent 5ab90ea221
commit 7389f6d716
535 changed files with 991 additions and 162534 deletions

View File

@@ -28,8 +28,10 @@ import AppAction from "./AppAction";
// let APIPath = `http://localhost:8080`
// let WsPath = `ws://localhost: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.174:8080`
// let WsPath = `ws://192.168.0.174:8080/websocket`
// let APIPath = `https://api.pet.jisol.cn`
// let WsPath = `wss://api.pet.jisol.cn/websocket`
@@ -229,7 +231,8 @@ export const app = {
}
app.api.addRequestInterceptors((config:JAPIConfig) => {
//设置Token
config.headers["Token"] = StorageData.get(StorageEnum.Token);
// //设置Token
// if(StorageData.get(StorageEnum.Token))
// config.headers["Token"] = StorageData.get(StorageEnum.Token);
return true;
})

View File

@@ -0,0 +1,8 @@
//打包环境
export enum Env{
Server, //服务器模式
H5, //H5模式
}
//当前环境
export const EnvCurrent:Env = Env.Server;

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "6afed554-ecb2-4126-a8b6-16f3b30dfab1",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -3,8 +3,12 @@ import { app } from './App';
import { Env, JNGame } from '../../extensions/ngame/assets/ngame/JNGame';
import { JNSyncAction } from '../../extensions/ngame/assets/ngame/sync/JNSyncAction';
import { GOnHookPets } from '../../extensions/ngame/assets/ngame/message/proto';
import { EnvCurrent } from './Env';
const { ccclass, property } = _decorator;
window['GUser'] = "100000";
window['GPassworld'] = "123456";
@ccclass('Main')
export class Main extends Component {
@@ -16,14 +20,16 @@ export class Main extends Component {
async onLoad(){
console.log("EnvCurrent",EnvCurrent)
// 创建UI
director.getScene().addChild(instantiate(this.UIPrefab));
//加载 APP
await JNGame.Init(app);
//发生帧同步开始
app.socket.Send(JNSyncAction.NSyncFrameStart);
// //发生帧同步开始
// app.socket.Send(JNSyncAction.NSyncFrameStart);
// 创建世界
director.getScene().addChild(instantiate(this.WorldPrefab));

View File

@@ -1,4 +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 { GAction } from "../consts/GAction";
import { GActionType } from "../consts/GActionType";
@@ -24,6 +26,10 @@ export default class PVPAction extends BaseAction {
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);
app.socket.on(GAction.C_MODE_PVP_MESSAGE,this.onModePVPMessage,this,GActionType.GPVPText);
if(EnvCurrent == Env.Server){
app.socket.on(GAction.CR_REFEREE_PVP_MODE,this.onCrReferee,this,GActionType.GPVPStart); //监听PVP裁决
}
}
//PVP开始等待
@@ -44,6 +50,13 @@ export default class PVPAction extends BaseAction {
GBattleModeManager.getIns().Open(BattleMode.PVP,true,info);
}
//裁决运行
onCrReferee(info:GPVPStart){
console.log("开始PVP裁决",info);
GBattleModeManager.getIns().Open(BattleMode.PVP,false,info);
GBattleModeManager.getIns().setAuto(true,true);
}
//提示
onModePVPMessage(info:GPVPText){
console.log("提示PVP",info);

View File

@@ -7,6 +7,7 @@ import { instantiate } from "cc";
import { app } from "../App";
import { JNFrameInfo, JNSyncFrameEvent } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
import { CCObject } from "cc";
import { Env, EnvCurrent } from "../Env";
export enum BattleMode{
//无尽模式
@@ -37,8 +38,10 @@ export default class GBattleModeManager extends Singleton {
//当前模式
current:BattleMode = null;
//是否自动退
//是否自动
isAuto:boolean = false;
//是否推追帧
isAutoMaxFrame:boolean = false;
//自动推帧间隔
autoTime:number = 0;
@@ -73,6 +76,8 @@ export default class GBattleModeManager extends Singleton {
this.data = data;
if(!this.current && mode == null){
//裁决员不允许默认模式
if(EnvCurrent == Env.Server) return;
await this.Open(this.default,true,data);
return;
}else if(mode == null){
@@ -98,11 +103,14 @@ export default class GBattleModeManager extends Singleton {
}
//设置自动推帧 ( 帧不由addFrame控制 管理器自动推帧)
setAuto(is:boolean){
setAuto(is:boolean,isAutoMaxFrame:boolean = false){
this.isAuto = is;
this.isAutoMaxFrame = isAutoMaxFrame;
this.autoTime = 0;
}
//设置自动追帧
//清除当前模式
private clear(){
if(!this.isInit) return;
@@ -146,15 +154,31 @@ export default class GBattleModeManager extends Singleton {
if(!this.isAuto) return;
this.autoTime += dt * 1000;
if(this.isAutoMaxFrame){
//保持超高频率追帧
while(app.sync.nFrameQueue.length < (app.sync.nMaxFrameLoopBan * 2)){
//速度推帧
app.sync.addFrame({
index:app.sync.nLocalFrame + 1
});
}
}else{
//正常追帧
this.autoTime += dt * 1000;
//获取当前帧同步的帧数推空帧
if(app.sync.nSyncTime < this.autoTime){
//如果事件够则推帧
this.autoTime -= app.sync.nSyncTime;
app.sync.addFrame({
index:app.sync.nLocalFrame + 1
});
}
//获取当前帧同步的帧数推空帧
if(app.sync.nSyncTime < this.autoTime){
//如果事件够则推帧
this.autoTime -= app.sync.nSyncTime;
app.sync.addFrame({
index:app.sync.nLocalFrame + 1
});
}
}

View File

@@ -216,6 +216,7 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{
this.isEndGame = true;
//结束游戏
JNFrameTime.getInstance().setTimeout(() => {
console.log(this.getOnesRoleAlive(GPVPModePlayerEnum.PLAYER).length,this.getOnesRoleAlive(GPVPModePlayerEnum.ENEMY).length)
this.Close();
},3000)
}

View File

@@ -17,4 +17,8 @@ export enum GAction {
C_MODE_PVP_END_WAIT = 3007, //结束等待PVP开始
C_MODE_PVP_MESSAGE = 3008, //PVP 消息通知
/*************** 裁决 *********************/
CR_REFEREE_PVP_MODE = 4001, //裁决PVP模式
}

View File

@@ -6,6 +6,7 @@ import NoviceManager from "../../manager/NoviceManager";
import { JNGLayerBase } from "../../components/JNComponent";
import { app } from "../../App";
import { lerp } from "cc";
import { Env, EnvCurrent } from "../../Env";
const { ccclass, property } = _decorator;
@ccclass('LoadingView')
@@ -35,7 +36,12 @@ export default class LoadingView extends JNGLayerBase {
await NoviceManager.getIns().onStart();
//关闭加载页
await app.layer.Open(GUI.Main);
if(EnvCurrent == Env.Server){
//打开服务器主页
await app.layer.Open(GUI.ServerMain);
}else{
await app.layer.Open(GUI.Main);
}
app.layer.Close(GUI.Loading);
}

View File

@@ -5,6 +5,7 @@ import { EditBox } from 'cc';
import { app } from '../../App';
import { GUI } from '../UIConfig';
import { StorageData, StorageEnum } from '../../consts/GData';
import { Env, EnvCurrent } from '../../Env';
const { ccclass, property } = _decorator;
@ccclass('LoginView')
@@ -20,6 +21,13 @@ export class LoginView extends JNLayerBase {
onJNLoad(resolve?: (token:string) => void): void {
super.onJNLoad();
this.resolve = resolve;
//如果是服务器则取Windows账号密码
if(EnvCurrent == Env.Server){
this.account.string = window['GUser'];
this.password.string = window['GPassworld'];
this.onClickLogin();
}
}

View File

@@ -26,8 +26,9 @@ export enum GUI{
/**游戏模式页面 */
PVPModeMatchView = "PVPModeMatchView", //PVP模式匹配页面
Home = "Home", //主页面
Main = "Main", //主页面2
Home = "Home", //主页面
Main = "Main", //主页面2
ServerMain = "ServerMain", //服务器主页
}
@@ -132,6 +133,16 @@ export const UIConfig:{ [key: string]: JNLayerInfo; } = {
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
},
},
[GUI.ServerMain]:{
layer:GLayer.View,
uri: "prefab/ui/主页/ServerMainView",
anims:{
front:JNLayerAnim.Enlarge,
back:JNLayerAnim.Smaller,
frontInfo:{key:"position",start:v3(720,0,0),end:v3(0,0,0)},
backInfo:{key:"position",start:v3(0,0,0),end:v3(-720,0,0)}
},
},
...UISystemConfig, //系统页面
...UINoviceConfig, //新手引导页面
...UIMainConfig, //主页面