feat(战斗系统): 实现伤害队列机制优化战斗处理
重构伤害处理逻辑,将直接伤害组件改为队列系统 - 新增DamageQueueComp组件管理伤害事件队列 - 添加DamageQueueHelper工具类处理伤害事件添加和查询 - 修改HeroAtkSystem改为处理伤害队列而非单个伤害 - 移除旧的DmgDataCom组件及相关引用 - 优化SkillView.apply_damage使用新队列系统
This commit is contained in:
@@ -22,30 +22,4 @@ export class SDataCom extends ecs.Comp {
|
||||
this.hit_count=0
|
||||
}
|
||||
}
|
||||
//伤害数据
|
||||
@ecs.register('DmgDataCom')
|
||||
export class DmgDataCom extends ecs.Comp {
|
||||
/** 业务层组件移除时,重置所有数据为默认值 */
|
||||
Attrs:any=null
|
||||
caster:HeroViewComp=null
|
||||
s_uuid:number=0
|
||||
reset() {
|
||||
this.Attrs=null
|
||||
this.s_uuid=0
|
||||
this.caster=null
|
||||
}
|
||||
}
|
||||
|
||||
// /** 业务层业务逻辑处理对象 */
|
||||
// export class SDataComSystem extends ecs.ComblockSystem implements ecs.IEntityEnterSystem {
|
||||
// filter(): ecs.IMatcher {
|
||||
// return ecs.allOf(SDataCom);
|
||||
// }
|
||||
|
||||
// entityEnter(e: ecs.Entity): void {
|
||||
// // 注:自定义业务逻辑
|
||||
|
||||
|
||||
// e.remove(SDataCom);
|
||||
// }
|
||||
// }
|
||||
@@ -5,12 +5,13 @@ import { HeroViewComp } from "../hero/HeroViewComp";
|
||||
import { DTType, EType, RType, SkillConfig, SkillSet } from "../common/config/SkillSet";
|
||||
import { BezierMove } from "../BezierMove/BezierMove";
|
||||
import { BoxSet, FacSet } from "../common/config/BoxSet";
|
||||
import { DmgDataCom, SDataCom } from "./SDataCom";
|
||||
import { SDataCom } from "./SDataCom";
|
||||
import { SMoveDataComp } from "./SMoveComp";
|
||||
import { Attrs } from "../common/config/HeroAttrs";
|
||||
import { MonMoveComp } from "../hero/MonMove";
|
||||
import { HeroAttrsComp } from "../hero/HeroAttrsComp";
|
||||
import { HeroMoveComp } from "../hero/HeroMove";
|
||||
import { DamageQueueHelper } from "../hero/DamageQueueComp";
|
||||
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@@ -178,14 +179,21 @@ export class SkillView extends CCComp {
|
||||
apply_damage(target:HeroViewComp,is_range:boolean=false){
|
||||
if(target == null) return;
|
||||
if (!this.SConf) return;
|
||||
//伤害处理
|
||||
target.ent.addComponents<DmgDataCom>(DmgDataCom)
|
||||
let dmgData=target.ent.get(DmgDataCom)
|
||||
dmgData.Attrs= this.sData.Attrs
|
||||
dmgData.caster= this.sData.caster
|
||||
dmgData.s_uuid= this.sData.s_uuid
|
||||
|
||||
// 使用伤害队列系统处理伤害
|
||||
DamageQueueHelper.addDamageToEntity(
|
||||
target.ent,
|
||||
this.sData.Attrs,
|
||||
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++
|
||||
|
||||
// 更新技能命中次数
|
||||
this.sData.hit_count++
|
||||
|
||||
// 检查技能是否应该销毁
|
||||
if( this.sData.hit_count>=(this.SConf.hit+ this.sData.Attrs[Attrs.PUNCTURE])&&(this.SConf.DTType!=DTType.range)&&(this.endType!=EType.animationEnd)&&(this.endType!=EType.timeEnd)) this.ent.destroy// 技能命中次数
|
||||
}
|
||||
/** 视图对象通过 ecs.Entity.remove(ModuleViewComp) 删除组件是触发组件处理自定义释放逻辑 */
|
||||
|
||||
Reference in New Issue
Block a user