feat(battle): 重构技能施放与战斗距离系统
- 新增技能距离缓存机制,根据英雄类型动态计算最小和最大攻击范围 - 重构SCastSystem实现完整的技能施放逻辑,支持伤害、治疗、护盾和buff技能 - 在Hero和Monster初始化时调用updateSkillDistanceCache预计算技能距离 - 修改HeroMoveSystem和MonMoveSystem使用动态战斗范围,支持撤退逻辑 - 优化Skill实体创建,增加对象池支持 - 添加技能CD触发方法和状态检查方法
This commit is contained in:
@@ -2,8 +2,8 @@ import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ec
|
||||
import { oops } from "../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { Attrs, BType } from "../common/config/HeroAttrs";
|
||||
import { BuffConf, SkillDisVal, SkillRange, SkillSet } from "../common/config/SkillSet";
|
||||
import { HeroInfo } from "../common/config/heroSet";
|
||||
import { BuffConf, SkillDisVal, SkillRange } from "../common/config/SkillSet";
|
||||
import { HeroInfo, HType } from "../common/config/heroSet";
|
||||
import { mLogger } from "../common/Logger";
|
||||
import { _decorator } from "cc";
|
||||
|
||||
@@ -267,11 +267,25 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
this.a_cd+=dt
|
||||
if(this.a_cd >= this.a_cd_max) this.can_atk = true
|
||||
}
|
||||
if(this.skill_id !=0&&this.can_skill){
|
||||
if(this.skill_id !=0&&!this.can_skill){
|
||||
this.s_cd+=dt
|
||||
if(this.s_cd >= this.s_cd_max) this.can_skill = true
|
||||
}
|
||||
}
|
||||
isStun(): boolean {
|
||||
return this.in_stun;
|
||||
}
|
||||
isFrost(): boolean {
|
||||
return this.in_frost;
|
||||
}
|
||||
triggerAtkCD() {
|
||||
this.a_cd = 0;
|
||||
this.can_atk = false;
|
||||
}
|
||||
triggerSkillCD() {
|
||||
this.s_cd = 0;
|
||||
this.can_skill = false;
|
||||
}
|
||||
// ==================== 临时 BUFF/DEBUFF 更新 ====================
|
||||
/**
|
||||
* 更新临时 buff/debuff 的剩余时间
|
||||
@@ -342,16 +356,26 @@ export class HeroAttrsComp extends ecs.Comp {
|
||||
* @param skillsComp 技能组件
|
||||
*/
|
||||
public updateSkillDistanceCache(skill_id:number): void {
|
||||
let skillConf=SkillSet[skill_id];
|
||||
if (!skillConf) {
|
||||
this.maxSkillDistance = 0;
|
||||
this.minSkillDistance = 0;
|
||||
return;
|
||||
void skill_id;
|
||||
let rangeType = this.rangeType;
|
||||
if (rangeType === undefined || rangeType === null) {
|
||||
if (this.type === HType.remote) {
|
||||
rangeType = SkillRange.Long;
|
||||
} else if (this.type === HType.mage || this.type === HType.support) {
|
||||
rangeType = SkillRange.Mid;
|
||||
} else {
|
||||
rangeType = SkillRange.Melee;
|
||||
}
|
||||
}
|
||||
// 最远距离使用当前MP可施放的技能
|
||||
this.maxSkillDistance = SkillDisVal[skillConf.dis];
|
||||
// 最近距离使用所有技能中的最小距离,不考虑MP限制,用于停止位置判断
|
||||
this.minSkillDistance = SkillDisVal[skillConf.dis];
|
||||
const maxRange = SkillDisVal[rangeType];
|
||||
let minRange = 0;
|
||||
if (rangeType === SkillRange.Mid) {
|
||||
minRange = SkillDisVal[SkillRange.Melee];
|
||||
} else if (rangeType === SkillRange.Long) {
|
||||
minRange = SkillDisVal[SkillRange.Mid];
|
||||
}
|
||||
this.maxSkillDistance = maxRange;
|
||||
this.minSkillDistance = minRange;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user