refactor(英雄技能): 重构天赋触发逻辑和技能施放系统
- 将HeroAttrsComp中的isDSill和isWFuny改为talTrigger结构体 - 移除TalComp中不再使用的checkTriggers和checkIsTrigger方法 - 优化SACastSystem中的技能施放逻辑,分离天赋处理代码块 - 为Skill.load方法添加damage参数 - 重命名executeCast返回变量为castSucess以提高可读性
This commit is contained in:
@@ -77,13 +77,13 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
if (!this.checkCastConditions(skills, heroAttrs, skill.s_uuid)) return false
|
||||
|
||||
// 4. 执行施法
|
||||
const ok = this.executeCast(e, skill.s_uuid, heroView,hset);
|
||||
const castSucess = this.executeCast(e, skill.s_uuid, heroView,hset);
|
||||
// 5. 扣除资源和重置CD
|
||||
if (ok) {
|
||||
if (castSucess) {
|
||||
heroAttrs.mp -= skill.cost;
|
||||
skills.resetCD(skill.s_uuid);
|
||||
}
|
||||
return ok;
|
||||
return castSucess;
|
||||
}
|
||||
public manualCast(e: ecs.Entity, s_uuid: number): boolean {
|
||||
if (!e) return false
|
||||
@@ -134,8 +134,8 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
*/
|
||||
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet): boolean {
|
||||
const heroAttrs=casterEntity.get(HeroAttrsComp)
|
||||
let isDSill=heroAttrs.isDSill > 0
|
||||
let isWFuny=heroAttrs.isWFuny > 0
|
||||
let isDSill=heroAttrs.tal_DSill.count > 0
|
||||
let isWFuny=heroAttrs.tal_WFuny.count > 0
|
||||
const config = SkillSet[s_uuid];
|
||||
if (!config) {
|
||||
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
|
||||
@@ -144,14 +144,14 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
|
||||
// 1. 播放施法动画
|
||||
heroView.playSkillEffect(s_uuid);
|
||||
/**********************天赋处理*************************************************************************/
|
||||
// 2. 更新攻击类型的天赋触发值
|
||||
if(casterEntity.has(TalComp)){
|
||||
const talComp = casterEntity.get(TalComp);
|
||||
if (hset === HSSet.atk) talComp.updateCur(TriType.ATK);
|
||||
if (hset != HSSet.atk) talComp.updateCur(TriType.SKILL);
|
||||
|
||||
|
||||
}
|
||||
/**********************天赋处理*************************************************************************/
|
||||
// 获取目标位置
|
||||
let targets = this.sTargets(heroView, s_uuid);
|
||||
if (targets.length === 0) {
|
||||
@@ -161,28 +161,29 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
// 2. 延迟创建技能实体(等待动画)
|
||||
const delay = 0.3
|
||||
heroView.scheduleOnce(() => {
|
||||
//风怒wfuny 只针对 普通攻击起效
|
||||
if (hset === HSSet.atk&&isWFuny){
|
||||
this.createSkill(s_uuid, heroView,targets,isWFuny);
|
||||
heroAttrs.isWFuny --
|
||||
}else{
|
||||
this.createSkill(s_uuid, heroView,targets,false);
|
||||
}
|
||||
|
||||
this.createSkill(s_uuid, heroView,targets);
|
||||
}, delay);
|
||||
|
||||
if(isDSill){
|
||||
//风怒wfuny 只针对 普通攻击起效
|
||||
if (hset === HSSet.atk&&isWFuny){
|
||||
heroView.playSkillEffect(s_uuid);
|
||||
//需要再添加 风怒动画
|
||||
this.createSkill(s_uuid, heroView,targets);
|
||||
heroAttrs.tal_WFuny.count --
|
||||
}
|
||||
// 双技能 只针对 技能起效
|
||||
if(hset === HSSet.skill&&isDSill){
|
||||
targets = this.sTargets(heroView, s_uuid);
|
||||
if (targets.length === 0) {
|
||||
console.warn("[SACastSystem] 没有找到有效目标");
|
||||
return false;
|
||||
}
|
||||
heroAttrs.isDSill --
|
||||
heroView.playSkillEffect(s_uuid);
|
||||
//需要再添加 双技能动画
|
||||
heroView.scheduleOnce(() => {
|
||||
this.createSkill(s_uuid, heroView,targets,isWFuny);
|
||||
isWFuny=false
|
||||
this.createSkill(s_uuid, heroView,targets);
|
||||
}, delay);
|
||||
heroAttrs.tal_DSill.count --
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +194,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
/**
|
||||
* 创建技能实体
|
||||
*/
|
||||
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],isWFuny:boolean=false) {
|
||||
private createSkill(s_uuid: number, caster: HeroViewComp,targets:Vec3[]=[],damage:number=0) {
|
||||
// 检查节点有效性
|
||||
if (!caster.node || !caster.node.isValid) {
|
||||
console.warn("[SACastSystem] 施法者节点无效");
|
||||
@@ -218,7 +219,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
const targetPos = targets[0]; // 使用第一个目标位置
|
||||
// console.log(`[SACastSystem]: ${s_uuid}, 起始位置: ${startPos}, 目标位置: ${targetPos}`);
|
||||
// 加载技能实体(包括预制体、组件初始化等)
|
||||
skill.load(startPos, parent, s_uuid, targetPos, caster);
|
||||
skill.load(startPos, parent, s_uuid, targetPos, caster,damage);
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user