diff --git a/assets/script/Design.md b/assets/script/Design.md index 555301c9..a39ca4b8 100644 --- a/assets/script/Design.md +++ b/assets/script/Design.md @@ -21,7 +21,7 @@ 击退: 普通攻击3次后, 获得5%的击退率(可叠加,触发清零) :击退收到伤害的目标, cd减少5点, 会心: 普通攻击1次后, 获得5%的暴击率(可叠加,触发清零) -熟练: 普通攻击3次后, 获得5%的机率(触发特效前效果可以叠加)触发2次一般技能 +熟练: 普通攻击10次后, 获得下2次一般技能触发2次 反击: 被攻击3次后, 给于目标50%的伤害 护盾: 被攻击3次后,获得20%生命值护盾 diff --git a/assets/script/game/common/config/TalSet.ts b/assets/script/game/common/config/TalSet.ts index bd4a86eb..58afa4ea 100644 --- a/assets/script/game/common/config/TalSet.ts +++ b/assets/script/game/common/config/TalSet.ts @@ -4,42 +4,32 @@ import { Attrs } from "./HeroAttrs"; /** * 天赋类型枚举,也是触发条件 */ -export enum TalType { - LUP_1 = 1, // 等级升级1级触发 - LUP_5 = 2, // 等级升级5级触发 - LUP_10 = 3, // 等级升级10级触发 - ATK_1 = 4, //普通攻击1次触发 - ATK_3 = 5, // 普通攻击3次触发 - ATK_5 = 6, // 普通攻击5次触发 - DMG_1 = 7, // 受伤1次触发 - DMG_3 = 8, // 受伤3次触发 - DMG_5 = 9, // 受伤5次触发 - SKILL_1 = 10, // 技能1次触发 - SKILL_3 = 11, // 技能3次触发 - SKILL_5 = 12, // 技能5次触发 - LHP_50 = 13, // 失去生命值50%触发 - LHP_30 = 14, // 失去生命值30%触发 - AHP_100 = 15, // 获得生命值100%触发 - AHP_200 = 16, // 获得生命值200%触发 - - INIT = 17, // 初始触发,如:多1个技能 - DEAD = 18 // 基于死亡触发 +export enum TriType { + LUP = 1, // 等级升触发 + ATK = 2, //普通攻击触发 + DMG = 3, // 受伤触发 + SKILL = 4, // 技能触发 + HPL = 5, // 失去生命值触发 + HPA = 6, // 获得生命值触发 + INIT = 7, // 初始触发,如:多1个技能 + DEAD = 8 // 基于死亡触发 } -/** - * 触发效果 - */ -export enum TalETag { - Wfuny = 1, // 风怒 -} + export enum TalEffet { DMG=1, // 伤害 - ATTR=2, // 属性hp,mp数值,持久添加 - BUFF = 3, // 暴击率,闪避率等,可叠加的触发后清零 - STATS=3, // 状态 - N_ATK = 4, // 下n次普通攻击 需要特殊处理 - N_SKILL=5, // 下n次技能攻击 需要特殊处理 + HP=2, // 回血 百分比 + MP=3, //回蓝 百分比 + BUFF = 4, // 暴击率,闪避率等,可叠加的触发后清零 + STATS=5, // 状态 + N_ATK = 6, // 下n次普通攻击暴击 + N_SKILL=7, // 下n次技能攻击暴击 + WFUNY=8, // 风怒 + SPLASH=9, // 溅射 + D_SKILL=10, //两次技能 + SHIELD=11, // 护盾 + LDMG=12, // 减伤 } export enum TalTarget { @@ -48,6 +38,7 @@ export enum TalTarget { } export enum TalAttrs { + NON=0, FREEZE_CHANCE=Attrs.FREEZE_CHANCE, // 冰冻概率 STUN_CHANCE=Attrs.STUN_CHANCE, // 冰冻概率 BACK_CHANCE=Attrs.BACK_CHANCE, // 击退概率 @@ -62,11 +53,11 @@ export enum TalAttrs { export interface ItalConf { uuid: number; // 天赋ID name: string; // 天赋名称 - type: TalType; + triType: TriType; target: TalTarget; effet: TalEffet; value: number; // 触发的效果值(如增加10%攻击力, 触发的技能uuid,增加1个技能uuid) - attrs:TalAttrs //触发的 + attrs?:TalAttrs //触发的attrs效果的对应attrs Trigger:number //触发值 desc: string; // 天赋描述(说明触发条件和效果) } @@ -88,7 +79,44 @@ export interface ItalConf { * 4. 技能触发类:当特定条件满足时自动触发指定技能 */ export const talConf: Record = { - 7001:{uuid:7001,name:"风怒",type:TalType.ATK_3,target:TalTarget.ENEMY,effet:TalEffet.DMG,value:150,Trigger:3,desc:"普通攻击3次后, 给于目标150%的伤害"}, + /*** 普通攻击触发 ***/ + 7001:{uuid:7001,name:"风怒",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.WFUNY,value:150,attrs:TalAttrs.NON, + desc:"普通攻击3次后, 给于目标150%的伤害"}, + 7002:{uuid:7002,name:"溅射",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.SPLASH,value:50,attrs:TalAttrs.NON, + desc:"普通攻击3次后, 会对目标100码内的敌人造成30%伤害"}, + 7003:{uuid:7003,name:"回血",triType:TriType.ATK,Trigger:3,target:TalTarget.SELF,effet:TalEffet.HP,value:1,attrs:TalAttrs.NON, + desc:"普通攻击3次后, 会回复10%的生命值"}, + 7004:{uuid:7004,name:"回蓝",triType:TriType.ATK,Trigger:3,target:TalTarget.SELF,effet:TalEffet.MP,value:1,attrs:TalAttrs.NON, + desc:"普通攻击3次后, 会回复10%的蓝值"}, + 7005:{uuid:7005,name:"冰冻",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.FREEZE_CHANCE, + desc:"普通攻击3次后, 获得5%的冻结率"}, + 7006:{uuid:7006,name:"沉默",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.SILENCE_CHANCE, + desc:"普通攻击3次后, 获得5%的沉默率"}, + 7007:{uuid:7007,name:"击退",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.BACK_CHANCE, + desc:"普通攻击3次后, 获得5%的击退率"}, + 7008:{uuid:7008,name:"会心",triType:TriType.ATK,Trigger:3,target:TalTarget.SELF,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.CRITICAL, + desc:"普通攻击3次后, 获得5%的暴击率"}, + 7009:{uuid:7009,name:"眩晕",triType:TriType.ATK,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.BUFF,value:5,attrs:TalAttrs.STUN_CHANCE, + desc:"普通攻击3次后, 获得5%的眩晕率"}, + 7010:{uuid:7010,name:"熟练",triType:TriType.ATK,Trigger:10,target:TalTarget.SELF,effet:TalEffet.D_SKILL,value:2,attrs:TalAttrs.NON, + desc:"普通攻击10次后, 获得下2次一般技能触发2次"}, + + /*** 受伤触发 ***/ + 7101:{uuid:7101,name:"反击",triType:TriType.DMG,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.DMG,value:50,attrs:TalAttrs.NON, + desc:"被攻击3次后, 给于目标50%的伤害"}, + 7102:{uuid:7102,name:"护盾",triType:TriType.DMG,Trigger:3,target:TalTarget.SELF,effet:TalEffet.SHIELD,value:20,attrs:TalAttrs.NON, + desc:"被攻击3次后, 获得20%的生命值护盾"}, + 7103:{uuid:7103,name:"减伤",triType:TriType.DMG,Trigger:3,target:TalTarget.ENEMY,effet:TalEffet.LDMG,value:50,attrs:TalAttrs.NON, + desc:"被攻击3次后, 下1次伤害减50%"}, + + + /*** 失去血量触发 ***/ + 7201:{uuid:7201,name:"背水",triType:TriType.HPL,Trigger:50,target:TalTarget.SELF,effet:TalEffet.N_ATK,value:10,attrs:TalAttrs.NON, + desc:"每失去50%生命值,获得下10次普通攻击暴击"}, + + /*** 升级触发 ***/ + 7301:{uuid:7301,name:"勤勉",triType:TriType.LUP,Trigger:1,target:TalTarget.SELF,effet:TalEffet.N_ATK,value:10,attrs:TalAttrs.NON, + desc:"每升1级,获得下5次技能暴击"}, }; diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index d6c0da25..d673e62b 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -3,6 +3,7 @@ import { Attrs, AttrsType, BType, NeAttrs } from "../common/config/HeroAttrs"; import { BuffConf } from "../common/config/SkillSet"; import { HeroInfo, AttrSet } from "../common/config/heroSet"; import { HeroSkillsComp } from "./HeroSkills"; +import { talConf, TalAttrs } from "../common/config/TalSet"; @ecs.register('HeroAttrs') @@ -42,7 +43,9 @@ export class HeroAttrsComp extends ecs.Comp { /** 临时型buff数组 - 按时间自动过期 */ BUFFS_TEMP: Record> = {}; - + /** 天赋buff数组 - 触发过期,数量可叠加 */ + BUFFS_TAL: Record> = {}; + // ==================== 标记状态 ==================== is_dead: boolean = false; is_count_dead: boolean = false; @@ -70,6 +73,7 @@ export class HeroAttrsComp extends ecs.Comp { // 清空现有 buff/debuff this.BUFFS = {}; this.BUFFS_TEMP = {}; + this.BUFFS_TAL = {}; // 获取英雄配置 const heroInfo = HeroInfo[this.hero_uuid]; @@ -177,6 +181,14 @@ export class HeroAttrsComp extends ecs.Comp { } } } + // 遍历天赋buff数组(数值型叠加 value*count) + if (this.BUFFS_TAL[attrIndex] && this.BUFFS_TAL[attrIndex].length > 0) { + for (const buff of this.BUFFS_TAL[attrIndex]) { + if (buff.BType === BType.VALUE) { + totalValue += buff.value * buff.count; + } + } + } // 3. 收集所有百分比型 buff/debuff let totalRatio = 0; @@ -197,6 +209,14 @@ export class HeroAttrsComp extends ecs.Comp { } } } + // 遍历天赋buff数组(百分比型叠加 value*count) + if (this.BUFFS_TAL[attrIndex] && this.BUFFS_TAL[attrIndex].length > 0) { + for (const buff of this.BUFFS_TAL[attrIndex]) { + if (buff.BType === BType.RATIO) { + totalRatio += buff.value * buff.count; + } + } + } // 4. 根据属性类型计算最终值 const attrType = AttrsType[attrIndex]; @@ -408,6 +428,7 @@ export class HeroAttrsComp extends ecs.Comp { this.NeAttrs = []; this.BUFFS = {}; this.BUFFS_TEMP = {}; + this.BUFFS_TAL = {}; // 重置技能距离缓存 this.maxSkillDistance = 0; this.minSkillDistance = 0; @@ -423,5 +444,45 @@ export class HeroAttrsComp extends ecs.Comp { this.atk_count = 0; this.atked_count = 0; } + private getTalAttr(tal: number) { + const conf = talConf[tal]; + if (!conf) return null; + const attrIndex = conf.attrs ?? TalAttrs.NON; + if (attrIndex === TalAttrs.NON) return null; + const bType = AttrsType[attrIndex as unknown as number]; + const value = conf.value; + return { attrIndex: attrIndex as unknown as number, bType, value }; + } + addTalBuff(tal: number, count: number = 1) { + const info = this.getTalAttr(tal); + if (!info) return; + const { attrIndex, bType, value } = info; + if (!this.BUFFS_TAL[attrIndex]) this.BUFFS_TAL[attrIndex] = []; + const list = this.BUFFS_TAL[attrIndex]; + const exist = list.find(i => i.tal === tal && i.BType === bType); + if (exist) { + exist.count += count; + } else { + list.push({ tal, value, BType: bType, count }); + } + this.recalculateSingleAttr(attrIndex); + } + clearTalBuff(tal: number) { + const affected = new Set(); + for (const key in this.BUFFS_TAL) { + const idx = parseInt(key); + const list = this.BUFFS_TAL[idx]; + if (!list || list.length === 0) continue; + const newList = list.filter(i => i.tal !== tal); + if (newList.length !== list.length) { + this.BUFFS_TAL[idx] = newList; + affected.add(idx); + if (newList.length === 0) delete this.BUFFS_TAL[idx]; + } + } + affected.forEach(i => this.recalculateSingleAttr(i)); + } + + } diff --git a/assets/script/game/hero/TalComp.ts b/assets/script/game/hero/TalComp.ts index ed3160f0..2002c746 100644 --- a/assets/script/game/hero/TalComp.ts +++ b/assets/script/game/hero/TalComp.ts @@ -1,20 +1,23 @@ -import { _decorator } from "cc"; import { ecs } from "../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS"; -import { CCComp } from "../../../../extensions/oops-plugin-framework/assets/module/common/CCComp"; import { BuffConf, SkillSet } from "../common/config/SkillSet"; +import { TalAttrs, TalEffet, TalTarget, TriType } from "../common/config/TalSet"; import { HeroInfo } from "../common/config/heroSet"; import { HeroViewComp } from "./HeroViewComp"; -const { ccclass } = _decorator; - +export interface TalSlot { + uuid: number; // 天赋ID + name: string; // 天赋名称 + value: number; // 触发的效果价值 + Trigger:boolean //触发值减值 + C_Trigger:number //当前值 +} /** * 天赋系统组件类 * 继承自 CCComp,作为 ECS 架构中的组件存在 * 负责管理英雄的天赋系统,包括天赋获取、触发、效果应用等 */ -@ccclass('TalComp') @ecs.register('TalComp', false) export class TalComp extends ecs.Comp { /** 英雄视图组件引用,运行时获取避免循环引用 */ @@ -22,17 +25,15 @@ export class TalComp extends ecs.Comp { private skillCon:any=null; /** 英雄唯一标识符,用于从配置中获取英雄信息 */ private heroUuid: number = 0; - - - - start() { - - } - - - + /** 天赋数组 */ + Tals: Record = {}; + /** 天赋槽位数组,默认开启2个,最多4个 */ + TalSlots:number[]=[1,1,0,0] reset() { } + + + } \ No newline at end of file