mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
修复PVP 切换地图重置数据
This commit is contained in:
parent
cebe7cc9d3
commit
1e76e420b1
Binary file not shown.
@ -18,7 +18,6 @@
|
||||
"mapImage": "ui/map/魔法镇_图片/spriteFrame",
|
||||
"mapId": 60002,
|
||||
"petIds": [
|
||||
10003,
|
||||
10004
|
||||
],
|
||||
"sign": "",
|
||||
|
@ -98,6 +98,12 @@ export default class GBattleModeManager extends Singleton {
|
||||
|
||||
}
|
||||
|
||||
//重置当前模式
|
||||
Reset(){
|
||||
app.sync.onReset();
|
||||
app.sync.onStart();
|
||||
}
|
||||
|
||||
//关闭当前模式
|
||||
async Close(data?:any){
|
||||
|
||||
|
@ -64,7 +64,14 @@ export default abstract class GRoleBase<T> extends GObject<T>{
|
||||
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<T> extends GObject<T>{
|
||||
//创建角色动画状态机
|
||||
this.fsmAnim = this.fsmAnimCreate();
|
||||
|
||||
//创建数值类
|
||||
this.values = new GRoleValues();
|
||||
// //创建数值类
|
||||
// this.values = new GRoleValues();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
//更新页面
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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){
|
||||
|
@ -6,9 +6,9 @@ option java_package = "cn.jisol.ngame.proto";
|
||||
//PVP 开始
|
||||
message GPVPStart {
|
||||
string leftTactical = 1; //左边的布阵
|
||||
map<int64, string> leftPets = 2; //左边的宠物 key:宠物Id value 宠物配置Id
|
||||
map<int64, string> leftPets = 2; //左边的宠物 key:宠物Id value PlayerPet JSON
|
||||
string rightTactical = 3; //右边的布阵
|
||||
map<int64, string> rightPets = 4; //右边的宠物 key:宠物Id value 宠物配置Id
|
||||
map<int64, string> rightPets = 4; //右边的宠物 key:宠物Id value PlayerPet JSON
|
||||
int64 leftPlayerId = 5; //左边的玩家Id
|
||||
int64 rightPlayerId = 6; //右边的玩家Id
|
||||
}
|
||||
|
@ -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<TbGRole> tdPets = TD.DATA.getTbGRole().getDataList();
|
||||
//获取玩家所在当前地图可生成的宠物
|
||||
ModeOnHook info = this.getInfo(player).data;
|
||||
TbGOnHookMaps mapInfo = TD.DATA.getTbGOnHookMaps().get(info.getOnHookMap());
|
||||
List<TbGRole> tdPets = Arrays.stream(mapInfo.petIds).mapToObj(petId -> TD.DATA.getTbGRole().get(petId)).collect(Collectors.toList());
|
||||
|
||||
//如果小于最大数量则生成
|
||||
while (creeps.size() < max){
|
||||
|
@ -6,9 +6,9 @@ option java_package = "cn.jisol.ngame.proto";
|
||||
//PVP 开始
|
||||
message GPVPStart {
|
||||
string leftTactical = 1; //左边的布阵
|
||||
map<int64, string> leftPets = 2; //左边的宠物 key:宠物Id value 宠物配置Id
|
||||
map<int64, string> leftPets = 2; //左边的宠物 key:宠物Id value PlayerPet JSON
|
||||
string rightTactical = 3; //右边的布阵
|
||||
map<int64, string> rightPets = 4; //右边的宠物 key:宠物Id value 宠物配置Id
|
||||
map<int64, string> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -18,7 +18,6 @@
|
||||
"mapImage": "ui/map/魔法镇_图片/spriteFrame",
|
||||
"mapId": 60002,
|
||||
"petIds": [
|
||||
10003,
|
||||
10004
|
||||
],
|
||||
"sign": "",
|
||||
|
Loading…
x
Reference in New Issue
Block a user