mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
更新主页内容
This commit is contained in:
@@ -1,14 +1,137 @@
|
||||
import { Prefab } from "cc";
|
||||
import Singleton from "../../../extensions/ngame/assets/ngame/util/Singleton";
|
||||
import { Camera } from "cc";
|
||||
import GBaseMode from "./GBaseMode";
|
||||
import { Node } from "cc";
|
||||
import { instantiate } from "cc";
|
||||
import { app } from "../App";
|
||||
import { JNFrameInfo, JNSyncFrameEvent } from "../../../extensions/ngame/assets/ngame/sync/frame/JNSyncFrame";
|
||||
|
||||
export enum BattleMode{
|
||||
//无尽模式
|
||||
OnHook = 0,
|
||||
//PVP 模式
|
||||
PVP,
|
||||
PVP = 1,
|
||||
}
|
||||
|
||||
export interface GBattleModeInfo{
|
||||
modes:Prefab[], //模式预制体
|
||||
camera:Camera, //场景相机
|
||||
root:Node, //世界场景Root
|
||||
}
|
||||
|
||||
//全局战斗模式管理器
|
||||
export default class GBattleModeManager extends Singleton {
|
||||
|
||||
//模式预制体
|
||||
modes:Prefab[] = [];
|
||||
//场景相机
|
||||
camera:Camera;
|
||||
//世界场景Root
|
||||
root:Node;
|
||||
|
||||
//是否初始化
|
||||
isInit:boolean = false;
|
||||
|
||||
//当前模式
|
||||
current:BattleMode = null;
|
||||
|
||||
//是否自动退帧
|
||||
isAuto:boolean = false;
|
||||
|
||||
//自动推帧间隔
|
||||
autoTime:number = 0;
|
||||
|
||||
//初始化管理器
|
||||
async onInit(info:GBattleModeInfo){
|
||||
|
||||
this.modes = info.modes || [];
|
||||
this.camera = info.camera;
|
||||
this.root = info.root;
|
||||
|
||||
//监听帧同步 世界创建逻辑
|
||||
app.event.on(JNSyncFrameEvent.CLEAR,this.clear,this);
|
||||
app.event.on(JNSyncFrameEvent.CREATE,this.create,this);
|
||||
|
||||
this.isInit = true;
|
||||
|
||||
}
|
||||
|
||||
//打开指定模式
|
||||
async Open(mode:BattleMode,isAuto:boolean = false){
|
||||
|
||||
await this.Close();
|
||||
|
||||
this.current = mode;
|
||||
this.setAuto(isAuto);
|
||||
|
||||
app.sync.onReset();
|
||||
app.sync.onStart();
|
||||
|
||||
}
|
||||
|
||||
//关闭当前模式
|
||||
async Close(){
|
||||
|
||||
//主动调用场景销毁
|
||||
app.sync.onReset();
|
||||
this.clear();
|
||||
this.current = null;
|
||||
|
||||
}
|
||||
|
||||
//设置自动推帧 ( 帧不由addFrame控制 管理器自动推帧)
|
||||
setAuto(is:boolean){
|
||||
this.isAuto = is;
|
||||
this.autoTime = 0;
|
||||
}
|
||||
|
||||
//清除当前模式
|
||||
private clear(){
|
||||
if(!this.isInit) return;
|
||||
this.root.destroyAllChildren();
|
||||
}
|
||||
|
||||
//创建当前模式
|
||||
private create(){
|
||||
if(!this.isInit || this.current == null) return;
|
||||
let mode = instantiate(this.modes[this.current]);
|
||||
mode.getComponent(GBaseMode).camera = this.camera;
|
||||
this.root.addChild(mode)
|
||||
|
||||
}
|
||||
|
||||
//向场景推帧
|
||||
addFrame(info:JNFrameInfo){
|
||||
if(this.isAuto) return; //如果是自动推帧则返回
|
||||
app.sync.addFrame(info,true);
|
||||
}
|
||||
|
||||
//管理器更新
|
||||
onUpdate(dt:number){
|
||||
//更新帧同步
|
||||
app.sync.update(dt);
|
||||
//自动推帧
|
||||
this.onAutoFrame(dt);
|
||||
}
|
||||
|
||||
//自动推帧
|
||||
private onAutoFrame(dt:number){
|
||||
|
||||
if(!this.isAuto) return;
|
||||
|
||||
this.autoTime += dt * 1000;
|
||||
|
||||
//获取当前帧同步的帧数推空帧
|
||||
if(app.sync.nSyncTime < this.autoTime){
|
||||
//如果事件够则推帧
|
||||
this.autoTime -= app.sync.nSyncTime;
|
||||
app.sync.addFrame({
|
||||
index:app.sync.nLocalFrame + 1
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import { Vec2 } from "cc";
|
||||
import { JNGSyncProtoBase } from "../../App";
|
||||
import GBaseMode from "../GBaseMode";
|
||||
import { v2 } from "cc";
|
||||
import { JNGSyncProtoBase } from "../../components/JNComponent";
|
||||
|
||||
export enum GTowards{
|
||||
RIGHT,LEFT
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { _decorator, Component, Node } from 'cc';
|
||||
import { app, JNGSyncBase } from '../../../../App';
|
||||
import { SpriteFrame } from 'cc';
|
||||
import { Sprite } from 'cc';
|
||||
import { UITransform } from 'cc';
|
||||
import { v3 } from 'cc';
|
||||
import { size } from 'cc';
|
||||
import GNode from '../GNode';
|
||||
import { JNGSyncBase } from '../../../../components/JNComponent';
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/**
|
||||
|
@@ -106,16 +106,19 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
||||
|
||||
//调整相机
|
||||
let camreaPos = this.camera.node.worldPosition;
|
||||
this.camera.node.worldPosition = v3(0,100,camreaPos.z)
|
||||
this.camera.node.worldPosition = v3(0,800,camreaPos.z)
|
||||
|
||||
//初始化状态机
|
||||
this.fsm = new GFSMOnHookMode(this);
|
||||
|
||||
//初始化地图
|
||||
this.mapInfo = TD.TbGMap.get(60001);
|
||||
this.map1.init(app.battleRes.maps[60001][0],1);
|
||||
this.map2.init(app.battleRes.maps[60001][1],1);
|
||||
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width,app.battleRes.maps[60001][1].height);
|
||||
|
||||
let scale = this.mapInfo.scale;
|
||||
|
||||
this.map1.init(app.battleRes.maps[60001][0],1,app.battleRes.maps[60001][0].width * scale,app.battleRes.maps[60001][0].height * scale);
|
||||
this.map2.init(app.battleRes.maps[60001][1],1,app.battleRes.maps[60001][1].width * scale,app.battleRes.maps[60001][1].height * scale);
|
||||
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width * scale,1048 * scale);
|
||||
this.onUpdateMap(0);
|
||||
|
||||
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) };
|
||||
|
Reference in New Issue
Block a user