From c61e1b576b3977a3dbfb74daa478731c9d9fcd5b Mon Sep 17 00:00:00 2001 From: "PC-20230316NUNE\\Administrator" <2858626794@qq.com> Date: Mon, 18 Dec 2023 18:48:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../battle/mode/CampGuardianMode.prefab | 4 ++-- .../模式/CampGuardian/阵营守护战斗页面.prefab | 6 +++--- JisolGameCocos/assets/script/App.ts | 8 +++---- .../script/battle/base/common/GDetection.ts | 2 +- .../script/battle/base/role/GRoleBase.ts | 21 +++++++++++++++++-- 5 files changed, 29 insertions(+), 12 deletions(-) diff --git a/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab b/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab index 2a89b979..98d3d83a 100644 --- a/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab +++ b/JisolGameCocos/assets/resources/prefab/battle/mode/CampGuardianMode.prefab @@ -186,7 +186,7 @@ }, "_fillStart": 0, "_fillRange": 0, - "_isTrimmedMode": true, + "_isTrimmedMode": false, "_useGrayscale": false, "_atlas": null, "_id": "" @@ -322,7 +322,7 @@ }, "_fillStart": 0, "_fillRange": 0, - "_isTrimmedMode": true, + "_isTrimmedMode": false, "_useGrayscale": false, "_atlas": null, "_id": "" diff --git a/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab b/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab index d5764176..c6f950c0 100644 --- a/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab +++ b/JisolGameCocos/assets/resources/prefab/ui/模式/CampGuardian/阵营守护战斗页面.prefab @@ -281,7 +281,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": -86.34900000000005, + "y": -640, "z": 0 }, "_lrot": { @@ -527,7 +527,7 @@ "_left": 0, "_right": 0, "_top": 0, - "_bottom": 553.651, + "_bottom": 0, "_horizontalCenter": 0, "_verticalCenter": 0, "_isAbsLeft": true, @@ -661,7 +661,7 @@ "_lpos": { "__type__": "cc.Vec3", "x": 0, - "y": 279.365, + "y": 0, "z": 0 }, "_lrot": { diff --git a/JisolGameCocos/assets/script/App.ts b/JisolGameCocos/assets/script/App.ts index d544b698..e3ce2106 100644 --- a/JisolGameCocos/assets/script/App.ts +++ b/JisolGameCocos/assets/script/App.ts @@ -30,10 +30,10 @@ import { Component } from "cc"; // let APIPath = `http://localhost:8080` // 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.122:8080` -// let WsPath = `ws://192.168.0.122: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.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/common/GDetection.ts b/JisolGameCocos/assets/script/battle/base/common/GDetection.ts index 97776d7d..741d684f 100644 --- a/JisolGameCocos/assets/script/battle/base/common/GDetection.ts +++ b/JisolGameCocos/assets/script/battle/base/common/GDetection.ts @@ -12,7 +12,7 @@ export default class GDetection{ rect.x -= rect.width / 2; rect.y -= rect.height / 2; //@ts-ignore - return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase)); + return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase)).filter(role => !!role); } //检测角色 static testPointRole(pos:Vec2){ diff --git a/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts b/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts index 03693faa..20155bfd 100644 --- a/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts +++ b/JisolGameCocos/assets/script/battle/base/role/GRoleBase.ts @@ -11,6 +11,10 @@ import { TB } from "../../../config/data/schema"; import GRoleValues, { GRoleAttackType } from "../values/GRoleValues"; import GAttributeBase from "../values/attribute/GAttributeBase"; import { GPetAminEnum } from "../anim/GPetAnim"; +import NOV2DSimple from "../../../../../extensions/ngame/assets/ngame/util/collide/OV/NOV2DSimple"; +import NOVBase from "../../../../../extensions/ngame/assets/ngame/util/collide/OV/NOVBase"; +import { BoxCollider2D } from "cc"; +import { Vec3 } from "cc"; const { ccclass, property } = _decorator; export enum GRoleAnimEvent{ @@ -74,12 +78,18 @@ export default abstract class GRoleBase extends GObject{ this._values = value; } + //添加避障 + ov:NOVBase; + get():this{ if(this.isDie) return null; return this; } onSyncLoad(){ + + //避障 + this.ov = new NOV2DSimple(this.node.getComponent(BoxCollider2D)); if(!this.spine) this.spine = this.node.getComponent(JNSkeleton); //如果没有生成则直接销毁 @@ -135,16 +145,23 @@ export default abstract class GRoleBase extends GObject{ if(Vec2.len(normal) >= Vec2.len(mins)){ - this.node.setWorldPosition(Object.assign(v3(),target.clone())); + this.setWorldPosition(Object.assign(v3(),target.clone())); return true; }else{ //移动 - this.node.worldPosition = this.node.worldPosition.subtract(v3(normal.x*dt*this.moveSpeed,normal.y*dt*this.moveSpeed,0)) + this.setWorldPosition(this.node.worldPosition.subtract(v3(normal.x*dt*this.moveSpeed,normal.y*dt*this.moveSpeed,0))); return false; } } + //设置世界坐标 + setWorldPosition(worldPos:Vec3){ + if(this.ov.moveTo(worldPos)){ + this.node.setWorldPosition(worldPos); + } + } + //朝向目标 onTowardsTarget(role:GRoleBase<{}>){ //获取两个坐标差值向量