fix: 修复技能碰撞检测和英雄prefab配置问题

修复技能碰撞检测逻辑,确保正确应用伤害并过滤同组碰撞
调整多个英雄prefab的_enabled状态和碰撞组配置
优化技能视图的日志输出和伤害应用逻辑
移除不必要的prefab组件和调试日志
This commit is contained in:
walkpan
2025-11-01 23:10:38 +08:00
parent 2e1c6c3aa1
commit 1091b0399e
19 changed files with 40 additions and 164 deletions

View File

@@ -38,7 +38,6 @@ export class SkillView extends CCComp {
if(collider) {
collider.group = this.group;
collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
console.log(`[skillView] ${this.sData.caster.ent.get(HeroAttrsComp).hero_name}${this.SConf.name} 碰撞组 ${this.group}`)
}
if(this.node.getComponent(Animation)){
let anim = this.node.getComponent(Animation);
@@ -48,18 +47,16 @@ export class SkillView extends CCComp {
}
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
console.log(`[skillView] ${this.sData.caster.ent.get(HeroAttrsComp).hero_name}${this.SConf.name} 碰撞了 ${oCol.getComponent(HeroViewComp).ent.get(HeroAttrsComp).hero_name}`);
if(oCol.group==this.group) return
if (!this.SConf) return;
if(this.SConf.EType!=EType.collision) return
let target = oCol.getComponent(HeroViewComp)
if(target == null) return;
let model=target.ent.get(HeroAttrsComp)
if(!model) return
if(model.is_dead) return
if(oCol.group!=this.group){
if(target == null) return;
if (!this.SConf) return;
if(this.SConf.EType==EType.collision){
this.apply_damage(target)
}
}
// console.log(`[skillView] 碰撞5[${this.sData.caster.box_group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的[${this.group}] [${this.SConf.name}]碰撞了 [${oCol.group}][ ${oCol.getComponent(HeroViewComp).ent.get(HeroAttrsComp).hero_name}][${oCol.getComponent(HeroViewComp).ent.eid}]`);
this.apply_damage(target)
}
onAnimationFinished(){
@@ -98,11 +95,9 @@ export class SkillView extends CCComp {
const distanceB = Math.abs(this.node.position.x - b.node.position.x);
return distanceA - distanceB;
});
// 限制目标数量
const maxTargets = Math.min(hitNum, IRTargets.length);
const sTargets = IRTargets.slice(0, maxTargets);
sTargets.forEach(target => {
this.apply_damage(target, false);
});
@@ -120,7 +115,8 @@ export class SkillView extends CCComp {
apply_damage(target:HeroViewComp,is_range:boolean=false){
if(target == null) return;
if (!this.SConf) return;
console.log(`[skillView] 伤害 [${this.group}][${this.sData.caster.ent.get(HeroAttrsComp).hero_name}][${this.sData.caster.ent.eid}]的 [${this.SConf.name}]对 [${target.box_group}][ ${target.ent.get(HeroAttrsComp).hero_name}][${target.ent.eid}]`);
// if(this.sData.hit_count > this.SConf.hit_num) return 不能超出 最大伤害数量
// 使用伤害队列系统处理伤害
DamageQueueHelper.addDamageToEntity(
target.ent,
@@ -128,12 +124,8 @@ export class SkillView extends CCComp {
this.sData.caster,
this.sData.s_uuid
);
// console.log(`[SkillCom]: ${this.sData.caster.ent.get(HeroAttrsComp).hero_name}[${this.sData.caster.ent.get(HeroAttrsComp).fac}:${ this.sData.fac}:${target.ent.get(HeroAttrsComp).fac}] 对 ${target.ent.get(HeroAttrsComp).hero_name} 释放技能 ${this.SConf.name}`)
// 更新技能命中次数
this.sData.hit_count++
// 检查技能是否应该销毁
if( this.sData.hit_count>=(this.SConf.hit+ this.sData.Attrs[Attrs.PUNCTURE])&&(this.SConf.DTType!=DTType.range)&&(this.SConf.EType!=EType.animationEnd)&&(this.SConf.EType!=EType.timeEnd)) this.ent.destroy// 技能命中次数
}