diff --git a/DataTables/Datas/战斗/模式/无尽模式/OnHook地图.xlsx b/DataTables/Datas/战斗/模式/无尽模式/OnHook地图.xlsx index 06922d40..e5ec9662 100644 Binary files a/DataTables/Datas/战斗/模式/无尽模式/OnHook地图.xlsx and b/DataTables/Datas/战斗/模式/无尽模式/OnHook地图.xlsx differ diff --git a/JisolGameCocos/assets/resources/config/json/tbgonhookmaps.json b/JisolGameCocos/assets/resources/config/json/tbgonhookmaps.json index 953dd292..ebcd8ef4 100644 --- a/JisolGameCocos/assets/resources/config/json/tbgonhookmaps.json +++ b/JisolGameCocos/assets/resources/config/json/tbgonhookmaps.json @@ -18,7 +18,6 @@ "mapImage": "ui/map/魔法镇_图片/spriteFrame", "mapId": 60002, "petIds": [ - 10003, 10004 ], "sign": "", diff --git a/JisolGameCocos/assets/script/battle/GBattleModeManager.ts b/JisolGameCocos/assets/script/battle/GBattleModeManager.ts index 2dd89c9d..8b8a54c6 100644 --- a/JisolGameCocos/assets/script/battle/GBattleModeManager.ts +++ b/JisolGameCocos/assets/script/battle/GBattleModeManager.ts @@ -98,6 +98,12 @@ export default class GBattleModeManager extends Singleton { } + //重置当前模式 + Reset(){ + app.sync.onReset(); + app.sync.onStart(); + } + //关闭当前模式 async Close(data?:any){ diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts b/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts index ed00d31e..5ed53f4b 100644 --- a/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts @@ -64,7 +64,14 @@ export default abstract class GRoleBase extends GObject{ addAttackCallback(fun:Function){this.attackCallbacks.push(fun)}; //角色数值类 - values:GRoleValues; + _values:GRoleValues; + get values(){ + if(!this._values) this._values = new GRoleValues(); + return this._values; + } + set values(value){ + this._values = value; + } get():this{ if(this.isDie) return null; @@ -85,8 +92,8 @@ export default abstract class GRoleBase extends GObject{ //创建角色动画状态机 this.fsmAnim = this.fsmAnimCreate(); - //创建数值类 - this.values = new GRoleValues(); + // //创建数值类 + // this.values = new GRoleValues(); } diff --git a/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts b/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts index 43d17a9d..d1599a7f 100644 --- a/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts +++ b/JisolGameCocos/assets/script/battle/modes/GOnHookMode.ts @@ -100,13 +100,13 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{ //添加监听事件 addEvent(){ app.event.on(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this); - app.event.on(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this); + // app.event.on(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this); } //移除监听事件 onDestroy(){ super.onDestroy(); app.event.off(PlayerTacticalEvent.UPDATE_TACTICAL,this.onUpdatePlayerPet,this); - app.event.off(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this); + // app.event.off(GOnHookManagerEvent.UPDATE_MAP,this.onUpdateWorld,this); } onSyncInitSuccess():void{ @@ -151,7 +151,7 @@ export default class GOnHookMode extends GDefaultMode<{},{}>{ //更新地图 onUpdateWorld(){ let info = TD.TbGOnHookMaps.get(GOnHookData.getIns().info.onHookMap); - this.setWorldMap(info.mapId) + this.setWorldMap(info.mapId); } //更新页面 diff --git a/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts b/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts index 65d38147..9a935571 100644 --- a/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts +++ b/JisolGameCocos/assets/script/battle/modes/GPVPMode.ts @@ -14,6 +14,7 @@ import { app, TD } from "../../App"; import { ModeRenderEvent } from "../../ui/Consts/Game/ModeRender"; import { GPVPStart } from "../../action/PVPAction"; import { PlayerPetOV } from "../../consts/API"; +import GPetAttribute from "../base/values/attribute/role/GPetAttribute"; const { ccclass, property } = _decorator; //PVP 角色 @@ -27,7 +28,7 @@ export interface GPVPModePlayerInfo{ //阵法 tactical: GTactical; //宠物列表 - roles: TB.TbGRole[]; + roles: PlayerPetOV[]; } /** @@ -72,26 +73,29 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{ let rightTactical:number[] = JSON.parse(this.data.rightTactical); //宠物列表 - let leftTbs:TB.TbGRole[] = JSON.parse(this.data.leftTactical); - let rightTbs:TB.TbGRole[] = JSON.parse(this.data.rightTactical); + let leftTbs:PlayerPetOV[] = []; + let rightTbs:PlayerPetOV[] = []; - //玩家宠物信息 + //整理宠物信息 for (let index = 0; index < leftTactical.length; index++) { const petId = leftTactical[index]; + leftTbs[index] = null; + if(petId != 0){ let pet:PlayerPetOV = JSON.parse(this.data.leftPets[petId]); - leftTbs[index] = TD.TbGRole.get(pet.petTbId); - }else{ - leftTbs[index] = null; + if(pet && pet.petId) + leftTbs[index] = pet; } } + for (let index = 0; index < rightTactical.length; index++) { const petId = rightTactical[index]; + rightTbs[index] = null; + if(petId != 0){ let pet:PlayerPetOV = JSON.parse(this.data.leftPets[petId]); - rightTbs[index] = TD.TbGRole.get(pet.petTbId); - }else{ - rightTbs[index] = null; + if(pet && pet.petId) + rightTbs[index] = pet; } } @@ -119,7 +123,7 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{ } //生成角色 - onGenRole(type: GPVPModePlayerEnum,index:number,info:TB.TbGRole) { + onGenRole(type: GPVPModePlayerEnum,index:number,info:PlayerPetOV) { let tactical = this.getInfo(type).tactical; let pos:Vec2 = this.getInfo(type).tactical.getPosition(index); @@ -127,7 +131,7 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{ let role = instantiate(this.rolePrefab); let entity = role.getComponent(GRoleDefault); //初始化 - entity.onInit(type,info,tactical,index); + entity.onInit(type,TD.TbGRole.get(info.petTbId),tactical,index); //绑定寻敌 entity.onQueryEunmy = () => { @@ -139,6 +143,9 @@ export default class GPVPMode extends GBaseMode<{},GPVPStart>{ //绑定死亡回调 entity.addKillBackEvent(this.onRoleKillBack.bind(this)) + //添加宠物属性 + entity.onEffectiveValue(new GPetAttribute(info)); + this.addGObject(entity,tactical.getPosition(index)); this.getOnesRole(type).push(entity); diff --git a/JisolGameCocos/assets/script/manager/battle/mode/GOnHookManager.ts b/JisolGameCocos/assets/script/manager/battle/mode/GOnHookManager.ts index 77babbff..65ac652f 100644 --- a/JisolGameCocos/assets/script/manager/battle/mode/GOnHookManager.ts +++ b/JisolGameCocos/assets/script/manager/battle/mode/GOnHookManager.ts @@ -1,6 +1,7 @@ import { GOnHookPet } from "../../../../../extensions/ngame/assets/ngame/message/proto"; import Singleton from "../../../../../extensions/ngame/assets/ngame/util/Singleton"; import { app } from "../../../App"; +import GBattleModeManager, { BattleMode } from "../../../battle/GBattleModeManager"; import { PlayerPetOV } from "../../../consts/API"; import { GAPI } from "../../../consts/GAPI"; import GOnHookData from "../../../data/GOnHookData"; @@ -12,6 +13,8 @@ export enum GOnHookManagerEvent{ ADD_KILL_SREEP = "GOnHookManagerEvent_ADD_KILL_SREEP", //删除死亡野怪 DEL_KILL_SREEP = "GOnHookManagerEvent_DEL_KILL_SREEP", + //重置数据 + RESET_DATA = "GOnHookManagerEvent_RESET_DATA", //删除死亡野怪 UPDATE_MAP = "GOnHookManagerEvent_UPDATE_MAP" } @@ -26,7 +29,7 @@ export default class GOnHookManager extends Singleton{ if(!this._sreeps || !(this._sreeps.size)){ //生成 this.onSpawnSreeps(); - return null; + return new Map(); } return this._sreeps; } @@ -119,6 +122,13 @@ export default class GOnHookManager extends Singleton{ return await GAPI.GOnHookSellCreeps(creeps.key); } + //重置数据 + onResetData(){ + this._sreeps = new Map(); + this.killSreeps = []; + app.event.emit(GOnHookManagerEvent.RESET_DATA); + } + //切换场景 async setMap(mapId:number){ @@ -126,6 +136,10 @@ export default class GOnHookManager extends Singleton{ //通知地图已切换 app.event.emit(GOnHookManagerEvent.UPDATE_MAP); + //重置数据 + this.onResetData(); + //重置场景 + GBattleModeManager.getIns().Open(BattleMode.OnHook,true); } diff --git a/JisolGameCocos/assets/script/ui/Home/Sreeps/MainSreepsList.ts b/JisolGameCocos/assets/script/ui/Home/Sreeps/MainSreepsList.ts index 82397d98..fc0265b2 100644 --- a/JisolGameCocos/assets/script/ui/Home/Sreeps/MainSreepsList.ts +++ b/JisolGameCocos/assets/script/ui/Home/Sreeps/MainSreepsList.ts @@ -24,6 +24,8 @@ export class MainSreepsList extends Component { app.event.on(GOnHookManagerEvent.ADD_KILL_SREEP,this.onAddSreep,this); //监听 野怪删除 app.event.on(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this); + //监听 野怪数据重置 + app.event.on(GOnHookManagerEvent.RESET_DATA,this.onResetData,this); //添加子节点事件 this.views.addItemEvent(NodeEventType.TOUCH_END,this.onClickItem.bind(this)); @@ -34,9 +36,14 @@ export class MainSreepsList extends Component { //取消监听 app.event.off(GOnHookManagerEvent.ADD_KILL_SREEP,this.onAddSreep,this); - app.event.on(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this); + app.event.off(GOnHookManagerEvent.DEL_KILL_SREEP,this.onDelSreep,this); + app.event.off(GOnHookManagerEvent.RESET_DATA,this.onResetData,this); } + //重置数据 + onResetData(){ + this.views.refreshData([]); + } //添加野怪 onAddSreep(sreep:GOnHookPet){ diff --git a/JisolGameCocos/proto/GPVPMessage.proto b/JisolGameCocos/proto/GPVPMessage.proto index 94ef6ad0..87e8679e 100644 --- a/JisolGameCocos/proto/GPVPMessage.proto +++ b/JisolGameCocos/proto/GPVPMessage.proto @@ -6,9 +6,9 @@ option java_package = "cn.jisol.ngame.proto"; //PVP 开始 message GPVPStart { string leftTactical = 1; //左边的布阵 - map leftPets = 2; //左边的宠物 key:宠物Id value 宠物配置Id + map leftPets = 2; //左边的宠物 key:宠物Id value PlayerPet JSON string rightTactical = 3; //右边的布阵 - map rightPets = 4; //右边的宠物 key:宠物Id value 宠物配置Id + map rightPets = 4; //右边的宠物 key:宠物Id value PlayerPet JSON int64 leftPlayerId = 5; //左边的玩家Id int64 rightPlayerId = 6; //右边的玩家Id } diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/mode/GOnHookController.java b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/mode/GOnHookController.java index ae262c6d..7cdc5780 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/mode/GOnHookController.java +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/controller/game/mode/GOnHookController.java @@ -29,10 +29,8 @@ import org.springframework.retry.annotation.Retryable; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Map; -import java.util.Objects; +import java.util.*; +import java.util.stream.Collectors; @Api(value = "JNGameDemo - API", tags = {"无尽模式 - API"}) @RestController @@ -89,6 +87,8 @@ public class GOnHookController { ModeOnHook data = this.getInfo(player).data; data.setOnHookMap(mapId); modeOnHookService.saveOrUpdate(data); + //切换地图 清理历史野怪 + CREEPS.put(player.getPlayerId(),new HashMap<>()); return NewsContext.onSuccess("成功",data); } @@ -112,8 +112,10 @@ public class GOnHookController { //获取可生成的最大数量 int max = Integer.parseInt(TD.DATA.getTbGOnHookGlobal().get(GlobalId.MODE_ON_HOOK_SPAWN_NUM).args); - //获取配置表全部宠物 - ArrayList tdPets = TD.DATA.getTbGRole().getDataList(); + //获取玩家所在当前地图可生成的宠物 + ModeOnHook info = this.getInfo(player).data; + TbGOnHookMaps mapInfo = TD.DATA.getTbGOnHookMaps().get(info.getOnHookMap()); + List tdPets = Arrays.stream(mapInfo.petIds).mapToObj(petId -> TD.DATA.getTbGRole().get(petId)).collect(Collectors.toList()); //如果小于最大数量则生成 while (creeps.size() < max){ diff --git a/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GPVPMessage.proto b/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GPVPMessage.proto index 94ef6ad0..b5c9699b 100644 --- a/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GPVPMessage.proto +++ b/JisolGameServer/Main/src/main/java/cn/jisol/game/proto/GPVPMessage.proto @@ -6,9 +6,9 @@ option java_package = "cn.jisol.ngame.proto"; //PVP 开始 message GPVPStart { string leftTactical = 1; //左边的布阵 - map leftPets = 2; //左边的宠物 key:宠物Id value 宠物配置Id + map leftPets = 2; //左边的宠物 key:宠物Id value PlayerPet JSON string rightTactical = 3; //右边的布阵 - map rightPets = 4; //右边的宠物 key:宠物Id value 宠物配置Id + map rightPets = 4; //右边的宠物 key:宠物Id value PlayerPet JSON int64 leftPlayerId = 5; //左边的玩家Id int64 rightPlayerId = 6; //右边的玩家Id } @@ -22,6 +22,4 @@ message GPVPText { message GPVPRefereeInfo{ //获胜玩家Id int64 winnerId = 1; -} - - +} \ No newline at end of file diff --git a/JisolGameServer/Main/src/main/resources/json/tbgonhookmaps.json b/JisolGameServer/Main/src/main/resources/json/tbgonhookmaps.json index 953dd292..ebcd8ef4 100644 --- a/JisolGameServer/Main/src/main/resources/json/tbgonhookmaps.json +++ b/JisolGameServer/Main/src/main/resources/json/tbgonhookmaps.json @@ -18,7 +18,6 @@ "mapImage": "ui/map/魔法镇_图片/spriteFrame", "mapId": 60002, "petIds": [ - 10003, 10004 ], "sign": "",