From 9a3f666df1fe7c0cf719fa8ab29a418b6d003563 Mon Sep 17 00:00:00 2001 From: "PC-20230316NUNE\\Administrator" <2858626794@qq.com> Date: Thu, 14 Dec 2023 19:16:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E6=96=B0=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/resources/WorldCanvas.prefab | 2 +- .../battle/mode/CampGuardianMode.prefab | 294 ++++++------------ .../模式/CampGuardian/阵营守护战斗页面.prefab | 28 +- .../renders/CampGuardianMode/CampGuardian.rt | 2 +- .../CampGuardianMode/CampGuardian.rt.meta | 4 +- JisolGameCocos/assets/script/App.ts | 4 +- .../battle/base/fsm/Default/GFSMDefault.ts | 6 +- .../script/battle/base/role/GRoleDefault.ts | 16 +- .../script/battle/modes/GCampGuardianMode.ts | 58 +++- .../assets/script/battle/modes/GModeTools.ts | 29 ++ .../script/battle/modes/GModeTools.ts.meta | 9 + JisolGameCocos/extensions/ngame | 2 +- 12 files changed, 221 insertions(+), 233 deletions(-) create mode 100644 JisolGameCocos/assets/script/battle/modes/GModeTools.ts create mode 100644 JisolGameCocos/assets/script/battle/modes/GModeTools.ts.meta diff --git a/JisolGameCocos/assets/resources/WorldCanvas.prefab b/JisolGameCocos/assets/resources/WorldCanvas.prefab index 320083ac..e44cbb65 100644 --- a/JisolGameCocos/assets/resources/WorldCanvas.prefab +++ b/JisolGameCocos/assets/resources/WorldCanvas.prefab @@ -156,7 +156,7 @@ "_shutter": 7, "_iso": 0, "_screenScale": 1, - "_visibility": 1073741825, + "_visibility": 1, "_targetTexture": { "__uuid__": "a0d1e275-5512-493e-8e15-7d2db8beb48e", "__expectedType__": "cc.RenderTexture" diff --git a/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab b/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab index 2ae27243..b30e49ed 100644 --- a/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab +++ b/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab @@ -22,23 +22,26 @@ "__id__": 2 }, { - "__id__": 18 + "__id__": 8 }, + { + "__id__": 14 + }, + { + "__id__": 18 + } + ], + "_active": true, + "_components": [ { "__id__": 22 - } - ], - "_active": true, - "_components": [ - { - "__id__": 26 }, { - "__id__": 28 + "__id__": 24 } ], "_prefab": { - "__id__": 30 + "__id__": 26 }, "_lpos": { "__type__": "cc.Vec3", @@ -69,85 +72,31 @@ }, "_id": "" }, - { - "__type__": "cc.Node", - "_name": "Map", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 1 - }, - "_children": [ - { - "__id__": 3 - }, - { - "__id__": 9 - } - ], - "_active": true, - "_components": [ - { - "__id__": 15 - } - ], - "_prefab": { - "__id__": 17 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 75.97, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 1, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, { "__type__": "cc.Node", "_name": "MAP2_2", "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 4 + "__id__": 3 }, { - "__id__": 6 + "__id__": 5 } ], "_prefab": { - "__id__": 8 + "__id__": 7 }, "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 523.294, + "y": 610.769, "z": 0 }, "_lrot": { @@ -159,9 +108,9 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1.46, - "y": 1.46, - "z": 1.46 + "x": 1, + "y": 1, + "z": 1 }, "_mobility": 0, "_layer": 1, @@ -179,16 +128,16 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 3 + "__id__": 2 }, "_enabled": true, "__prefab": { - "__id__": 5 + "__id__": 4 }, "_contentSize": { "__type__": "cc.Size", - "width": 1200, - "height": 530 + "width": 1800, + "height": 800 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -199,7 +148,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "02JaCy2RtBv6IQedYySi9J" + "fileId": "cfYou1Zg5LCqtPnS+wfZS1" }, { "__type__": "cc.Sprite", @@ -207,11 +156,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 3 + "__id__": 2 }, "_enabled": true, "__prefab": { - "__id__": 7 + "__id__": 6 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -229,7 +178,7 @@ }, "_type": 0, "_fillType": 0, - "_sizeMode": 1, + "_sizeMode": 0, "_fillCenter": { "__type__": "cc.Vec2", "x": 0, @@ -244,7 +193,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "4fkgqaKsNJ2bWL29nICOgi" + "fileId": "69Tj3S2xNHMZ3EglIU5w1Y" }, { "__type__": "cc.PrefabInfo", @@ -254,7 +203,7 @@ "asset": { "__id__": 0 }, - "fileId": "51KkM8+RpPXbBFXOTtb9rJ", + "fileId": "918Xg0Q+RGA54YezNI+cvl", "instance": null, "targetOverrides": null, "nestedPrefabInstanceRoots": null @@ -265,25 +214,25 @@ "_objFlags": 0, "__editorExtras__": {}, "_parent": { - "__id__": 2 + "__id__": 1 }, "_children": [], "_active": true, "_components": [ { - "__id__": 10 + "__id__": 9 }, { - "__id__": 12 + "__id__": 11 } ], "_prefab": { - "__id__": 14 + "__id__": 13 }, "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 124.735, + "y": 203.74199999999996, "z": 0 }, "_lrot": { @@ -295,9 +244,9 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1.46, - "y": 1.46, - "z": 1.46 + "x": 1, + "y": 1, + "z": 1 }, "_mobility": 0, "_layer": 1, @@ -315,16 +264,16 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 9 + "__id__": 8 }, "_enabled": true, "__prefab": { - "__id__": 11 + "__id__": 10 }, "_contentSize": { "__type__": "cc.Size", - "width": 1200, - "height": 643 + "width": 1800, + "height": 964 }, "_anchorPoint": { "__type__": "cc.Vec2", @@ -335,7 +284,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "08W8yrO6ZAMYoLsN5M67nH" + "fileId": "6fNO9YoFBMVoknPFNDhdIt" }, { "__type__": "cc.Sprite", @@ -343,11 +292,11 @@ "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 9 + "__id__": 8 }, "_enabled": true, "__prefab": { - "__id__": 13 + "__id__": 12 }, "_customMaterial": null, "_srcBlendFactor": 2, @@ -365,7 +314,7 @@ }, "_type": 0, "_fillType": 0, - "_sizeMode": 1, + "_sizeMode": 0, "_fillCenter": { "__type__": "cc.Vec2", "x": 0, @@ -380,7 +329,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "8fnMp4WlZP54syw5QNPIMP" + "fileId": "4fqbVXXF9COpEp3qOMviz0" }, { "__type__": "cc.PrefabInfo", @@ -390,18 +339,65 @@ "asset": { "__id__": 0 }, - "fileId": "35BC8iioRG9YIjz054LzvN", + "fileId": "db7KlVnmBMUKpoqKybUC9n", "instance": null, "targetOverrides": null, "nestedPrefabInstanceRoots": null }, + { + "__type__": "cc.Node", + "_name": "GObject", + "_objFlags": 0, + "__editorExtras__": {}, + "_parent": { + "__id__": 1 + }, + "_children": [], + "_active": true, + "_components": [ + { + "__id__": 15 + } + ], + "_prefab": { + "__id__": 17 + }, + "_lpos": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_lrot": { + "__type__": "cc.Quat", + "x": 0, + "y": 0, + "z": 0, + "w": 1 + }, + "_lscale": { + "__type__": "cc.Vec3", + "x": 1, + "y": 1, + "z": 1 + }, + "_mobility": 0, + "_layer": 1, + "_euler": { + "__type__": "cc.Vec3", + "x": 0, + "y": 0, + "z": 0 + }, + "_id": "" + }, { "__type__": "cc.UITransform", "_name": "", "_objFlags": 0, "__editorExtras__": {}, "node": { - "__id__": 2 + "__id__": 14 }, "_enabled": true, "__prefab": { @@ -421,7 +417,7 @@ }, { "__type__": "cc.CompPrefabInfo", - "fileId": "10qY81RfZAO71vWAsMbNxA" + "fileId": "51F2pLtaRAvIrZ6+pAQ7gN" }, { "__type__": "cc.PrefabInfo", @@ -431,7 +427,7 @@ "asset": { "__id__": 0 }, - "fileId": "7dQpog1zRHRanaq1MbAxcj", + "fileId": "afU00zeEBCvYG08IYSwZ58", "instance": null, "targetOverrides": null, "nestedPrefabInstanceRoots": null @@ -523,7 +519,7 @@ "_shutter": 7, "_iso": 0, "_screenScale": 1, - "_visibility": 1073741825, + "_visibility": 1, "_targetTexture": { "__uuid__": "0aace819-1a93-43fc-90a6-43189c1dbf89", "__expectedType__": "cc.RenderTexture" @@ -551,94 +547,6 @@ "targetOverrides": null, "nestedPrefabInstanceRoots": null }, - { - "__type__": "cc.Node", - "_name": "GObject", - "_objFlags": 0, - "__editorExtras__": {}, - "_parent": { - "__id__": 1 - }, - "_children": [], - "_active": true, - "_components": [ - { - "__id__": 23 - } - ], - "_prefab": { - "__id__": 25 - }, - "_lpos": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_lrot": { - "__type__": "cc.Quat", - "x": 0, - "y": 0, - "z": 0, - "w": 1 - }, - "_lscale": { - "__type__": "cc.Vec3", - "x": 1, - "y": 1, - "z": 1 - }, - "_mobility": 0, - "_layer": 1, - "_euler": { - "__type__": "cc.Vec3", - "x": 0, - "y": 0, - "z": 0 - }, - "_id": "" - }, - { - "__type__": "cc.UITransform", - "_name": "", - "_objFlags": 0, - "__editorExtras__": {}, - "node": { - "__id__": 22 - }, - "_enabled": true, - "__prefab": { - "__id__": 24 - }, - "_contentSize": { - "__type__": "cc.Size", - "width": 100, - "height": 100 - }, - "_anchorPoint": { - "__type__": "cc.Vec2", - "x": 0.5, - "y": 0.5 - }, - "_id": "" - }, - { - "__type__": "cc.CompPrefabInfo", - "fileId": "51F2pLtaRAvIrZ6+pAQ7gN" - }, - { - "__type__": "cc.PrefabInfo", - "root": { - "__id__": 1 - }, - "asset": { - "__id__": 0 - }, - "fileId": "afU00zeEBCvYG08IYSwZ58", - "instance": null, - "targetOverrides": null, - "nestedPrefabInstanceRoots": null - }, { "__type__": "cc.UITransform", "_name": "", @@ -649,7 +557,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 27 + "__id__": 23 }, "_contentSize": { "__type__": "cc.Size", @@ -677,7 +585,7 @@ }, "_enabled": true, "__prefab": { - "__id__": 29 + "__id__": 25 }, "crystalPrefab": { "__uuid__": "96ad3740-fce8-4333-9f8e-eb85f43bf6f8", diff --git a/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab b/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab index 0c93ccbf..d5b077f3 100644 --- a/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab +++ b/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab @@ -333,7 +333,7 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": 360, + "x": 277.5, "y": 640, "z": 0 }, @@ -346,8 +346,8 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1, - "y": 1, + "x": 0.75, + "y": 0.75, "z": 1 }, "_mobility": 0, @@ -374,7 +374,7 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 1440, + "width": 1700, "height": 1280 }, "_anchorPoint": { @@ -441,11 +441,11 @@ "node": { "__id__": 11 }, - "_enabled": false, + "_enabled": true, "__prefab": { "__id__": 17 }, - "_alignFlags": 8, + "_alignFlags": 12, "_target": null, "_left": 0, "_right": 0, @@ -462,7 +462,7 @@ "_originalWidth": 0, "_originalHeight": 0, "_alignMode": 2, - "_lockFlags": 0, + "_lockFlags": 36, "_id": "" }, { @@ -713,7 +713,7 @@ }, "_lpos": { "__type__": "cc.Vec3", - "x": -360, + "x": -277.5, "y": 640, "z": 0 }, @@ -726,8 +726,8 @@ }, "_lscale": { "__type__": "cc.Vec3", - "x": 1, - "y": 1, + "x": 0.75, + "y": 0.75, "z": 1 }, "_mobility": 0, @@ -754,7 +754,7 @@ }, "_contentSize": { "__type__": "cc.Size", - "width": 1440, + "width": 1700, "height": 1280 }, "_anchorPoint": { @@ -821,11 +821,11 @@ "node": { "__id__": 29 }, - "_enabled": false, + "_enabled": true, "__prefab": { "__id__": 35 }, - "_alignFlags": 32, + "_alignFlags": 36, "_target": null, "_left": 0, "_right": 0, @@ -842,7 +842,7 @@ "_originalWidth": 0, "_originalHeight": 0, "_alignMode": 2, - "_lockFlags": 0, + "_lockFlags": 36, "_id": "" }, { diff --git a/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt b/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt index f02a5334..92e2bf30 100644 --- a/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt +++ b/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt @@ -2,7 +2,7 @@ "__type__": "cc.RenderTexture", "content": { "base": "2,2,0,0,0,0", - "w": 1440, + "w": 1700, "h": 1280, "n": "CampGuardian" } diff --git a/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt.meta b/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt.meta index b5220431..b8064e6a 100644 --- a/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt.meta +++ b/JisolGameCocos/assets/resources/renders/CampGuardianMode/CampGuardian.rt.meta @@ -15,7 +15,7 @@ "name": "spriteFrame", "userData": { "imageUuidOrDatabaseUri": "0aace819-1a93-43fc-90a6-43189c1dbf89", - "width": 1440, + "width": 1700, "height": 1280 }, "ver": "1.0.0", @@ -27,7 +27,7 @@ } }, "userData": { - "width": 1440, + "width": 1700, "height": 1280, "anisotropy": 0, "minfilter": "linear", diff --git a/JisolGameCocos/assets/script/App.ts b/JisolGameCocos/assets/script/App.ts index e0d030c7..e3ce2106 100644 --- a/JisolGameCocos/assets/script/App.ts +++ b/JisolGameCocos/assets/script/App.ts @@ -32,8 +32,8 @@ import { Component } from "cc"; // let WsPath = `ws://localhost:8080/websocket` // let APIPath = `http://192.168.1.23:8080` // let WsPath = `ws://192.168.1.23:8080/websocket` -let APIPath = `http://192.168.0.125:8080` -let WsPath = `ws://192.168.0.125:8080/websocket` +let APIPath = `http://192.168.0.122:8080` +let WsPath = `ws://192.168.0.122:8080/websocket` // let APIPath = `https://api.pet.jisol.cn` // let WsPath = `wss://api.pet.jisol.cn/websocket` diff --git a/JisolGameCocos/assets/script/battle/base/fsm/Default/GFSMDefault.ts b/JisolGameCocos/assets/script/battle/base/fsm/Default/GFSMDefault.ts index b73bcbb8..eb6a7c2b 100644 --- a/JisolGameCocos/assets/script/battle/base/fsm/Default/GFSMDefault.ts +++ b/JisolGameCocos/assets/script/battle/base/fsm/Default/GFSMDefault.ts @@ -28,8 +28,8 @@ export default class GFSMDefault extends GFSMBase{ } //锁定的敌人 - _enemy:() => GRoleDefault; - get enemy():GRoleDefault{ + _enemy:() => GRoleBase<{}>; + get enemy():GRoleBase<{}>{ if(this._enemy) return this._enemy(); return null; @@ -76,7 +76,7 @@ export default class GFSMDefault extends GFSMBase{ //寻敌 - onSeekEnemy(): GRoleDefault { + onSeekEnemy(): GRoleBase<{}> { return this.player.onQueryEunmy(); } diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts b/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts index 6ee2135e..d1c92927 100644 --- a/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleDefault.ts @@ -142,13 +142,19 @@ export default class GRoleDefault extends GRoleBase<{}>{ let vWorld = this.node.worldPosition; let vEndWorld = this.getWorldBackLen(v2(1500,500)); this.JTween(vWorld) - .to({x:vEndWorld.x},1000) - .onUpdate(pos => this.node.worldPosition = pos) + .to({x:vEndWorld.x},1200) + .onUpdate(pos => { + if(this.node.isValid) + this.node.worldPosition = pos; + }) .start(); this.JTween(vWorld) - .to({y:vEndWorld.y},1000) + .to({y:vEndWorld.y},1200) .easing(JEasing.Circular.Out) - .onUpdate(pos => this.node.worldPosition = vWorld) + .onUpdate(pos => { + if(this.node.isValid) + this.node.worldPosition = vWorld + }) .start(); } @@ -208,7 +214,7 @@ export default class GRoleDefault extends GRoleBase<{}>{ return false; } - onQueryEunmy():GRoleDefault{ + onQueryEunmy():GRoleBase<{}>{ return null; } diff --git a/JisolGameCocos/assets/script/battle/modes/GCampGuardianMode.ts b/JisolGameCocos/assets/script/battle/modes/GCampGuardianMode.ts index e02f0409..d8876ce7 100644 --- a/JisolGameCocos/assets/script/battle/modes/GCampGuardianMode.ts +++ b/JisolGameCocos/assets/script/battle/modes/GCampGuardianMode.ts @@ -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) + + } } diff --git a/JisolGameCocos/assets/script/battle/modes/GModeTools.ts b/JisolGameCocos/assets/script/battle/modes/GModeTools.ts new file mode 100644 index 00000000..5a5983e9 --- /dev/null +++ b/JisolGameCocos/assets/script/battle/modes/GModeTools.ts @@ -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; + } + } + +} + diff --git a/JisolGameCocos/assets/script/battle/modes/GModeTools.ts.meta b/JisolGameCocos/assets/script/battle/modes/GModeTools.ts.meta new file mode 100644 index 00000000..57ced7fe --- /dev/null +++ b/JisolGameCocos/assets/script/battle/modes/GModeTools.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.23", + "importer": "typescript", + "imported": true, + "uuid": "2e0c3126-ff69-4923-9ad6-21821ade5e93", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/JisolGameCocos/extensions/ngame b/JisolGameCocos/extensions/ngame index e7ef32f1..f04667b4 160000 --- a/JisolGameCocos/extensions/ngame +++ b/JisolGameCocos/extensions/ngame @@ -1 +1 @@ -Subproject commit e7ef32f1ed47ef7ffe0173e5e5a7cc66b41bf25b +Subproject commit f04667b4988cb251db49a4289f22ec54e8ce889b