mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
修复PVP 切换地图重置数据
This commit is contained in:
@@ -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){
|
||||
|
Reference in New Issue
Block a user