feat(技能系统): 为重复施放技能添加偏移目标与起始位置
当技能重复施放时,根据施放序号调整目标位置和起始位置,使多次施放的效果在垂直方向上产生偏移,避免完全重叠。
This commit is contained in:
@@ -134,12 +134,20 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
this.applyFriendlySkillEffects(s_uuid, skillLv, config, heroView, heroAttrs, friendlyTargets, null);
|
this.applyFriendlySkillEffects(s_uuid, skillLv, config, heroView, heroAttrs, friendlyTargets, null);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.applyEnemySkillEffects(s_uuid, skillLv, config, heroView, heroAttrs, castPlan.targetPos);
|
const enemyTargetPos = this.resolveRepeatCastTargetPos(castPlan.targetPos, i);
|
||||||
|
this.applyEnemySkillEffects(s_uuid, skillLv, config, heroView, heroAttrs, enemyTargetPos, i);
|
||||||
}
|
}
|
||||||
}, delay);
|
}, delay);
|
||||||
heroAttrs.triggerSkillCD(s_uuid);
|
heroAttrs.triggerSkillCD(s_uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private resolveRepeatCastTargetPos(targetPos: Vec3 | null, castIndex: number): Vec3 | null {
|
||||||
|
if (!targetPos) return null;
|
||||||
|
if (castIndex === 1) return new Vec3(targetPos.x, targetPos.y + 15, targetPos.z);
|
||||||
|
if (castIndex === 2) return new Vec3(targetPos.x, targetPos.y - 15, targetPos.z);
|
||||||
|
return targetPos;
|
||||||
|
}
|
||||||
|
|
||||||
/** 构建技能尝试顺序:优先主动技能,其次普攻 */
|
/** 构建技能尝试顺序:优先主动技能,其次普攻 */
|
||||||
private buildSkillCandidates(skillIds: number[]): number[] {
|
private buildSkillCandidates(skillIds: number[]): number[] {
|
||||||
if (!skillIds || skillIds.length === 0) return [];
|
if (!skillIds || skillIds.length === 0) return [];
|
||||||
@@ -151,24 +159,31 @@ export class SCastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate
|
|||||||
* 创建技能实体(投射物/范围体等)。
|
* 创建技能实体(投射物/范围体等)。
|
||||||
* 仅用于对敌伤害技能的实体化表现与碰撞伤害分发。
|
* 仅用于对敌伤害技能的实体化表现与碰撞伤害分发。
|
||||||
*/
|
*/
|
||||||
private createSkillEntity(s_uuid: number, skillLv: number, caster: HeroViewComp,cAttrsComp: HeroAttrsComp, targetPos: Vec3) {
|
private createSkillEntity(s_uuid: number, skillLv: number, caster: HeroViewComp,cAttrsComp: HeroAttrsComp, targetPos: Vec3, castIndex: number = 0) {
|
||||||
if (!caster.node || !caster.node.isValid) return;
|
if (!caster.node || !caster.node.isValid) return;
|
||||||
const parent = caster.node.parent;
|
const parent = caster.node.parent;
|
||||||
if (!parent) return;
|
if (!parent) return;
|
||||||
const skill = ecs.getEntity<Skill>(Skill);
|
const skill = ecs.getEntity<Skill>(Skill);
|
||||||
const sNum= Math.floor(SkillUpList[s_uuid].num*skillLv)
|
const sNum= Math.floor(SkillUpList[s_uuid].num*skillLv)
|
||||||
skill.load(caster.node.position.clone(), parent, s_uuid, targetPos.clone(), caster, cAttrsComp, skillLv, 0);
|
const startPos = this.resolveRepeatCastStartPos(caster.node.position, castIndex);
|
||||||
|
skill.load(startPos, parent, s_uuid, targetPos.clone(), caster, cAttrsComp, skillLv, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对敌技能效果处理。
|
* 对敌技能效果处理。
|
||||||
* 当前职责:仅处理伤害技能并创建技能实体。
|
* 当前职责:仅处理伤害技能并创建技能实体。
|
||||||
*/
|
*/
|
||||||
private applyEnemySkillEffects(s_uuid: number, skillLv: number, config: SkillConfig, heroView: HeroViewComp, cAttrsComp: HeroAttrsComp, targetPos: Vec3 | null) {
|
private applyEnemySkillEffects(s_uuid: number, skillLv: number, config: SkillConfig, heroView: HeroViewComp, cAttrsComp: HeroAttrsComp, targetPos: Vec3 | null, castIndex: number = 0) {
|
||||||
const kind = config.kind ?? SkillKind.Damage;
|
const kind = config.kind ?? SkillKind.Damage;
|
||||||
if (kind !== SkillKind.Damage) return;
|
if (kind !== SkillKind.Damage) return;
|
||||||
if (config.ap <= 0 || !targetPos) return;
|
if (config.ap <= 0 || !targetPos) return;
|
||||||
this.createSkillEntity(s_uuid, skillLv, heroView, cAttrsComp, targetPos);
|
this.createSkillEntity(s_uuid, skillLv, heroView, cAttrsComp, targetPos, castIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
private resolveRepeatCastStartPos(startPos: Readonly<Vec3>, castIndex: number): Vec3 {
|
||||||
|
if (castIndex === 1) return new Vec3(startPos.x, startPos.y + 15, startPos.z);
|
||||||
|
if (castIndex === 2) return new Vec3(startPos.x, startPos.y - 15, startPos.z);
|
||||||
|
return startPos.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user