去掉碰撞系统
This commit is contained in:
@@ -117,5 +117,20 @@ export const SkillSet = {
|
||||
6031:{uuid:6031,path:"6031",type:1,tg:0,fname:"buff_do",flash:true,with:false,debuff:0,depb:0,debtime:0,derate:0,in:2,count:1,def:20,apup:0,ap:70,mhp:0,hp:70,cd:1,shield:0,speed:120,sonsk:0,hero:5211,name:"召唤仆从",sp_name:"zhaohuan",info:"召唤一个与施法者等级相同的骷髅战士为我方而战"},
|
||||
6032:{uuid:6032,path:"6032",type:1,tg:0,fname:"",flash:false,with:false,debuff:0,depb:0,debtime:0,derate:0,in:2,count:1,def:0,apup:0,ap:100,mhp:0,hp:5,cd:1,shield:0,speed:120,sonsk:0,hero:0,name:"自愈",sp_name:"heath_small",info:"主动:自己回复自身5%最大生命值的生命"},
|
||||
6033:{uuid:6033,path:"6033",type:1,tg:3,fname:"",flash:false,with:false,debuff:4,depb:100,debtime:1,derate:20,in:1,count:1,def:0,apup:0,ap:500,mhp:0,hp:0,cd:1,shield:0,speed:500,sonsk:6035,hero:0,name:"爆锤",sp_name:"cuida",info:"捶爆前方目标,造成300%攻击的伤害,震慑敌人,本局内全部敌方降低对方10%攻击力"},
|
||||
6034:{uuid:6034,path:"6034",type:1,tg:3,fname:"",flash:false,with:false,debuff:4,depb:100,debtime:1,derate:20,in:1,count:1,def:0,apup:0,ap:80,mhp:0,hp:0,cd:1,shield:0,speed:350,sonsk:0,hero:0,name:"暴风箭",sp_name:"bingyu",info:"射出能量暴风箭攻击最前方范围敌人,每波造成80%攻击的伤害"}
|
||||
6034:{uuid:6034,path:"6034",type:1,tg:3,fname:"",flash:false,with:false,debuff:4,depb:100,debtime:1,derate:20,in:1,count:1,def:0,apup:0,ap:80,mhp:0,hp:0,cd:1,shield:0,speed:350,sonsk:0,hero:0,name:"暴风箭",sp_name:"bingyu",info:"射出能量暴风箭攻击最前方范围敌人,每波造成80%攻击的伤害"},
|
||||
7001: {
|
||||
prefab: "arrow", // 预制体路径
|
||||
range: 500, // 攻击距离
|
||||
width: 30, // 攻击宽度
|
||||
penetrate: 3, // 最大穿透数
|
||||
speed: 800, // 飞行速度(像素/秒)
|
||||
hitInterval: 0.1 // 伤害间隔(秒)
|
||||
},
|
||||
8001: {
|
||||
prefab: "fireball",
|
||||
speed: 600,
|
||||
range: 800,
|
||||
penetrate: 2,
|
||||
collisionRadius: 50 // 碰撞检测半径
|
||||
}
|
||||
};
|
||||
17
assets/script/game/common/ecs/position/BattleMoveComp.ts
Normal file
17
assets/script/game/common/ecs/position/BattleMoveComp.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { ecs } from "../../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
@ecs.register('BattleMove')
|
||||
|
||||
export class BattleMoveComp extends ecs.Comp {
|
||||
/** 移动方向:1向右,-1向左 */
|
||||
direction: number = 1;
|
||||
/** 目标x坐标 */
|
||||
targetX: number = 0;
|
||||
/** 是否处于移动状态 */
|
||||
moving: boolean = true;
|
||||
|
||||
reset() {
|
||||
this.direction = 1;
|
||||
this.targetX = 0;
|
||||
this.moving = true;
|
||||
}
|
||||
}
|
||||
51
assets/script/game/common/ecs/position/BattleMoveSystem.ts
Normal file
51
assets/script/game/common/ecs/position/BattleMoveSystem.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
import { HeroViewComp } from "../../../hero/HeroViewComp";
|
||||
import { BattleMoveComp } from "./BattleMoveComp";
|
||||
import { ecs } from "../../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
||||
|
||||
@ecs.register('BattleMoveSystem')
|
||||
export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate {
|
||||
filter(): ecs.IMatcher {
|
||||
return ecs.allOf(BattleMoveComp, HeroViewComp);
|
||||
}
|
||||
|
||||
update(e: ecs.Entity) {
|
||||
const move = e.get(BattleMoveComp);
|
||||
const view = e.get(HeroViewComp);
|
||||
|
||||
if (!move.moving) return;
|
||||
|
||||
// 检测攻击范围内是否有敌人
|
||||
const hasEnemy = this.checkEnemiesInRange(e, view.dis);
|
||||
|
||||
if (!hasEnemy) {
|
||||
// 计算移动量
|
||||
const delta = view.speed * this.dt * move.direction;
|
||||
const newX = view.node.position.x + delta;
|
||||
|
||||
// 限制移动范围
|
||||
if (this.validatePosition(newX, move)) {
|
||||
view.node.setPosition(newX, view.node.position.y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 验证目标位置有效性 */
|
||||
private validatePosition(newX: number, move: BattleMoveComp): boolean {
|
||||
// 我方不能超过右边界,敌方不能超过左边界
|
||||
return move.direction === 1 ?
|
||||
newX <= move.targetX :
|
||||
newX >= move.targetX;
|
||||
}
|
||||
|
||||
/** 检测攻击范围内敌人 */
|
||||
private checkEnemiesInRange(entity: ecs.Entity, range: number): boolean {
|
||||
const currentPos = entity.get(HeroViewComp).node.position;
|
||||
const team = entity.get(HeroViewComp).fac;
|
||||
|
||||
return ecs.query(ecs.allOf(HeroViewComp)).some(e => {
|
||||
const view = e.get(HeroViewComp);
|
||||
return view.fac !== team &&
|
||||
Math.abs(currentPos.x - view.node.position.x) <= range;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user