mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 02:36:14 +00:00
提交新模式
This commit is contained in:
@@ -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)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
29
JisolGameCocos/assets/script/battle/modes/GModeTools.ts
Normal file
29
JisolGameCocos/assets/script/battle/modes/GModeTools.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { Vec2 } from "cc";
|
||||
import GRoleBase from "../base/role/GRoleBase";
|
||||
|
||||
//模式工具类
|
||||
export default class GModeTools{
|
||||
|
||||
//通过距离获取最近的敌人
|
||||
static getNearbyEnumy(player:GRoleBase<{}>,roles:GRoleBase<{}>[]){
|
||||
//通过距离获取最近的敌人
|
||||
if(roles[0]){
|
||||
let len = Math.abs(Vec2.distance(player.v2World,roles[0].v2World));
|
||||
let enumy = roles[0];
|
||||
for (let index = 0; index < roles.length; index++) {
|
||||
const role = roles[index];
|
||||
let tLen;
|
||||
if(tLen = Math.abs(Vec2.distance(player.v2World,role.v2World)) < len){
|
||||
enumy = role;
|
||||
len = tLen;
|
||||
}
|
||||
|
||||
}
|
||||
return enumy;
|
||||
}else{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2e0c3126-ff69-4923-9ad6-21821ade5e93",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user