This commit is contained in:
PC-20230316NUNE\Administrator 2023-12-18 18:48:42 +08:00
parent 8c4d80ea8a
commit c61e1b576b
5 changed files with 29 additions and 12 deletions

View File

@ -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": ""

View File

@ -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": {

View File

@ -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`

View File

@ -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<any>));
return PhysicsSystem2D.instance.testAABB(rect).map(item => item.getComponent(GRoleBase<any>)).filter(role => !!role);
}
//检测角色
static testPointRole(pos:Vec2){

View File

@ -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,6 +78,9 @@ export default abstract class GRoleBase<T> extends GObject<T>{
this._values = value;
}
//添加避障
ov:NOVBase;
get():this{
if(this.isDie) return null;
return this;
@ -81,6 +88,9 @@ export default abstract class GRoleBase<T> extends GObject<T>{
onSyncLoad(){
//避障
this.ov = new NOV2DSimple(this.node.getComponent(BoxCollider2D));
if(!this.spine) this.spine = this.node.getComponent(JNSkeleton);
//如果没有生成则直接销毁
if(!this.spine) {
@ -135,16 +145,23 @@ export default abstract class GRoleBase<T> extends GObject<T>{
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<{}>){
//获取两个坐标差值向量