fix(战斗系统): 修复伤害数值出错问题
- 修复在DamageEvent接口和DamageQueueComp缺少ext_dmg和dmg_ratio字段问题 - 修复HeroAtkSystem的伤害计算逻辑 - 优化HeroViewComp的hp_show和mp_show方法,直接使用model数据 - 默认显示血条并增加调试日志输出 - 移除冗余的debug日志,优化伤害计算流程
This commit is contained in:
@@ -21,6 +21,9 @@ export interface DamageEvent {
|
||||
|
||||
/** 伤害事件ID(用于去重和调试) */
|
||||
eventId: string;
|
||||
|
||||
ext_dmg:number //额外伤害
|
||||
dmg_ratio:number//伤害比例
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -55,7 +58,7 @@ export class DamageQueueComp extends ecs.Comp {
|
||||
/**
|
||||
* 添加伤害事件到队列
|
||||
*/
|
||||
addDamageEvent(attrs: any, caster: HeroViewComp, s_uuid: number): void {
|
||||
addDamageEvent(attrs: any, caster: HeroViewComp, s_uuid: number,ext_dmg:number=0,dmg_ratio:number=1): void {
|
||||
const timestamp = Date.now();
|
||||
const eventId = `${caster.ent.eid}_${s_uuid}_${timestamp}_${Math.random()}`;
|
||||
|
||||
@@ -64,7 +67,9 @@ export class DamageQueueComp extends ecs.Comp {
|
||||
caster: caster,
|
||||
s_uuid: s_uuid,
|
||||
timestamp: timestamp,
|
||||
eventId: eventId
|
||||
eventId: eventId,
|
||||
ext_dmg:ext_dmg,
|
||||
dmg_ratio:dmg_ratio,
|
||||
};
|
||||
|
||||
this.damageEvents.push(damageEvent);
|
||||
@@ -155,7 +160,7 @@ export class DamageQueueHelper {
|
||||
* 为实体添加伤害事件
|
||||
* 如果实体没有伤害队列组件,会自动创建
|
||||
*/
|
||||
static addDamageToEntity(entity: ecs.Entity, attrs: any, caster: HeroViewComp, s_uuid: number): void {
|
||||
static addDamageToEntity(entity: ecs.Entity, attrs: any, caster: HeroViewComp, s_uuid: number,ext_dmg:number=0,dmg_ratio:number=1): void {
|
||||
let damageQueue = entity.get(DamageQueueComp);
|
||||
|
||||
// 如果实体没有伤害队列组件,创建一个
|
||||
@@ -164,7 +169,7 @@ export class DamageQueueHelper {
|
||||
}
|
||||
|
||||
// 添加伤害事件到队列
|
||||
damageQueue.addDamageEvent(attrs, caster, s_uuid);
|
||||
damageQueue.addDamageEvent(attrs, caster, s_uuid,ext_dmg,dmg_ratio);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user