refactor(skill): 重构技能命中次数管理逻辑
- 在 SDataCom 组件中添加 max_hit_count 字段,用于存储最大可命中次数 - 移除 SkillView 中基于攻击帧的计数逻辑,改为使用 sData.max_hit_count 管理 - 在技能初始化时计算 max_hit_count(基础命中数 + 穿刺属性) - 更新技能配置注释,将 hit_num 重命名为 hit_count 以保持命名一致性
This commit is contained in:
@@ -123,7 +123,7 @@ export enum EType {
|
||||
4. 数值参数:
|
||||
- ap: 攻击力百分比
|
||||
- cd: 冷却时间
|
||||
- hit_num: 范围攻击 伤害敌人数量
|
||||
- hit_count: 范围攻击 伤害敌人数量
|
||||
- t_num: 目标数量
|
||||
- hit: 穿刺个数
|
||||
- hitcd: 持续伤害的伤害间隔
|
||||
@@ -183,7 +183,7 @@ export interface SkillConfig {
|
||||
act:string, // 角色执行的动画
|
||||
DTType:DTType, // 伤害类型(单体/范围)
|
||||
ap:number, // 攻击百分比(角色攻击力)
|
||||
hit_num:number, // 范围攻击伤害敌人数量
|
||||
hit_count:number, // 可攻击目标数量
|
||||
hit:number, // 穿刺个数
|
||||
hitcd:number, // 持续伤害的伤害间隔(秒)
|
||||
speed:number, // 移动速度
|
||||
@@ -205,56 +205,56 @@ export interface SkillConfig {
|
||||
|
||||
export const SkillSet: Record<number, SkillConfig> = {
|
||||
5000:{uuid:5000,name:"反伤",sp_name:"thorns",icon:"1168",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:0,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:0,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[],debuffs:[],info:"反伤",
|
||||
},
|
||||
// ========== 基础攻击 ========== 6001-6099
|
||||
6001: {
|
||||
uuid:6001,name:"空挥",sp_name:"atk_s1",icon:"1026",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.collision,
|
||||
buffs:[],debuffs:[],info:"对前方目标造成100%攻击的伤害",
|
||||
},
|
||||
6002: {
|
||||
uuid:6002,name:"电击",sp_name:"atk_s4",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
|
||||
},
|
||||
6003: {
|
||||
uuid:6003,name:"闪击",sp_name:"atk_s1",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
|
||||
},
|
||||
6004: {
|
||||
uuid:6004,name:"火焰击",sp_name:"atk_f2",icon:"1173",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"max",DTType:DTType.single,
|
||||
ap:100,hit_num:6,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:6,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
buffs:[],debuffs:[],info:"对前方目标造成150%攻击的伤害",
|
||||
},
|
||||
6005: {
|
||||
uuid:6005,name:"蓝箭",sp_name:"arrow_blue",icon:"1135",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision,
|
||||
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
|
||||
},
|
||||
6006: {
|
||||
uuid:6006,name:"绿箭",sp_name:"arrow_green",icon:"1135",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.animationEnd,
|
||||
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
|
||||
},
|
||||
6007: {
|
||||
uuid:6007,name:"红箭",sp_name:"arrow_red",icon:"1135",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:100,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.animationEnd,
|
||||
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
|
||||
},
|
||||
6008: {
|
||||
uuid:6008,name:"水球",sp_name:"ball_water",icon:"1126",TGroup:TGroup.Enemy,TType:TType.Frontline,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:100,hit_num:1,hit:2,hitcd:0.3,speed:720,with:90,
|
||||
ap:100,hit_count:1,hit:2,hitcd:0.3,speed:720,with:90,
|
||||
ready:8001,EAnm:0,DAnm:9001,RType:RType.linear,EType:EType.collision,
|
||||
buffs:[],debuffs:[],info:"对前方单个目标造成100%攻击的伤害",
|
||||
},
|
||||
@@ -262,25 +262,25 @@ export const SkillSet: Record<number, SkillConfig> = {
|
||||
//============================= ====== 基础buff ====== ========================== 6100-6199
|
||||
6100: {
|
||||
uuid:6100,name:"治疗",sp_name:"buff_wind",icon:"1292",TGroup:TGroup.Self,TType:TType.LowestHP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
kind:SkillKind.Heal,buffs:[],debuffs:[],info:"治疗自己,回复30%最大生命值",
|
||||
},
|
||||
6101:{
|
||||
uuid:6101,name:"魔法盾",sp_name:"buff_wind",icon:"1255",TGroup:TGroup.Self,TType:TType.LowestHP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
kind:SkillKind.Shield,buffs:[],debuffs:[],info:"获得30%最大生命值的护盾,持续60秒",
|
||||
},
|
||||
6102:{
|
||||
uuid:6102,name:"强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,TType:TType.HighestAP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.single,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
kind:SkillKind.Support,buffs:[10001],debuffs:[],info:"增加目标10%攻击力,持续30秒",
|
||||
},
|
||||
6103:{
|
||||
uuid:6103,name:"群体强壮",sp_name:"buff_wind",icon:"3036",TGroup:TGroup.Team,TType:TType.HighestAP,readyAnm:"",endAnm:"",act:"atk",DTType:DTType.range,
|
||||
ap:30,hit_num:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ap:30,hit_count:1,hit:1,hitcd:0.2,speed:720,with:0,
|
||||
ready:0,EAnm:0,DAnm:9001,RType:RType.fixed,EType:EType.animationEnd,
|
||||
kind:SkillKind.Support,buffs:[10011],debuffs:[],info:"增加目标10%攻击力,持续30秒",
|
||||
},
|
||||
@@ -288,14 +288,14 @@ export const SkillSet: Record<number, SkillConfig> = {
|
||||
6201: {
|
||||
uuid:6201, name:"怪物近战", sp_name:"atk_s1", icon:"3036",
|
||||
TGroup:TGroup.Enemy, TType:TType.Frontline, readyAnm:"",endAnm:"",act:"atk", DTType:DTType.single,
|
||||
ap:100, hit_num:1, hit:1, hitcd:0.2, speed:0, with:0, // 怪物近战特殊距离
|
||||
ap:100, hit_count:1, hit:1, hitcd:0.2, speed:0, with:0, // 怪物近战特殊距离
|
||||
ready:0, EAnm:0, DAnm:9001, RType:RType.fixed, EType:EType.animationEnd,
|
||||
buffs:[], debuffs:[], info:"怪物基础近战攻击",
|
||||
},
|
||||
6203: {
|
||||
uuid:6203, name:"怪物射击", sp_name:"arrow_1", icon:"3039",
|
||||
TGroup:TGroup.Enemy, TType:TType.Frontline, readyAnm:"",endAnm:"",act:"atk", DTType:DTType.single,
|
||||
ap:80, hit_num:1, hit:1, hitcd:0.2, speed:800, with:0, // 怪物远程特殊距离
|
||||
ap:80, hit_count:1, hit:1, hitcd:0.2, speed:800, with:0, // 怪物远程特殊距离
|
||||
ready:0, EAnm:0, DAnm:9001, RType:RType.linear, EType:EType.collision,
|
||||
buffs:[], debuffs:[], info:"怪物基础远程攻击",
|
||||
},
|
||||
|
||||
@@ -16,6 +16,7 @@ export class SDataCom extends ecs.Comp {
|
||||
ext_dmg:number=0 //额外伤害
|
||||
dmg_ratio:number=1 //伤害比例
|
||||
hit_count:number=0 //击中数量
|
||||
max_hit_count:number=0 //最大可命中次数
|
||||
reset() {
|
||||
this.Attrs=null
|
||||
this.group=BoxSet.HERO
|
||||
@@ -24,6 +25,7 @@ export class SDataCom extends ecs.Comp {
|
||||
this.caster=null
|
||||
this.casterEid = -1;
|
||||
this.hit_count=0
|
||||
this.max_hit_count=0
|
||||
this.ext_dmg=0
|
||||
this.dmg_ratio=1
|
||||
}
|
||||
|
||||
@@ -32,8 +32,6 @@ export class SkillView extends CCComp {
|
||||
private collider: Collider2D = null; // 缓存碰撞体引用
|
||||
private pendingDisableCollider: boolean = false;
|
||||
private isDisposing: boolean = false;
|
||||
private attackFrameCount: number = 0; // 攻击帧计数器
|
||||
private maxAttackFrames: number = 1; // 最大攻击帧数,可配置
|
||||
// 已命中目标追踪,防止重复伤害
|
||||
init() {
|
||||
this.SConf = SkillSet[this.s_uuid]
|
||||
@@ -60,7 +58,12 @@ export class SkillView extends CCComp {
|
||||
anim.play(anim.defaultClip.name);
|
||||
}
|
||||
}
|
||||
this.attackFrameCount = 0; // 重置攻击帧计数
|
||||
if (this.sData) {
|
||||
this.sData.hit_count = 0;
|
||||
const punctureCount = this.sData.Attrs?.[Attrs.puncture] ?? 0;
|
||||
const baseHitCount = this.SConf?.hit ?? 0;
|
||||
this.sData.max_hit_count = baseHitCount + punctureCount;
|
||||
}
|
||||
}
|
||||
onBeginContact (seCol: Collider2D, oCol: Collider2D) {
|
||||
if (!this.sData || !this.SConf) {
|
||||
@@ -102,13 +105,12 @@ export class SkillView extends CCComp {
|
||||
}
|
||||
// //动画帧事件 atk 触发
|
||||
public atk(args:any){
|
||||
this.attackFrameCount++;
|
||||
if (this.enable_collider_safely()) {
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧开启碰撞检测`);
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 开启碰撞检测`);
|
||||
this.scheduleOnce(() => {
|
||||
if (!this.node || !this.node.isValid || this.isDisposing) return;
|
||||
this.close_collider();
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 第${this.attackFrameCount}次攻击帧关闭碰撞检测`);
|
||||
mLogger.log(this.debugMode, 'SkillView', `[SkillView] [${this.SConf?.name}] 关闭碰撞检测`);
|
||||
}, 0);
|
||||
}
|
||||
}
|
||||
@@ -117,10 +119,10 @@ export class SkillView extends CCComp {
|
||||
if(target == null) return;
|
||||
// 安全检查:如果目标实体已不存在,直接返回
|
||||
if (!target.ent) return;
|
||||
if (!this.sData) return;
|
||||
if (!this.SConf) return;
|
||||
// 检查技能是否应该销毁
|
||||
const max_hit_count=this.SConf.hit + this.sData.Attrs[Attrs.puncture]
|
||||
if ( this.sData.hit_count >= max_hit_count ) {
|
||||
if ( this.sData.hit_count >= this.sData.max_hit_count ) {
|
||||
this.close_collider()
|
||||
return
|
||||
}
|
||||
@@ -141,6 +143,9 @@ export class SkillView extends CCComp {
|
||||
|
||||
// 更新技能命中次数
|
||||
this.sData.hit_count++
|
||||
if (this.sData.hit_count >= this.sData.max_hit_count) {
|
||||
this.close_collider();
|
||||
}
|
||||
if (
|
||||
(this.SConf.DTType != DTType.range) &&
|
||||
(this.SConf.EType != EType.animationEnd) &&
|
||||
|
||||
Reference in New Issue
Block a user