mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 11:24:46 +00:00
更新无限模式
This commit is contained in:
parent
2eca21dab1
commit
ec4d6a15d7
@ -36,7 +36,7 @@ export default class GBaseMode<T> extends GObject<T> {
|
|||||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T) {
|
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: T) {
|
||||||
|
|
||||||
//重置 场景中的层级
|
//重置 场景中的层级
|
||||||
[...this.node.children].sort((node1,node2) => node2.worldPosition.y - node1.worldPosition.y).forEach((node,index) => {
|
[...this.scene.children].sort((node1,node2) => node2.worldPosition.y - node1.worldPosition.y).forEach((node,index) => {
|
||||||
node.setSiblingIndex(index);
|
node.setSiblingIndex(index);
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -88,6 +88,7 @@ export default class GFSMBase{
|
|||||||
|
|
||||||
if(process.to.indexOf(next) == -1 && next != GFSMProcessEnum.Wait && next != GFSMProcessEnum.Reset){
|
if(process.to.indexOf(next) == -1 && next != GFSMProcessEnum.Wait && next != GFSMProcessEnum.Reset){
|
||||||
console.log(`[GFSM]: 流程To中没有这个流程 请检查代码`,process,next);
|
console.log(`[GFSM]: 流程To中没有这个流程 请检查代码`,process,next);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
if(!this.process[next]) next = null;
|
if(!this.process[next]) next = null;
|
||||||
|
|
||||||
|
@ -209,5 +209,10 @@ export default class GRoleDefault extends GRoleBase<{}>{
|
|||||||
this.killBack.push(callback);
|
this.killBack.push(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//判断玩家是否在阵法位置
|
||||||
|
isTacticalPos():boolean{
|
||||||
|
return this.tactical.getPosition(this.tacticalIndex).equals(this.v2World);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
mapInfo:TableGMap;
|
mapInfo:TableGMap;
|
||||||
|
|
||||||
//每一波怪的距离
|
//每一波怪的距离
|
||||||
everyX:number = 1000;
|
everyX:number = 600;
|
||||||
|
|
||||||
//下一波怪的对战位置X
|
//下一波怪的对战位置X
|
||||||
_nextFightX:number = 0;
|
_nextFightX:number = 0;
|
||||||
@ -91,6 +91,7 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
set nextFightX(value:number){
|
set nextFightX(value:number){
|
||||||
//修改玩家阵法位置
|
//修改玩家阵法位置
|
||||||
this.playerInfo.tactical.setOffset(this.playerPos.clone().add(v2(value,0)))
|
this.playerInfo.tactical.setOffset(this.playerPos.clone().add(v2(value,0)))
|
||||||
|
this.enemyInfo.tactical.setOffset(this.enemyPos.clone().add(v2(value,0)))
|
||||||
this._nextFightX = value;
|
this._nextFightX = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,11 +112,9 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
//初始化地图
|
//初始化地图
|
||||||
this.mapInfo = TableGMap.getConfig(60001);
|
this.mapInfo = TableGMap.getConfig(60001);
|
||||||
this.map1.init(app.battleRes.maps[60001][0],1);
|
this.map1.init(app.battleRes.maps[60001][0],1);
|
||||||
this.map1.UpdateMap(0,this.camera.node.worldPosition.x,this.mapInfo.map1OffsetY);
|
|
||||||
this.map2.init(app.battleRes.maps[60001][1],1);
|
this.map2.init(app.battleRes.maps[60001][1],1);
|
||||||
this.map2.UpdateMap(0,this.camera.node.worldPosition.x,this.mapInfo.map2OffsetY);
|
|
||||||
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width,app.battleRes.maps[60001][1].height);
|
this.map3.init(app.battleRes.maps[60001][2],1,app.battleRes.maps[60001][1].width,app.battleRes.maps[60001][1].height);
|
||||||
this.map3.UpdateMap(0,this.camera.node.worldPosition.x,this.mapInfo.map3OffsetY);
|
this.onUpdateMap(0);
|
||||||
|
|
||||||
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) };
|
this.playerInfo = { tactical: GTactical.getTactical().setOffset(this.playerPos), roles: GRoleUtil.getGRoles([10004,10004,10004,10004,10003,10003]) };
|
||||||
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([10002]) };
|
this.enemyInfo = { tactical: GTactical.getTactical(true).setOffset(this.enemyPos), roles: GRoleUtil.getGRoles([10002]) };
|
||||||
@ -123,10 +122,6 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
//生成玩家
|
//生成玩家
|
||||||
this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.PLAYER,index + 1,info))
|
this.playerInfo.roles.forEach((info,index) => this.onGenRole(GOnHookModePlayerEnum.PLAYER,index + 1,info))
|
||||||
|
|
||||||
JNFrameTime.getInstance().setTimeout(() => {
|
|
||||||
//下一波怪
|
|
||||||
this.onNextTarget();
|
|
||||||
})
|
|
||||||
// //生成敌人
|
// //生成敌人
|
||||||
// this.onResetGenerateEnemy();
|
// this.onResetGenerateEnemy();
|
||||||
|
|
||||||
@ -134,10 +129,19 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
|
|
||||||
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}){
|
onSyncUpdate(dt: number,frame:JNFrameInfo, input?: {}){
|
||||||
super.onSyncUpdate(dt,frame,input);
|
super.onSyncUpdate(dt,frame,input);
|
||||||
|
this.onUpdateMap(dt);
|
||||||
this.onUpdateCamera(dt);
|
this.onUpdateCamera(dt);
|
||||||
this.fsm.onUpdate(dt,frame);
|
this.fsm.onUpdate(dt,frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//更新地图
|
||||||
|
onUpdateMap(dt){
|
||||||
|
let cameraX = this.camera.node.worldPosition.x;
|
||||||
|
this.map1.UpdateMap(cameraX,0,this.mapInfo.map1OffsetY);
|
||||||
|
this.map2.UpdateMap(cameraX,cameraX / 10,this.mapInfo.map2OffsetY);
|
||||||
|
this.map3.UpdateMap(cameraX,0,this.mapInfo.map3OffsetY);
|
||||||
|
}
|
||||||
|
|
||||||
//更新相机逻辑
|
//更新相机逻辑
|
||||||
onUpdateCamera(dt:number){
|
onUpdateCamera(dt:number){
|
||||||
|
|
||||||
@ -145,7 +149,7 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
if(!this.isHaveEnemy()){
|
if(!this.isHaveEnemy()){
|
||||||
|
|
||||||
//获取冲到最前面的宠物
|
//获取冲到最前面的宠物
|
||||||
let roles = this.getOnesRole(GOnHookModePlayerEnum.PLAYER);
|
let roles = this.getOnesRoleAlive(GOnHookModePlayerEnum.PLAYER);
|
||||||
let frontRole = roles.sort((role1,role2) => role2.v2World.x - role1.v2World.x)[0];
|
let frontRole = roles.sort((role1,role2) => role2.v2World.x - role1.v2World.x)[0];
|
||||||
if(!frontRole) return;
|
if(!frontRole) return;
|
||||||
|
|
||||||
@ -153,6 +157,10 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
let cameraWorld = this.camera.node.worldPosition.clone();
|
let cameraWorld = this.camera.node.worldPosition.clone();
|
||||||
this.camera.node.worldPosition = cameraWorld.lerp(v3(frontRole.v2World.x,cameraWorld.y,cameraWorld.z),(dt / 1000));
|
this.camera.node.worldPosition = cameraWorld.lerp(v3(frontRole.v2World.x,cameraWorld.y,cameraWorld.z),(dt / 1000));
|
||||||
|
|
||||||
|
}else{
|
||||||
|
//如果有敌人则移动到战斗位置
|
||||||
|
let cameraWorld = this.camera.node.worldPosition.clone();
|
||||||
|
this.camera.node.worldPosition = cameraWorld.lerp(v3(this.nextFightX,cameraWorld.y,cameraWorld.z),(dt / 1000));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -251,11 +259,8 @@ export default class GOnHookMode extends GBaseMode<{}>{
|
|||||||
//前往下一个目标
|
//前往下一个目标
|
||||||
onNextTarget(){
|
onNextTarget(){
|
||||||
|
|
||||||
//如果没有敌人则前往
|
|
||||||
if(!this.isHaveEnemy()){
|
|
||||||
//下一个目标点
|
//下一个目标点
|
||||||
this.nextFightX = this.nextFightX + this.everyX;
|
this.nextFightX = this.nextFightX + this.everyX;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import { Vec2 } from "cc";
|
|||||||
import { GRoleUtil } from "../entity/GRole";
|
import { GRoleUtil } from "../entity/GRole";
|
||||||
import { TableGRole } from "../../../resources/config/ts/TableGRole";
|
import { TableGRole } from "../../../resources/config/ts/TableGRole";
|
||||||
import GRoleDefault from "../base/role/GRoleDefault";
|
import GRoleDefault from "../base/role/GRoleDefault";
|
||||||
|
import { v3 } from "cc";
|
||||||
const { ccclass, property } = _decorator;
|
const { ccclass, property } = _decorator;
|
||||||
|
|
||||||
//PVP 角色
|
//PVP 角色
|
||||||
@ -61,6 +62,9 @@ export default class GPVPMode extends GBaseMode<{}>{
|
|||||||
|
|
||||||
onSyncInitSuccess(): void {
|
onSyncInitSuccess(): void {
|
||||||
|
|
||||||
|
//调整相机
|
||||||
|
let camreaPos = this.camera.node.worldPosition;
|
||||||
|
this.camera.node.worldPosition = v3(0,100,camreaPos.z)
|
||||||
|
|
||||||
//初始化战斗
|
//初始化战斗
|
||||||
console.log("GPVPMode 模式初始化");
|
console.log("GPVPMode 模式初始化");
|
||||||
|
9
JisolGameCocos/assets/script/battle/modes/OnHook.meta
Normal file
9
JisolGameCocos/assets/script/battle/modes/OnHook.meta
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "1.2.0",
|
||||||
|
"importer": "directory",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "29dec340-ed67-481d-b6ef-41c2d4d47f7b",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -1,10 +1,10 @@
|
|||||||
import GFSMBase, { GFSMProcessInfo } from "../../base/fsm/GFSMBase";
|
import GFSMBase, { GFSMProcessEnum, GFSMProcessInfo, GFSMProcessMode } from "../../base/fsm/GFSMBase";
|
||||||
import GOnHookMode from "../GOnHookMode";
|
import GOnHookMode, { GOnHookModePlayerEnum } from "../GOnHookMode";
|
||||||
|
|
||||||
//流程枚举
|
//流程枚举
|
||||||
enum ProcessEnum {
|
enum ProcessEnum {
|
||||||
SeekEnemy = 0, //寻找敌人(场上没有敌人 或者敌人都击杀完)
|
SeekEnemy = 0, //寻找敌人(场上没有敌人 或者敌人都击杀完)
|
||||||
GenNextFight = 1, //下一个战斗位置
|
GenNextFight = 1, //生成下一个战斗位置
|
||||||
LeaveFight = 2, //前往战斗
|
LeaveFight = 2, //前往战斗
|
||||||
GenEnemy = 3, //生成敌人
|
GenEnemy = 3, //生成敌人
|
||||||
Fight = 4, //战斗
|
Fight = 4, //战斗
|
||||||
@ -19,7 +19,100 @@ export default class GFSMOnHookMode extends GFSMBase{
|
|||||||
this.mode = mode;
|
this.mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
start:number = ProcessEnum.SeekEnemy;
|
||||||
|
|
||||||
process:{[key:number]:GFSMProcessInfo} = {
|
process:{[key:number]:GFSMProcessInfo} = {
|
||||||
|
[ProcessEnum.SeekEnemy]:{
|
||||||
|
title:"寻找敌人",
|
||||||
|
mode:GFSMProcessMode.Execute,
|
||||||
|
execute: this.onSeekEnemyProcess.bind(this),
|
||||||
|
to:[ProcessEnum.GenNextFight,ProcessEnum.Fight]
|
||||||
|
},
|
||||||
|
[ProcessEnum.GenNextFight]:{
|
||||||
|
title:"生成下一个战斗位置",
|
||||||
|
mode:GFSMProcessMode.Execute,
|
||||||
|
execute: this.onGenNextFightProcess.bind(this),
|
||||||
|
to:[ProcessEnum.LeaveFight]
|
||||||
|
},
|
||||||
|
[ProcessEnum.LeaveFight]:{
|
||||||
|
title:"前往战斗",
|
||||||
|
mode:GFSMProcessMode.WaitExecute,
|
||||||
|
execute: this.onLeaveFightProcess.bind(this),
|
||||||
|
to:[ProcessEnum.GenEnemy]
|
||||||
|
},
|
||||||
|
[ProcessEnum.GenEnemy]:{
|
||||||
|
title:"生成敌人",
|
||||||
|
mode:GFSMProcessMode.Execute,
|
||||||
|
execute: this.onGenEnemyProcess.bind(this),
|
||||||
|
to:[ProcessEnum.Fight]
|
||||||
|
},
|
||||||
|
[ProcessEnum.Fight]:{
|
||||||
|
title:"战斗",
|
||||||
|
mode:GFSMProcessMode.WaitExecute,
|
||||||
|
execute: this.onFightProcess.bind(this),
|
||||||
|
to:[ProcessEnum.SeekEnemy]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//寻找敌人
|
||||||
|
onSeekEnemyProcess(dt:number){
|
||||||
|
|
||||||
|
//判断是否还有敌人
|
||||||
|
if(this.mode.isHaveEnemy()){
|
||||||
|
return ProcessEnum.Fight; //如果有则攻击
|
||||||
|
}else{
|
||||||
|
return ProcessEnum.GenNextFight; //没有则生成下一个战斗位置
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成下一个战斗位置
|
||||||
|
onGenNextFightProcess(){
|
||||||
|
|
||||||
|
this.mode.onNextTarget();
|
||||||
|
return ProcessEnum.LeaveFight; //前往战斗位置
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//前往战斗
|
||||||
|
onLeaveFightProcess(){
|
||||||
|
|
||||||
|
//判断玩家是否前往到战斗位置
|
||||||
|
let roles = this.mode.getOnesRoleAlive(GOnHookModePlayerEnum.PLAYER);
|
||||||
|
if(roles.length == 0) return GFSMProcessEnum.Reset;
|
||||||
|
|
||||||
|
for (let index = 0; index < roles.length; index++) {
|
||||||
|
const role = roles[index];
|
||||||
|
if(!(role.isTacticalPos())){
|
||||||
|
//如果不在位置则等待
|
||||||
|
return GFSMProcessEnum.Wait;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//到达位置生成敌人
|
||||||
|
return ProcessEnum.GenEnemy;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//生成敌人
|
||||||
|
onGenEnemyProcess(){
|
||||||
|
|
||||||
|
this.mode.onResetGenerateEnemy();
|
||||||
|
return ProcessEnum.Fight;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//战斗
|
||||||
|
onFightProcess(){
|
||||||
|
|
||||||
|
//等待敌人击杀完
|
||||||
|
if(!(this.mode.isHaveEnemy())){
|
||||||
|
return ProcessEnum.SeekEnemy; //击杀完寻找敌人
|
||||||
|
}
|
||||||
|
|
||||||
|
//没有击杀完则等待击杀
|
||||||
|
return GFSMProcessEnum.Wait;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,9 @@
|
|||||||
|
{
|
||||||
|
"ver": "4.0.23",
|
||||||
|
"importer": "typescript",
|
||||||
|
"imported": true,
|
||||||
|
"uuid": "9168aa67-58e4-4334-b5c6-9a7f6161c13b",
|
||||||
|
"files": [],
|
||||||
|
"subMetas": {},
|
||||||
|
"userData": {}
|
||||||
|
}
|
@ -1 +1 @@
|
|||||||
Subproject commit 62e1acdfdb0b1e8ae449e9324d1875934c058d47
|
Subproject commit da33a404f9d0e77d8f923eef3e68c1248e40e794
|
Loading…
x
Reference in New Issue
Block a user