refactor(hero): 重命名天赋相关方法以区分计数型和数值型
将计数型天赋操作方法从addTalent/consumeTalent重命名为addCountTal/useCountTal 将数值型天赋操作方法从addTalBuff/clearTalBuff重命名为addValueTal/useValueTalByUuid 更新相关文档和调用代码以保持一致性
This commit is contained in:
@@ -156,7 +156,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
// 暴击判定
|
// 暴击判定
|
||||||
// 使用施法者的暴击率属性(damageEvent.Attrs 快照)
|
// 使用施法者的暴击率属性(damageEvent.Attrs 快照)
|
||||||
const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]);
|
const isCrit = this.checkChance(damageEvent.Attrs[Attrs.CRITICAL]);
|
||||||
if (isCrit) attackerModel?.clearTalBuffByAttr(Attrs.CRITICAL);
|
if (isCrit) attackerModel?.useValueTalByAttr(Attrs.CRITICAL); // 清除施法者的暴击buff
|
||||||
// 计算伤害
|
// 计算伤害
|
||||||
let damage = this.dmgCount(damageEvent.Attrs,targetAttrs.Attrs,damageEvent.s_uuid);
|
let damage = this.dmgCount(damageEvent.Attrs,targetAttrs.Attrs,damageEvent.s_uuid);
|
||||||
if (isCrit) {
|
if (isCrit) {
|
||||||
@@ -179,7 +179,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd
|
|||||||
// 使用施法者的击退概率属性(damageEvent.Attrs 快照)
|
// 使用施法者的击退概率属性(damageEvent.Attrs 快照)
|
||||||
// 击退成功后需要清理施法者的相关天赋buff
|
// 击退成功后需要清理施法者的相关天赋buff
|
||||||
const isBack = this.checkChance(damageEvent.Attrs[Attrs.BACK_CHANCE] || 0);
|
const isBack = this.checkChance(damageEvent.Attrs[Attrs.BACK_CHANCE] || 0);
|
||||||
if (isBack) attackerModel?.clearTalBuffByAttr(Attrs.BACK_CHANCE);
|
if (isBack) attackerModel?.useValueTalByAttr(Attrs.BACK_CHANCE);
|
||||||
|
|
||||||
|
|
||||||
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
// ✅ 触发视图层表现(伤害数字、受击动画、后退)
|
||||||
|
|||||||
@@ -35,7 +35,9 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
shield: number = 0; // 当前护盾
|
shield: number = 0; // 当前护盾
|
||||||
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
Attrs: any = []; // 最终属性数组(经过Buff计算后)
|
||||||
NeAttrs: any = []; // 负面状态数组
|
NeAttrs: any = []; // 负面状态数组
|
||||||
Talents: Record<number, talTrigger> = {};
|
//计数型天赋buff
|
||||||
|
Talents: Record<number, talTrigger> = {};
|
||||||
|
//数值型天赋buff
|
||||||
BUFFS_TAL: Record<number, {count:number,BType:BType,attrIndex:number,value: number}> = {};
|
BUFFS_TAL: Record<number, {count:number,BType:BType,attrIndex:number,value: number}> = {};
|
||||||
|
|
||||||
// ==================== 技能距离缓存 ====================
|
// ==================== 技能距离缓存 ====================
|
||||||
@@ -407,7 +409,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
addTalBuff(t_uuid: number, attrIndex?: number, bType?: BType, value: number = 0) {
|
addValueTal(t_uuid: number, attrIndex?: number, bType?: BType, value: number = 0) {
|
||||||
if (attrIndex === undefined || bType === undefined) return;
|
if (attrIndex === undefined || bType === undefined) return;
|
||||||
const buff = this.BUFFS_TAL[t_uuid];
|
const buff = this.BUFFS_TAL[t_uuid];
|
||||||
if (!buff) {
|
if (!buff) {
|
||||||
@@ -418,14 +420,27 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
this.recalculateSingleAttr(attrIndex);
|
this.recalculateSingleAttr(attrIndex);
|
||||||
}
|
}
|
||||||
clearTalBuff(t_uuid: number) {
|
addCountTal(eff: number, value: number) {
|
||||||
|
const t = this.Talents[eff] || { value: 0, count: 0 };
|
||||||
|
t.value = value;
|
||||||
|
t.count += 1;
|
||||||
|
this.Talents[eff] = t;
|
||||||
|
}
|
||||||
|
|
||||||
|
useCountTal(eff: number): boolean {
|
||||||
|
const t = this.Talents[eff];
|
||||||
|
if (!t || t.count <= 0) return false;
|
||||||
|
t.count -= 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
useValueTalByUuid(t_uuid: number) {
|
||||||
const buff = this.BUFFS_TAL[t_uuid];
|
const buff = this.BUFFS_TAL[t_uuid];
|
||||||
if (!buff) return;
|
if (!buff) return;
|
||||||
const attrIndex = buff.attrIndex;
|
const attrIndex = buff.attrIndex;
|
||||||
delete this.BUFFS_TAL[t_uuid];
|
delete this.BUFFS_TAL[t_uuid];
|
||||||
this.recalculateSingleAttr(attrIndex);
|
this.recalculateSingleAttr(attrIndex);
|
||||||
}
|
}
|
||||||
clearTalBuffByAttr(attrIndex: number) {
|
useValueTalByAttr(attrIndex: number) {
|
||||||
let changed = false;
|
let changed = false;
|
||||||
for (const key in this.BUFFS_TAL) {
|
for (const key in this.BUFFS_TAL) {
|
||||||
const b = this.BUFFS_TAL[Number(key)];
|
const b = this.BUFFS_TAL[Number(key)];
|
||||||
@@ -436,20 +451,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
if (changed) this.recalculateSingleAttr(attrIndex);
|
if (changed) this.recalculateSingleAttr(attrIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
addTalent(eff: number, value: number) {
|
|
||||||
const t = this.Talents[eff] || { value: 0, count: 0 };
|
|
||||||
t.value = value;
|
|
||||||
t.count += 1;
|
|
||||||
this.Talents[eff] = t;
|
|
||||||
}
|
|
||||||
consumeTalent(eff: number): boolean {
|
|
||||||
const t = this.Talents[eff];
|
|
||||||
if (!t || t.count <= 0) return false;
|
|
||||||
t.count -= 1;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
// 重置为初始状态
|
// 重置为初始状态
|
||||||
this.hero_uuid = 1001;
|
this.hero_uuid = 1001;
|
||||||
|
|||||||
@@ -163,13 +163,13 @@ export class SACastSystem extends ecs.ComblockSystem implements ecs.ISystemUpdat
|
|||||||
}, delay);
|
}, delay);
|
||||||
|
|
||||||
//风怒wfuny 只针对 普通攻击起效
|
//风怒wfuny 只针对 普通攻击起效
|
||||||
if (hset === HSSet.atk && heroAttrs.consumeTalent(TalEffet.WFUNY)){
|
if (hset === HSSet.atk && heroAttrs.useCountTal(TalEffet.WFUNY)){
|
||||||
heroView.playSkillEffect(s_uuid);
|
heroView.playSkillEffect(s_uuid);
|
||||||
//需要再添加 风怒动画
|
//需要再添加 风怒动画
|
||||||
this.createSkill(s_uuid, heroView,targets);
|
this.createSkill(s_uuid, heroView,targets);
|
||||||
}
|
}
|
||||||
// 双技能 只针对 技能起效
|
// 双技能 只针对 技能起效
|
||||||
if(hset === HSSet.skill && heroAttrs.consumeTalent(TalEffet.D_SKILL)){
|
if(hset === HSSet.skill && heroAttrs.useCountTal(TalEffet.D_SKILL)){
|
||||||
targets = this.sTargets(heroView, s_uuid);
|
targets = this.sTargets(heroView, s_uuid);
|
||||||
if (targets.length === 0) {
|
if (targets.length === 0) {
|
||||||
console.warn("[SACastSystem] 没有找到有效目标");
|
console.warn("[SACastSystem] 没有找到有效目标");
|
||||||
|
|||||||
@@ -189,6 +189,10 @@ export class TalComp extends ecs.Comp {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//执行天赋触发效果
|
//执行天赋触发效果
|
||||||
|
// 功能:
|
||||||
|
// - 根据天赋类型执行相应的效果
|
||||||
|
// - 支持计数型和数值型天赋
|
||||||
|
// --heroAttrs.addTalent 是计数型天赋buff heroAttrs.addTalBuff 是数值型天赋buff
|
||||||
doTriggerTal(uuid: number) {
|
doTriggerTal(uuid: number) {
|
||||||
// 检查天赋是否存在
|
// 检查天赋是否存在
|
||||||
if (!this.Tals[uuid]) {
|
if (!this.Tals[uuid]) {
|
||||||
@@ -199,22 +203,22 @@ export class TalComp extends ecs.Comp {
|
|||||||
const heroAttrs=this.ent.get(HeroAttrsComp);
|
const heroAttrs=this.ent.get(HeroAttrsComp);
|
||||||
switch(talent.effet){
|
switch(talent.effet){
|
||||||
case TalEffet.WFUNY:
|
case TalEffet.WFUNY:
|
||||||
heroAttrs.addTalent(TalEffet.WFUNY, talent.value + talent.value_add);
|
heroAttrs.addCountTal(TalEffet.WFUNY, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
case TalEffet.D_SKILL:
|
case TalEffet.D_SKILL:
|
||||||
heroAttrs.addTalent(TalEffet.D_SKILL, talent.value + talent.value_add);
|
heroAttrs.addCountTal(TalEffet.D_SKILL, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
case TalEffet.C_ATK:
|
case TalEffet.C_ATK:
|
||||||
heroAttrs.addTalent(TalEffet.C_ATK, talent.value + talent.value_add);
|
heroAttrs.addCountTal(TalEffet.C_ATK, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
case TalEffet.C_SKILL:
|
case TalEffet.C_SKILL:
|
||||||
heroAttrs.addTalent(TalEffet.C_SKILL, talent.value + talent.value_add);
|
heroAttrs.addCountTal(TalEffet.C_SKILL, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
case TalEffet.C_MSKILL:
|
case TalEffet.C_MSKILL:
|
||||||
heroAttrs.addTalent(TalEffet.C_MSKILL, talent.value + talent.value_add);
|
heroAttrs.addCountTal(TalEffet.C_MSKILL, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
case TalEffet.BUFF:
|
case TalEffet.BUFF:
|
||||||
heroAttrs.addTalBuff(talent.uuid, talent.attrs, talent.vType, talent.value + talent.value_add);
|
heroAttrs.addValueTal(talent.uuid, talent.attrs, talent.vType, talent.value + talent.value_add);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -201,10 +201,10 @@ console.log("道具1001数量:", itemInfo.result.data.count);
|
|||||||
const talents = await WxCloudApi.getTalents();
|
const talents = await WxCloudApi.getTalents();
|
||||||
|
|
||||||
// 添加天赋点
|
// 添加天赋点
|
||||||
const result = await WxCloudApi.addTalent(1001, 1);
|
const result = await WxCloudApi.addCountTal(1001, 1);
|
||||||
|
|
||||||
// 消耗天赋点
|
// 消耗天赋点
|
||||||
const result = await WxCloudApi.consumeTalent(1001, 1);
|
const result = await WxCloudApi.useCountTal(1001, 1);
|
||||||
```
|
```
|
||||||
|
|
||||||
### 装备操作
|
### 装备操作
|
||||||
|
|||||||
Reference in New Issue
Block a user