refactor(buff): 统一buff和debuff属性结构及类型区分
- 新增Buff类型枚举BType,区分数值型与百分比型属性 - 定义AttrsType,映射每个属性的类型(数值或百分比) - 添加辅助方法isRatioAttr和getAttrType用于属性类型判断 - HeroViewComp中buff和debuff相关属性名称重新命名,区分持久型和临时型及属性类型 - 修改buff/debuff的加载、应用、更新逻辑,适配新的属性结构 - 新增HeroViewComp的isStun和isFrost方法判断状态 - BattleMoveSystem中使用新判断方法替代旧列表遍历 - 移除SkillCom中未使用的BuffAttr导入项,优化依赖关系
This commit is contained in:
@@ -146,8 +146,9 @@ export enum Attrs {
|
||||
SPEED = 27, //移动速度加成,默认都是百分比
|
||||
}
|
||||
|
||||
|
||||
export const getAttrs=()=>{
|
||||
// 遍历枚举的数字值(枚举会生成双向映射)
|
||||
// 遍历枚举的数字值(枚举会生成双向映射)
|
||||
let reAttrs = {};
|
||||
Object.keys(Attrs).forEach(key => {
|
||||
if (!isNaN(Number(key))) {
|
||||
@@ -157,6 +158,74 @@ export const getAttrs=()=>{
|
||||
return reAttrs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Buff类型枚举
|
||||
* VALUE: 数值型 - 直接加减数值
|
||||
* RATIO: 百分比型 - 按百分比计算
|
||||
*/
|
||||
export enum BType {
|
||||
VALUE=0, //数值型
|
||||
RATIO=1 //百分比型
|
||||
}
|
||||
|
||||
/**
|
||||
* 属性类型配置表
|
||||
* 用于区分每个属性是数值型还是百分比型
|
||||
* - VALUE: 数值型属性(如生命值、攻击力等绝对数值)
|
||||
* - RATIO: 百分比型属性(如暴击率、闪避率等百分比数值)
|
||||
*/
|
||||
export const AttrsType: Record<Attrs, BType> = {
|
||||
// ========== 数值型属性 ==========
|
||||
[Attrs.HP_MAX]: BType.VALUE, // 最大生命值 - 数值型
|
||||
[Attrs.MP_MAX]: BType.VALUE, // 最大魔法值 - 数值型
|
||||
[Attrs.SHIELD_MAX]: BType.VALUE, // 最大护盾值 - 数值型
|
||||
[Attrs.AP]: BType.VALUE, // 攻击力 - 数值型
|
||||
[Attrs.MAP]: BType.VALUE, // 魔法攻击力 - 数值型
|
||||
[Attrs.DEF]: BType.VALUE, // 防御 - 数值型
|
||||
[Attrs.MDEF]: BType.VALUE, // 魔法防御 - 数值型
|
||||
[Attrs.DIS]: BType.VALUE, // 攻击距离 - 数值型
|
||||
|
||||
// ========== 百分比型属性 ==========
|
||||
[Attrs.CRITICAL]: BType.RATIO, // 暴击率 - 百分比型
|
||||
[Attrs.CRITICAL_DMG]: BType.RATIO, // 暴击伤害 - 百分比型
|
||||
[Attrs.DODGE]: BType.RATIO, // 闪避 - 百分比型
|
||||
[Attrs.HIT]: BType.RATIO, // 命中 - 百分比型
|
||||
[Attrs.WFUNY]: BType.RATIO, // 风怒 - 百分比型
|
||||
[Attrs.AS]: BType.RATIO, // 攻击速度 - 百分比型
|
||||
[Attrs.REFLICT]: BType.RATIO, // 反伤比率 - 百分比型
|
||||
[Attrs.LIFESTEAL]: BType.RATIO, // 吸血比率 - 百分比型
|
||||
[Attrs.KNOCKBACK]: BType.RATIO, // 击退概率 - 百分比型
|
||||
[Attrs.CON_RES]: BType.RATIO, // 控制抗性 - 百分比型
|
||||
[Attrs.ICE_RES]: BType.RATIO, // 冰冻抗性 - 百分比型
|
||||
[Attrs.FIRE_RES]: BType.RATIO, // 火抗性 - 百分比型
|
||||
[Attrs.WIND_RES]: BType.RATIO, // 风抗性 - 百分比型
|
||||
[Attrs.ICE_POWER]: BType.RATIO, // 冰冻伤害效果提升 - 百分比型
|
||||
[Attrs.FIRE_POWER]: BType.RATIO, // 火伤害效果提升 - 百分比型
|
||||
[Attrs.WIND_POWER]: BType.RATIO, // 风伤害效果提升 - 百分比型
|
||||
[Attrs.SHIELD_UP]: BType.RATIO, // 护盾效果提升 - 百分比型
|
||||
[Attrs.BUFF_UP]: BType.RATIO, // buff效果提升 - 百分比型
|
||||
[Attrs.DBUFF_UP]: BType.RATIO, // debuff效果提升 - 百分比型
|
||||
[Attrs.SPEED]: BType.RATIO, // 移动速度加成 - 百分比型
|
||||
};
|
||||
|
||||
/**
|
||||
* 判断属性是否为百分比型
|
||||
* @param attrType 属性类型
|
||||
* @returns true: 百分比型, false: 数值型
|
||||
*/
|
||||
export const isRatioAttr = (attrType: Attrs): boolean => {
|
||||
return AttrsType[attrType] === BType.RATIO;
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取属性的类型
|
||||
* @param attrType 属性类型
|
||||
* @returns BType.VALUE 或 BType.RATIO
|
||||
*/
|
||||
export const getAttrType = (attrType: Attrs): BType => {
|
||||
return AttrsType[attrType];
|
||||
};
|
||||
|
||||
/**
|
||||
* 获取 debuff 对应的属性字段
|
||||
* @param debuffType DBuff 类型
|
||||
@@ -214,14 +283,6 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
|
||||
|
||||
return attrField;
|
||||
};
|
||||
|
||||
|
||||
export enum BType {
|
||||
VALUE=0, //数值型
|
||||
RATIO=1 //百分比型
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=== 技能配置系统使用说明 ===
|
||||
|
||||
@@ -29,9 +29,7 @@ export class BattleMoveSystem extends ecs.ComblockSystem implements ecs.ISystemU
|
||||
|
||||
if (!shouldStop) { //在攻击范围内停止移动
|
||||
// if(view.fac==1){
|
||||
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) {
|
||||
if(view.is_stop||view.is_dead||view.isStun()||view.isFrost()) {
|
||||
view.status_change("idle");
|
||||
return; //停止移动或者死亡不移动
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user