feat(英雄): 添加普通攻击后触发技能机制
在 HeroInfo 接口中添加 atking 字段,用于配置普攻后触发的技能。 在 SCastSystem 的 castSkill 方法中,当释放的技能为普通技能时,增加攻击计数并检查是否满足触发条件。 新增 checkAndTriggerAtkingSkills 方法,根据配置的触发次数,通过消息系统触发对应技能。
This commit is contained in:
@@ -67,6 +67,7 @@ export interface heroInfo {
|
|||||||
dead?:number[]; // 死亡后触发的技能uuid列表
|
dead?:number[]; // 死亡后触发的技能uuid列表
|
||||||
fstart?:number[]; // 战斗开始时释放的技能uuid列表
|
fstart?:number[]; // 战斗开始时释放的技能uuid列表
|
||||||
fend?:number[]; // 战斗结束时释放的技能uuid列表
|
fend?:number[]; // 战斗结束时释放的技能uuid列表
|
||||||
|
atking?:{s_uuid:number, t_num:number}[]; // 普通攻击后触发的技能配置,s_uuid: 技能id, t_num: 触发所需的普攻次数
|
||||||
// dis: number; // 攻击距离(像素)
|
// dis: number; // 攻击距离(像素)
|
||||||
speed: number; // 移动速度(像素/秒)
|
speed: number; // 移动速度(像素/秒)
|
||||||
skills: Record<number, HSkillInfo> ; // 携带技能ID列表
|
skills: Record<number, HSkillInfo> ; // 携带技能ID列表
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { HeroViewComp } from "./HeroViewComp";
|
|||||||
import { DTType, RType, SkillConfig, SkillKind, SkillSet, SkillUpList, TGroup } from "../common/config/SkillSet";
|
import { DTType, RType, SkillConfig, SkillKind, SkillSet, SkillUpList, TGroup } from "../common/config/SkillSet";
|
||||||
import { Skill } from "../skill/Skill";
|
import { Skill } from "../skill/Skill";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
import { HType } from "../common/config/heroSet";
|
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||||
import { Attrs } from "../common/config/HeroAttrs";
|
import { Attrs } from "../common/config/HeroAttrs";
|
||||||
import { BoxSet, FacSet, FightSet } from "../common/config/GameSet";
|
import { BoxSet, FacSet, FightSet } from "../common/config/GameSet";
|
||||||
import { oops } from "db://oops-framework/core/Oops";
|
import { oops } from "db://oops-framework/core/Oops";
|
||||||
@@ -300,6 +300,14 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
//播放角色攻击动画
|
//播放角色攻击动画
|
||||||
heroView.playSkillAnm(config.act);
|
heroView.playSkillAnm(config.act);
|
||||||
|
|
||||||
|
// 因为 castSkill 只由 update 循环调用,处理的必然是 heroAttrs.skills 中的普通技能
|
||||||
|
// 特殊触发技能(call/dead/atking等)走的是 forceCastTriggerSkill,不会调用 castSkill
|
||||||
|
const skillIds = heroAttrs.getSkillIds();
|
||||||
|
if (skillIds.includes(s_uuid)) {
|
||||||
|
heroAttrs.atk_count++;
|
||||||
|
this.checkAndTriggerAtkingSkills(heroAttrs, heroView);
|
||||||
|
}
|
||||||
|
|
||||||
// 优先使用技能配置的前摇时间,否则使用全局默认值
|
// 优先使用技能配置的前摇时间,否则使用全局默认值
|
||||||
// 注意:这里仍然是基于时间的延迟,受帧率波动影响。
|
// 注意:这里仍然是基于时间的延迟,受帧率波动影响。
|
||||||
// 若需精确同步,建议在动画中添加帧事件并在 HeroViewComp 中监听。
|
// 若需精确同步,建议在动画中添加帧事件并在 HeroViewComp 中监听。
|
||||||
@@ -325,6 +333,23 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
heroAttrs.triggerSkillCD(s_uuid);
|
heroAttrs.triggerSkillCD(s_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 检查并触发攻击附加技能 (atking) */
|
||||||
|
private checkAndTriggerAtkingSkills(heroAttrs: HeroAttrsComp, heroView: HeroViewComp) {
|
||||||
|
const heroInfo = HeroInfo[heroAttrs.hero_uuid];
|
||||||
|
if (!heroInfo || !heroInfo.atking || heroInfo.atking.length === 0) return;
|
||||||
|
|
||||||
|
heroInfo.atking.forEach(atkConfig => {
|
||||||
|
if (heroAttrs.atk_count > 0 && heroAttrs.atk_count % atkConfig.t_num === 0) {
|
||||||
|
oops.message.dispatchEvent(GameEvent.TriggerSkill, {
|
||||||
|
s_uuid: atkConfig.s_uuid,
|
||||||
|
heroAttrs: heroAttrs,
|
||||||
|
heroView: heroView,
|
||||||
|
triggerType: 'atking'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
private resolveRepeatCastTargetPos(targetPos: Vec3 | null, castIndex: number): Vec3 | null {
|
private resolveRepeatCastTargetPos(targetPos: Vec3 | null, castIndex: number): Vec3 | null {
|
||||||
if (!targetPos) return null;
|
if (!targetPos) return null;
|
||||||
if (castIndex === 1) return new Vec3(targetPos.x, targetPos.y + 15, targetPos.z);
|
if (castIndex === 1) return new Vec3(targetPos.x, targetPos.y + 15, targetPos.z);
|
||||||
|
|||||||
Reference in New Issue
Block a user