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