提交新模式

This commit is contained in:
PC-20230316NUNE\Administrator
2023-12-14 19:16:28 +08:00
parent 8fcc85a054
commit 9a3f666df1
12 changed files with 221 additions and 233 deletions

View File

@@ -13,6 +13,9 @@ import GRoleBase from "../base/role/GRoleBase";
import { GTactical } from "../entity/GTactical";
import JNFrameTime from "../../../../extensions/ngame/assets/ngame/sync/frame/game/time/JNFrameTime";
import { TbGPetId } from "../../config/TbGPet";
import GModeTools from "./GModeTools";
import GPetAttribute from "../base/values/attribute/role/GPetAttribute";
import RandomUtil from "../../../../extensions/ngame/assets/ngame/util/RandomUtil";
const { ccclass, property } = _decorator;
//阵营守护 角色
@@ -27,9 +30,9 @@ export enum GCampGuardianEnum{
export default class GCampGuardianMode extends GBaseMode<{},{}>{
//玩家水晶位置
playerPos: Vec2 = new Vec2(-600,0);
playerPos: Vec2 = new Vec2(-800,-100);
//敌方水晶位置
enemyPos: Vec2 = new Vec2(600,0);
enemyPos: Vec2 = new Vec2(800,-100);
//我方水晶
@@ -56,10 +59,9 @@ export default class GCampGuardianMode extends GBaseMode<{},{}>{
//定时器生成
JNFrameTime.getInstance().setInterval(() => {
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.get(TbGPetId.));
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.get(TbGPetId.));
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.get(TbGPetId.));
this.onGenRole(GCampGuardianEnum.ENEMY,TD.TbGRole.get(TbGPetId.));
let max = TD.TbGRole.getDataList().length;
this.onGenRole(GCampGuardianEnum.PLAYER,TD.TbGRole.getDataList()[Math.floor(this.getSync().SyncRandomInt(0,max - 1))]);
this.onGenRole(GCampGuardianEnum.ENEMY,TD.TbGRole.getDataList()[Math.floor(this.getSync().SyncRandomInt(0,max - 1))]);
},1000)
}
@@ -106,20 +108,54 @@ export default class GCampGuardianMode extends GBaseMode<{},{}>{
//初始化
entity.onInit(type,info,tactical,tactical.getPosXY(1,1));
// //绑定寻敌
// entity.onQueryEunmy = () => {
// return this.getEnumy(entity,type);
// }
//绑定寻敌
entity.onQueryEunmy = () => {
return GModeTools.getNearbyEnumy(entity,this.getOnesRoleAlive(type == GCampGuardianEnum.PLAYER ? GCampGuardianEnum.ENEMY : GCampGuardianEnum.PLAYER));
}
// //绑定死亡回调
//绑定死亡回调
// entity.addKillBackEvent(this.onRoleKillBack.bind(this))
//添加宠物属性
entity.onEffectiveValue(new GPetAttribute({
petId:info.id,
petPlayerId:0,
petTbId:info.id,
petLevel:0,
petStar:0,
petStarExp:0,
}));
// //绑定受击回调
// entity.addHitCallback(this.onHitBack.bind(this));
this.addGObject(entity,pos);
this.getOnesRole(type).push(entity);
return entity;
}
//获取阵营宠物
getOnesRole(type: GCampGuardianEnum):GRoleBase<{}>[]{
if(type == GCampGuardianEnum.PLAYER) return this.playerRoles;
if(type == GCampGuardianEnum.ENEMY) return this.enemyRoles;
}
//获取存活的宠物
getOnesRoleAlive(type: GCampGuardianEnum):GRoleBase<{}>[]{
if(type == GCampGuardianEnum.PLAYER) return this.playerRoles.filter(role => !!role.get());
if(type == GCampGuardianEnum.ENEMY) return this.enemyRoles.filter(role => !!role.get());
}
//角色死亡回调
onRoleKillBack(role:GRoleDefault){
//死亡销毁
JNFrameTime.getInstance().setTimeout(() => {
if(role.isValid)
role.node.destroy()
},3000)
}
}