feat(movement): 添加移动速度属性并调整速度计算逻辑

- 在DBuff和Attrs中新增移动速度相关字段SPEED
- 修改getAttrFieldFromDebuff映射,支持移动速度下降Debuff
- 修正DbuffConf接口中deV拼写错误
- BattleMoveSystem中使用Attrs.SPEED替代原慢速减值计算速度
- HeroViewComp中修复deV字段拼写并更新减速效果处理逻辑
- 移除未使用和无效的状态类Debuff标记,优化逻辑判断
This commit is contained in:
2025-10-17 10:54:02 +08:00
parent d8ba69aada
commit d9282b7469
3 changed files with 17 additions and 16 deletions

View File

@@ -111,6 +111,7 @@ export enum DBuff {
DODGE = 12, //-闪避 - 对应Attrs.DODGE (闪避), BType.RATIO
DBUFFUP=13, //edbuff效果提升
BUFF_DOWN = 14,// buff效果减弱
SPEED = 15, //移动速度下降 - 对应Attrs.MOVE_SPEED (移动速度), BType.RATIO
}
@@ -142,6 +143,7 @@ export enum Attrs {
BUFF_UP = 24, //buff效果提升
DBUFF_UP=25, //debuff效果提升
DIS=26, //攻击距离
SPEED = 27, //移动速度加成,默认都是百分比
}
export const getAttrs=()=>{
@@ -172,9 +174,7 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
// 状态类 debuff只需缓存不影响属性
const stateDebuffSet = new Set<DBuff>([
DBuff.STUN,
DBuff.SLOW,
DBuff.FROST,
DBuff.BURN,
]);
// 检查是否是状态类 debuff
@@ -200,6 +200,8 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
[DBuff.DODGE]: Attrs.DODGE, // -闪避 -> 闪避
[DBuff.DBUFFUP]: Attrs.DBUFF_UP, // debuff提升 -> debuff提升
[DBuff.BUFF_DOWN]: Attrs.BUFF_UP, // buff减弱 -> buff效果
[DBuff.SPEED]: Attrs.SPEED, // 移动速度下降 -> 移动速度
};
const attrField = debuffAttrMap[debuffType];
@@ -287,9 +289,9 @@ export const HeroSkillList = [6001,6001,6001,6001,6001,6001]
export interface DbuffConf {
debuff: DBuff; // debuff类型
BType:BType //buff是数值型还是百分比型
dev: number; // 效果值 (原deV)
deV: number; // 效果值
deC: number; // 持续时间
deR: number; // 触发概率 (原deR)
deR: number; // 触发概率
}
export interface BuffConf {
buff:Attrs;

View File

@@ -29,9 +29,9 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
if (!shouldStop) { //在攻击范围内停止移动
// if(view.fac==1){
const hasStun = view.V_DBUFF.some(d => d.debuff === DBuff.STUN);
const hasFrost = view.V_DBUFF.some(d => d.debuff === DBuff.FROST);
if(view.is_stop||view.is_dead||hasStun||hasFrost) {
const isStun = view.V_DBUFF.some(d => d.debuff === DBuff.STUN);
const isFrost = view.V_DBUFF.some(d => d.debuff === DBuff.FROST);
if(view.is_stop||view.is_dead||isStun||isFrost) {
view.status_change("idle");
return; //停止移动或者死亡不移动
}
@@ -40,7 +40,6 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
view.status_change("idle");
return;
}
// 英雄阵营特殊逻辑:根据职业区分行为
if (view.fac == FacSet.HERO) {
const hasEnemies = this.checkEnemiesExist(e);
@@ -65,7 +64,7 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
}
// 继续向敌人方向移动
const delta = ((view.speed-view.DEBUFF_SLOW)/3) * this.dt * move.direction;
const delta = (view.Attrs[Attrs.SPEED]/3) * this.dt * move.direction;
const newX = view.node.position.x + delta;
// 对于战士,允许更自由的移动范围
@@ -92,7 +91,7 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
if (Math.abs(currentX - finalTargetX) > 1) {
// 确定移动方向
const direction = currentX > finalTargetX ? -1 : 1;
const delta = ((view.speed-view.DEBUFF_SLOW)/3) * this.dt * direction;
const delta = (view.Attrs[Attrs.SPEED]/3) * this.dt * direction;
const newX = view.node.position.x + delta;
// 设置朝向
@@ -124,7 +123,7 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
}
// 计算移动量
const delta = ((view.speed-view.DEBUFF_SLOW)/3) * this.dt * move.direction;
const delta =(view.Attrs[Attrs.SPEED]/3) * this.dt * move.direction;
const newX = view.node.position.x + delta;
// 限制移动范围

View File

@@ -40,7 +40,7 @@ const { ccclass, property } = _decorator;
* const dbuffConf: DbuffConf = {
* debuff: DBuff.STUN, // 眩晕
* BType: BType.VALUE, // 数值型
* dev: 20, // 减少值
* deV: 20, // 减少值
* deC: 3, // 持续3秒
* deR: 100 // 触发概率(100%)
* };
@@ -386,7 +386,7 @@ export class HeroViewComp extends CCComp {
for (const debuff of this.V_DBUFF) {
// 跳过状态类 debuffattrField === -1
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
this.Attrs[debuff.attrField] -= debuff.dev;
this.Attrs[debuff.attrField] -= debuff.deV;
}
}
@@ -394,7 +394,7 @@ export class HeroViewComp extends CCComp {
for (const debuff of this.V_DBUFFS) {
// 跳过状态类 debuffattrField === -1
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
this.Attrs[debuff.attrField] -= debuff.dev;
this.Attrs[debuff.attrField] -= debuff.deV;
}
}
}
@@ -417,7 +417,7 @@ export class HeroViewComp extends CCComp {
// 跳过状态类 debuffattrField === -1
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
const baseVal = baseValues[debuff.attrField] || this.Attrs[debuff.attrField];
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.dev / 100));
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.deV / 100));
}
}
@@ -426,7 +426,7 @@ export class HeroViewComp extends CCComp {
// 跳过状态类 debuffattrField === -1
if (debuff.attrField !== undefined && debuff.attrField >= 0) {
const baseVal = baseValues[debuff.attrField] || this.Attrs[debuff.attrField];
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.dev / 100));
this.Attrs[debuff.attrField] -= Math.floor(baseVal * (debuff.deV / 100));
}
}
}