feat(技能系统): 添加最大技能自动施放开关并重构施法逻辑
- 在HeroSkillsComp中添加max_auto字段控制最大技能自动施放 - 重构SACastSystem的施法逻辑,增加返回值判断 - 新增manualCast和manualCastMax方法支持手动施法 - 删除废弃的SCastSystem文件
This commit is contained in:
@@ -52,6 +52,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
for (const s_uuid of readySkills) {
|
||||
const skill = skills.getSkill(s_uuid);
|
||||
if (!skill) continue;
|
||||
if (skill.hset === HSSet.max && !skills.max_auto) continue;
|
||||
|
||||
const config = SkillSet[skill.s_uuid];
|
||||
if (!config || config.SType !== SType.damage) continue;
|
||||
@@ -66,20 +67,44 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
break;
|
||||
}
|
||||
}
|
||||
private startCast(e: ecs.Entity,skill:SkillSlot,hset:HSSet): void {
|
||||
if (!skill||!e) return
|
||||
private startCast(e: ecs.Entity,skill:SkillSlot,hset:HSSet): boolean {
|
||||
if (!skill||!e) return false
|
||||
const skills = e.get(HeroSkillsComp);
|
||||
const heroAttrs = e.get(HeroAttrsComp);
|
||||
const heroView = e.get(HeroViewComp);
|
||||
// 3. 检查施法条件
|
||||
if (!this.checkCastConditions(skills, heroAttrs, skill.s_uuid)) return
|
||||
if (!this.checkCastConditions(skills, heroAttrs, skill.s_uuid)) return false
|
||||
|
||||
// 4. 执行施法
|
||||
this.executeCast(e, skill.s_uuid, heroView,hset);
|
||||
const ok = this.executeCast(e, skill.s_uuid, heroView,hset);
|
||||
// 5. 扣除资源和重置CD
|
||||
heroAttrs.mp -= skill.cost;
|
||||
skills.resetCD(skill.s_uuid);
|
||||
|
||||
if (ok) {
|
||||
heroAttrs.mp -= skill.cost;
|
||||
skills.resetCD(skill.s_uuid);
|
||||
}
|
||||
return ok;
|
||||
}
|
||||
public manualCast(e: ecs.Entity, s_uuid: number): boolean {
|
||||
if (!e) return false
|
||||
const skills = e.get(HeroSkillsComp)
|
||||
const heroAttrs = e.get(HeroAttrsComp)
|
||||
const heroView = e.get(HeroViewComp)
|
||||
if (!skills || !heroAttrs || !heroView) return false
|
||||
const slot = skills.getSkill(s_uuid)
|
||||
if (!slot) return false
|
||||
return this.startCast(e, slot, slot.hset)
|
||||
}
|
||||
public manualCastMax(e: ecs.Entity): boolean {
|
||||
const skills = e.get(HeroSkillsComp)
|
||||
if (!skills) return false
|
||||
for (const key in skills.skills) {
|
||||
const s_uuid = Number(key)
|
||||
const slot = skills.getSkill(s_uuid)
|
||||
if (slot && slot.hset === HSSet.max) {
|
||||
return this.manualCast(e, s_uuid)
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
/**
|
||||
* 检查施法条件
|
||||
@@ -106,11 +131,11 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
/**
|
||||
* 执行施法
|
||||
*/
|
||||
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet) {
|
||||
private executeCast(casterEntity: ecs.Entity, s_uuid: number, heroView: HeroViewComp,hset:HSSet): boolean {
|
||||
const config = SkillSet[s_uuid];
|
||||
if (!config) {
|
||||
console.error("[SACastSystem] 技能配置不存在:", s_uuid);
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
// 1. 播放施法动画
|
||||
heroView.playSkillEffect(s_uuid);
|
||||
@@ -144,6 +169,7 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
||||
|
||||
const heroAttrs = casterEntity.get(HeroAttrsComp);
|
||||
// console.log(`[SACastSystem] ${heroAttrs?.hero_name ?? '未知'} 施放技能: ${config.name}`);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user