- 在 Attrs 中添加力量、智力、敏捷、精神、幸运基本属性 - 为新增属性配置属性类型为数值型(BType.VALUE) - 新增 HeroBaseAttributes,定义不同英雄类型的基础属性初始值 - 设计 AttributeInfluence,定义基础属性对战斗属性的影响系数 - 实现 calculateBaseAttributes 方法,根据英雄类型和等级计算基础属性值 - 实现 calculateAttributeInfluences 方法,计算基础属性对战斗属性的具体影响值 - 在 heroSet.ts 中增加相关类型导入和类型定义,完善属性系统逻辑
259 lines
10 KiB
TypeScript
259 lines
10 KiB
TypeScript
import { v3 } from "cc"
|
||
import { FacSet } from "./BoxSet"
|
||
import { smc } from "../SingletonModuleComp"
|
||
import { BuffConf, DbuffConf, Attrs } from "./SkillSet"
|
||
import { debuff } from "../../skills/debuff"
|
||
|
||
export enum AttrSet {
|
||
ATTR_MAX = 85,
|
||
}
|
||
export enum HType {
|
||
warrior = 0,
|
||
remote = 1,
|
||
mage = 2,
|
||
support = 3,
|
||
assassin = 4,
|
||
}
|
||
|
||
// 英雄基础属性配置表
|
||
// 定义每种英雄类型的力量、智力、敏捷、精神、幸运基础值
|
||
export const HeroBaseAttributes: Record<HType, { strength: number; intelligence: number; agility: number; spirit: number; luck: number }> = {
|
||
[HType.warrior]: { strength: 10, intelligence: 3, agility: 5, spirit: 4, luck: 3 },
|
||
[HType.remote]: { strength: 5, intelligence: 6, agility: 10, spirit: 4, luck: 5 },
|
||
[HType.mage]: { strength: 3, intelligence: 10, agility: 4, spirit: 8, luck: 5 },
|
||
[HType.support]: { strength: 4, intelligence: 8, agility: 5, spirit: 10, luck: 3 },
|
||
[HType.assassin]: { strength: 7, intelligence: 5, agility: 10, spirit: 3, luck: 5 },
|
||
}
|
||
|
||
// 基础属性对战斗属性的影响配置
|
||
// 定义基础属性如何影响其他战斗属性的系数
|
||
export const AttributeInfluence: Record<string, { attribute: Attrs; ratio: number }> = {
|
||
// 力量影响
|
||
"strength_to_ap": { attribute: Attrs.AP, ratio: 2 }, // 力量影响攻击力 (每点力量增加2点攻击力)
|
||
"strength_to_hp": { attribute: Attrs.HP_MAX, ratio: 10 }, // 力量影响生命值 (每点力量增加10点生命值)
|
||
|
||
// 智力影响
|
||
"intelligence_to_map": { attribute: Attrs.MAP, ratio: 3 }, // 智力影响魔法攻击力 (每点智力增加3点魔法攻击力)
|
||
"intelligence_to_mp": { attribute: Attrs.MP_MAX, ratio: 15 }, // 智力影响魔法值 (每点智力增加15点魔法值)
|
||
"intelligence_to_mdef": { attribute: Attrs.MDEF, ratio: 1 }, // 智力影响魔法防御 (每点智力增加1点魔法防御)
|
||
|
||
// 敏捷影响
|
||
"agility_to_as": { attribute: Attrs.AS, ratio: 0.5 }, // 敏捷影响攻击速度 (每点敏捷增加0.5%攻击速度)
|
||
"agility_to_dodge": { attribute: Attrs.DODGE, ratio: 0.4 }, // 敏捷影响闪避 (每点敏捷增加0.4%闪避)
|
||
"agility_to_hit": { attribute: Attrs.HIT, ratio: 0.3 }, // 敏捷影响命中 (每点敏捷增加0.3%命中)
|
||
|
||
// 精神影响
|
||
"spirit_to_mdef": { attribute: Attrs.MDEF, ratio: 2 }, // 精神影响魔法防御 (每点精神增加2点魔法防御)
|
||
"spirit_to_hp": { attribute: Attrs.HP_MAX, ratio: 5 }, // 精神影响生命值 (每点精神增加5点生命值)
|
||
"spirit_to_mp": { attribute: Attrs.MP_MAX, ratio: 10 }, // 精神影响魔法值 (每点精神增加10点魔法值)
|
||
|
||
// 幸运影响
|
||
"luck_to_critical": { attribute: Attrs.CRITICAL, ratio: 0.6 }, // 幸运影响暴击率 (每点幸运增加0.6%暴击率)
|
||
"luck_to_lifesteal": { attribute: Attrs.LIFESTEAL, ratio: 0.2 }, // 幸运影响吸血比率 (每点幸运增加0.2%吸血比率)
|
||
};
|
||
|
||
/**
|
||
* 根据英雄类型和等级计算基础属性值
|
||
* @param heroType 英雄类型
|
||
* @param level 英雄等级
|
||
* @returns 包含所有基础属性值的对象
|
||
*/
|
||
export function calculateBaseAttributes(heroType: HType, level: number): { strength: number; intelligence: number; agility: number; spirit: number; luck: number } {
|
||
const baseAttrs = HeroBaseAttributes[heroType];
|
||
// 简单的等级成长公式,每级增加1点基础属性
|
||
const growth = level - 1;
|
||
|
||
return {
|
||
strength: baseAttrs.strength + growth,
|
||
intelligence: baseAttrs.intelligence + growth,
|
||
agility: baseAttrs.agility + growth,
|
||
spirit: baseAttrs.spirit + growth,
|
||
luck: baseAttrs.luck + growth
|
||
};
|
||
}
|
||
|
||
/**
|
||
* 根据基础属性计算对战斗属性的影响
|
||
* @param baseAttributes 基础属性值
|
||
* @returns 属性影响映射表
|
||
*/
|
||
export function calculateAttributeInfluences(baseAttributes: { strength: number; intelligence: number; agility: number; spirit: number; luck: number }): Record<Attrs, number> {
|
||
// 初始化所有属性影响值为0
|
||
const influences: Record<Attrs, number> = {
|
||
[Attrs.HP_MAX]: 0,
|
||
[Attrs.MP_MAX]: 0,
|
||
[Attrs.SHIELD_MAX]: 0,
|
||
[Attrs.AP]: 0,
|
||
[Attrs.MAP]: 0,
|
||
[Attrs.DEF]: 0,
|
||
[Attrs.MDEF]: 0,
|
||
[Attrs.CRITICAL]: 0,
|
||
[Attrs.CRITICAL_DMG]: 0,
|
||
[Attrs.DODGE]: 0,
|
||
[Attrs.HIT]: 0,
|
||
[Attrs.WFUNY]: 0,
|
||
[Attrs.AS]: 0,
|
||
[Attrs.REFLICT]: 0,
|
||
[Attrs.LIFESTEAL]: 0,
|
||
[Attrs.BACK]: 0,
|
||
[Attrs.DEBACK]: 0,
|
||
[Attrs.CON_RES]: 0,
|
||
[Attrs.ICE_RES]: 0,
|
||
[Attrs.FIRE_RES]: 0,
|
||
[Attrs.WIND_RES]: 0,
|
||
[Attrs.ICE_POWER]: 0,
|
||
[Attrs.FIRE_POWER]: 0,
|
||
[Attrs.WIND_POWER]: 0,
|
||
[Attrs.BUFF_UP]: 0,
|
||
[Attrs.DBUFF_UP]: 0,
|
||
[Attrs.DIS]: 0,
|
||
[Attrs.SPEED]: 0,
|
||
[Attrs.SHIELD_UP]: 0,
|
||
[Attrs.BURN]: 0,
|
||
[Attrs.DEBURN]: 0,
|
||
[Attrs.PUNCTURE]: 0,
|
||
[Attrs.PUNCTURE_DMG]: 0,
|
||
[Attrs.STRENGTH]: 0,
|
||
[Attrs.INTELLIGENCE]: 0,
|
||
[Attrs.AGILITY]: 0,
|
||
[Attrs.SPIRIT]: 0,
|
||
[Attrs.LUCK]: 0
|
||
};
|
||
|
||
// 计算力量的影响
|
||
influences[Attrs.AP] += baseAttributes.strength * (AttributeInfluence["strength_to_ap"]?.ratio || 0);
|
||
influences[Attrs.HP_MAX] += baseAttributes.strength * (AttributeInfluence["strength_to_hp"]?.ratio || 0);
|
||
|
||
// 计算智力的影响
|
||
influences[Attrs.MAP] += baseAttributes.intelligence * (AttributeInfluence["intelligence_to_map"]?.ratio || 0);
|
||
influences[Attrs.MP_MAX] += baseAttributes.intelligence * (AttributeInfluence["intelligence_to_mp"]?.ratio || 0);
|
||
influences[Attrs.MDEF] += baseAttributes.intelligence * (AttributeInfluence["intelligence_to_mdef"]?.ratio || 0);
|
||
|
||
// 计算敏捷的影响
|
||
influences[Attrs.AS] += baseAttributes.agility * (AttributeInfluence["agility_to_as"]?.ratio || 0);
|
||
influences[Attrs.DODGE] += baseAttributes.agility * (AttributeInfluence["agility_to_dodge"]?.ratio || 0);
|
||
influences[Attrs.HIT] += baseAttributes.agility * (AttributeInfluence["agility_to_hit"]?.ratio || 0);
|
||
|
||
// 计算精神的影响
|
||
influences[Attrs.MDEF] += baseAttributes.spirit * (AttributeInfluence["spirit_to_mdef"]?.ratio || 0);
|
||
influences[Attrs.HP_MAX] += baseAttributes.spirit * (AttributeInfluence["spirit_to_hp"]?.ratio || 0);
|
||
influences[Attrs.MP_MAX] += baseAttributes.spirit * (AttributeInfluence["spirit_to_mp"]?.ratio || 0);
|
||
|
||
// 计算幸运的影响
|
||
influences[Attrs.CRITICAL] += baseAttributes.luck * (AttributeInfluence["luck_to_critical"]?.ratio || 0);
|
||
influences[Attrs.LIFESTEAL] += baseAttributes.luck * (AttributeInfluence["luck_to_lifesteal"]?.ratio || 0);
|
||
|
||
return influences;
|
||
}
|
||
|
||
export const HTypeName ={
|
||
0:"战士",
|
||
1:"远程",
|
||
2:"法师",
|
||
3:"辅助",
|
||
4:"刺客",
|
||
}
|
||
|
||
//fac:FacSet.HERO
|
||
export const getHeroList = ()=>{
|
||
const filteredHeros = Object.values(HeroInfo).filter(item=>{
|
||
const facMatch = item.fac === FacSet.HERO;
|
||
return facMatch;
|
||
});
|
||
|
||
// 根据smc.heros中的数据分离拥有和未拥有的英雄
|
||
// smc.heros是一个包含英雄ID的数组,如[5001, 5002]
|
||
const ownedHeros = filteredHeros.filter(item => smc.heros.includes(item.uuid));
|
||
const unownedHeros = filteredHeros.filter(item => !smc.heros.includes(item.uuid));
|
||
|
||
// 合并列表:拥有的在前,未拥有的在后
|
||
return [...ownedHeros, ...unownedHeros].map(item => item.uuid);
|
||
}
|
||
//fac:FacSet.MON
|
||
export const getMonList = ()=>{
|
||
return Object.values(HeroInfo).filter(item=>{
|
||
const facMatch = item.fac === FacSet.MON;
|
||
return facMatch ;
|
||
}).map(item=>item.uuid)
|
||
}
|
||
|
||
export const HeroPos={
|
||
0:{pos:v3(-240,100,0)},
|
||
1:{pos:v3(0,100,0)},
|
||
2:{pos:v3(0,100,0)},
|
||
}
|
||
export const MonSet = {
|
||
0:{pos:v3(240,100,0)},
|
||
1:{pos:v3(320,100,0)},
|
||
2:{pos:v3(360,100,0)},
|
||
3:{pos:v3(400,100,0)},
|
||
4:{pos:v3(440,100,0)},
|
||
5:{pos:v3(480,100,0)},
|
||
6:{pos:v3(520,100,0)},
|
||
7:{pos:v3(560,100,0)},
|
||
}
|
||
|
||
export enum HeroConf{
|
||
COST=1500,
|
||
}
|
||
export enum HeroUpSet {
|
||
MP=5,
|
||
HP=10,
|
||
LVMP=100,
|
||
LVHP=100,
|
||
LVATK=10,
|
||
LVDEF=5,
|
||
}
|
||
|
||
export interface heroInfo{
|
||
uuid:number, name:string, path:string,fac:FacSet,kind:number,type:HType,
|
||
hp:number,mp:number,map:number, def:number, ap:number,dis:number, speed:number,lv:number,skills:number[],
|
||
buff:BuffConf[], debuff:DbuffConf[], info:string
|
||
}
|
||
|
||
export const HeroInfo: Record<number, heroInfo> = {
|
||
//主将
|
||
5001:{uuid:5001,name:"刘邦",path:"hk1", fac:FacSet.HERO, kind:1,
|
||
type:HType.warrior,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:100,speed:150,skills:[6001,6005],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
5002:{uuid:5002,name:"荆轲",path:"hc1", fac:FacSet.HERO, kind:1,
|
||
type:HType.warrior,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:100,speed:150,skills:[6001,6005],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
5005:{uuid:5005,name:"绿箭",path:"ha1", fac:FacSet.HERO, kind:2,
|
||
type:HType.remote,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,speed:100,skills:[6001,6005],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
5007:{uuid:5007,name:"牧师",path:"hh1", fac:FacSet.HERO, kind:2,
|
||
type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,speed:100,skills:[6001,6005],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
5008:{uuid:5008,name:"火女",path:"hm1", fac:FacSet.HERO, kind:2,
|
||
type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,speed:100,skills:[6001,6005],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
5009:{uuid:5009,name:"魔法精灵",path:"hm2", fac:FacSet.HERO, kind:2,
|
||
type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,speed:100,skills:[6006,6006,6301,6302,6303],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
5010:{uuid:5010,name:"德鲁伊",path:"hz1", fac:FacSet.HERO, kind:2,
|
||
type:HType.mage,lv:1,hp:100,mp:100,map:100,def:5,ap:15,dis:400,speed:100,skills:[6007,6007,6301,6302,6303],
|
||
buff:[],debuff:[],info:""},
|
||
|
||
|
||
|
||
//怪物
|
||
5201:{uuid:5201,name:"兽人战士",path:"mo1", fac:FacSet.MON, kind:1,
|
||
type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,speed:100,skills:[6005],
|
||
buff:[],debuff:[],info:"普通怪物-战士型"},
|
||
|
||
5202:{uuid:5202,name:"兽人刺客",path:"mo1", fac:FacSet.MON, kind:1,
|
||
type:HType.remote,lv:1,hp:20,mp:100,map:100,def:5,ap:5,dis:350,speed:100,skills:[6005],
|
||
buff:[],debuff:[],info:"普通怪物-战士型"},
|
||
|
||
5203:{uuid:5203,name:"兽人护卫",path:"mo1", fac:FacSet.MON, kind:1,
|
||
type:HType.warrior,lv:1,hp:25,mp:100,map:100,def:5,ap:5,dis:90,speed:100,skills:[6005],
|
||
buff:[],debuff:[],info:"普通怪物-战士型"},
|
||
|
||
}; |