From a08cca9cc330605f21e09b923b00b2647c0802ef Mon Sep 17 00:00:00 2001 From: walkpan Date: Thu, 19 Mar 2026 19:08:50 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=86=B0=E5=86=BB?= =?UTF-8?q?=E6=95=88=E6=9E=9C=E5=B9=B6=E7=A7=BB=E9=99=A4=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 GameSet 中添加冰冻时间常量 FROST_TIME - 在 HeroAttrsComp 中新增 toFrost 方法用于处理冰冻状态 - 在 HeroAtkSystem 中增加冰冻判定,命中时触发冰冻效果并显示冰冻特效 - 简化 HeroViewComp 中的冰冻特效方法,移除眩晕特效方法 - 删除调试用的 HSkillComp 组件及其 meta 文件 - 调整 HeroBuffSystem 的计时器间隔,使冰冻状态更平滑地递减 --- assets/script/game/common/config/GameSet.ts | 5 +- assets/script/game/hero/HeroAtkSystem.ts | 14 +- assets/script/game/hero/HeroAttrsComp.ts | 16 +- assets/script/game/hero/HeroViewComp.ts | 13 +- assets/script/game/map/HSkillComp.ts | 193 -------------------- assets/script/game/map/HSkillComp.ts.meta | 1 - assets/script/game/skill/Skill.ts | 1 - 7 files changed, 19 insertions(+), 224 deletions(-) delete mode 100644 assets/script/game/map/HSkillComp.ts delete mode 100644 assets/script/game/map/HSkillComp.ts.meta diff --git a/assets/script/game/common/config/GameSet.ts b/assets/script/game/common/config/GameSet.ts index 837a98e9..b8558446 100644 --- a/assets/script/game/common/config/GameSet.ts +++ b/assets/script/game/common/config/GameSet.ts @@ -18,8 +18,7 @@ export enum BoxSet { LETF_END = -420, RIGHT_END = 420, //游戏地平线 - GAME_LINE = -90 - + GAME_LINE = -90, //攻击距离 } @@ -88,6 +87,8 @@ export enum FightSet { BACK_RANG=30,//后退范围 FiIGHT_TIME=60*10,//战斗时间 BACK_CHANCE=40,//击退概率 + FROST_TIME=1,//冰冻时间 + } export enum IndexSet { diff --git a/assets/script/game/hero/HeroAtkSystem.ts b/assets/script/game/hero/HeroAtkSystem.ts index d1767ed5..90bcdd38 100644 --- a/assets/script/game/hero/HeroAtkSystem.ts +++ b/assets/script/game/hero/HeroAtkSystem.ts @@ -117,6 +117,7 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd // 暴击判定 // 使用施法者的暴击率属性(damageEvent.Attrs 快照),- 被攻击者的暴击抗性属 const isCrit = this.checkChance(damageEvent.Attrs[Attrs.critical]); + // 计算基础伤害 let damage = this.dmgCount(damageEvent,TAttrsComp); @@ -147,17 +148,16 @@ export class HeroAtkSystem extends ecs.ComblockSystem implements ecs.ISystemUpd mLogger.log(this.debugMode, 'HeroAtkSystem', ` 英雄${TAttrsComp.hero_name} (uuid: ${TAttrsComp.hero_uuid}) 受到 eid:${casterEid} 的 伤害 ${damage},${isCrit?"暴击":"普通"}攻击,技能ID ${damageEvent.s_uuid}`); - // 击退判定 - // 使用施法者的击退概率属性(damageEvent.Attrs 快照) - 被攻击者的控制抗性 - // 击退成功后需要清理施法者的相关天赋buff + // 击退和冰冻判定 const isBack = this.checkChance((damageEvent.Attrs[Attrs.back_chance] || 0)); - - - // ✅ 触发视图层表现(伤害数字、受击动画、后退) + const isFrost = this.checkChance(damageEvent.Attrs[Attrs.freeze_chance]); + // ✅ 触发视图层表现(伤害数字、受击动画、后退,冰冻) if (targetView) { targetView.do_atked(damage, isCrit, damageEvent.s_uuid, isBack); targetView.playEnd(skillConf.endAnm); - } + if(isFrost) TAttrsComp.toFrost(); + targetView.in_iced(TAttrsComp.frost_end_time); + } // 检查死亡 diff --git a/assets/script/game/hero/HeroAttrsComp.ts b/assets/script/game/hero/HeroAttrsComp.ts index 53517e6b..cc7dbd01 100644 --- a/assets/script/game/hero/HeroAttrsComp.ts +++ b/assets/script/game/hero/HeroAttrsComp.ts @@ -4,6 +4,7 @@ import { BuffConf } from "../common/config/SkillSet"; import { HeroDisVal, HType } from "../common/config/heroSet"; import { mLogger } from "../common/Logger"; import { Timer } from "db://oops-framework/core/common/timer/Timer"; +import { FightSet } from "../common/config/GameSet"; @ecs.register('HeroAttrs') export class HeroAttrsComp extends ecs.Comp { public debugMode: boolean = false; @@ -133,14 +134,11 @@ export class HeroAttrsComp extends ecs.Comp { mLogger.log(this.debugMode, 'HeroAttrs', `添加属性: ${buffConf.name}, 属性:${buffConf.buff}, 值:${buffConf.value}`); } } - - /** - * 把配置值统一转换为“可直接写入容器和结算”的数值 - * - RATIO 会在写入前转换为 VALUE - * - BOOLEAN 保持原类型 - */ + + toFrost(time: number=1) { + this.frost_end_time += FightSet.FROST_TIME*time; + } - /** * 通用属性修改应用 * @param attr 属性名 @@ -291,7 +289,7 @@ export class HeroAttrsComp extends ecs.Comp { @ecs.register('HeroBuffSystem') export class HeroBuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpdate { - private timer =new Timer(0.2) + private timer =new Timer(0.1) filter(): ecs.IMatcher { return ecs.allOf(HeroAttrsComp); } @@ -300,7 +298,7 @@ export class HeroBuffSystem extends ecs.ComblockSystem implements ecs.ISystemUpd if(this.timer.update(this.dt)){ const attrsComp = e.get(HeroAttrsComp); if(attrsComp.frost_end_time > 0){ - attrsComp.frost_end_time -= 0.2; + attrsComp.frost_end_time -= 0.1; if(attrsComp.frost_end_time <= 0){ attrsComp.frost_end_time = 0; } diff --git a/assets/script/game/hero/HeroViewComp.ts b/assets/script/game/hero/HeroViewComp.ts index fa457c41..b88dcd3f 100644 --- a/assets/script/game/hero/HeroViewComp.ts +++ b/assets/script/game/hero/HeroViewComp.ts @@ -261,17 +261,8 @@ export class HeroViewComp extends CCComp { } /** 冰冻特效 */ - private in_iced(t: number = 1, ap: number = 0) { - const node = this.spawnTimedFx("game/skill/buff/iced", this.node, t); - - } - - /** 眩晕特效 */ - private in_yun(t: number = 1, ap: number = 0) { - const node = this.spawnTimedFx("game/skill/buff/buff_yun", this.node, t); - if (!node) return; - let height = this.node.getComponent(UITransform).height; - node.setPosition(v3(0, height)); + in_iced(t: number = 1) { + this.spawnTimedFx("game/skill/buff/iced", this.node, t); } /** 技能提示 */ diff --git a/assets/script/game/map/HSkillComp.ts b/assets/script/game/map/HSkillComp.ts deleted file mode 100644 index a9f9c8f0..00000000 --- a/assets/script/game/map/HSkillComp.ts +++ /dev/null @@ -1,193 +0,0 @@ -import { _decorator, instantiate, Label, Node, Prefab, UITransform, v3, Vec3 } from 'cc'; -import { CCComp } from 'db://oops-framework/module/common/CCComp'; -import { ecs } from 'db://oops-framework/libs/ecs/ECS'; -import { SkillSet } from '../common/config/SkillSet'; -import { BoxSet, FacSet } from '../common/config/GameSet'; -import { smc } from '../common/SingletonModuleComp'; -import { Skill } from '../skill/Skill'; -import { mLogger } from '../common/Logger'; -const { ccclass, property } = _decorator; - -@ccclass('HSkillComp') -@ecs.register('HSkillComp', false) -export class HSkillComp extends CCComp { - debugMode: boolean = false; - private readonly panelName: string = 'skill_debug_panel'; - private readonly panelWidth: number = 680; - private readonly panelHeight: number = 1180; - private readonly colCount: number = 4; - private readonly cellWidth: number = 160; - private readonly cellHeight: number = 68; - private readonly startX: number = -240; - private readonly startY: number = 560; - @property(Prefab) - btnPrefab: Prefab | null = null; - - private panelNode: Node | null = null; - private buttonNodes: Node[] = []; - private mockCasterNode: Node | null = null; - private mockCasterView: any = null; - private currentSkill: Skill | null = null; - - protected onLoad(): void { - this.ensurePanel(); - } - - start() { - this.renderSkillButtons(); - } - - start_test() { - this.node.active = true; - const home = this.node.parent?.getChildByName('mission_home'); - if (home) { - home.active = false; - } - this.renderSkillButtons(); - } - - end_test() { - const home = this.node.parent?.getChildByName('mission_home'); - if (home) { - home.active = true; - } - this.node.active = false; - } - - update_data(uuid: number) { - this.renderSkillButtons(); - } - - private ensurePanel() { - let panel = this.node.getChildByName(this.panelName); - if (!panel) { - panel = new Node(this.panelName); - panel.parent = this.node; - const transform = panel.addComponent(UITransform); - transform.setContentSize(this.panelWidth, this.panelHeight); - panel.setPosition(0, 640, 0); - } - this.panelNode = panel; - } - - private renderSkillButtons() { - this.ensurePanel(); - const prefab = this.getBtnPrefab(); - if (!prefab || !this.panelNode || !this.panelNode.isValid) { - return; - } - this.clearButtons(); - const skillIds = Object.keys(SkillSet).map(Number).sort((a, b) => a - b); - skillIds.forEach((skillId, index) => { - const btnNode = instantiate(prefab); - btnNode.parent = this.panelNode; - const row = Math.floor(index / this.colCount); - const col = index % this.colCount; - btnNode.setPosition( - this.startX + col * this.cellWidth, - this.startY - row * this.cellHeight, - 0 - ); - const label = btnNode.getChildByName('Label')?.getComponent(Label); - if (label) { - const conf = SkillSet[skillId]; - label.string = `${skillId} ${conf?.name ?? ''}`; - } - btnNode.on(Node.EventType.TOUCH_END, () => this.playDebugSkill(skillId), this); - this.buttonNodes.push(btnNode); - }); - } - - private clearButtons() { - this.buttonNodes.forEach(node => { - if (!node || !node.isValid) { - return; - } - node.off(Node.EventType.TOUCH_END); - node.destroy(); - }); - this.buttonNodes.length = 0; - } - - private getBtnPrefab(): Prefab | null { - if (this.btnPrefab) { - return this.btnPrefab; - } - mLogger.error(this.debugMode, 'HSkillComp', '[HSkillComp] 未绑定 Btn 预制体,请在编辑器中设置 btnPrefab'); - return null; - } - - private getSkillParent(): Node { - const layer = smc.map?.MapView?.scene?.entityLayer?.node?.getChildByName('SKILL'); - if (layer && layer.isValid) { - return layer; - } - return this.node; - } - - private ensureMockCaster(parent: Node, startPos: Vec3): any { - if (!this.mockCasterNode || !this.mockCasterNode.isValid) { - this.mockCasterNode = new Node('debug_caster'); - this.mockCasterNode.parent = parent; - this.mockCasterNode.setScale(v3(1, 1, 1)); - this.mockCasterNode.active = false; - } else if (this.mockCasterNode.parent !== parent) { - this.mockCasterNode.parent = parent; - } - this.mockCasterNode.setPosition(startPos); - const mockAttrs = { - hero_name: '技能调试器', - ap: 100, - critical: 0, - critical_dmg: 50, - freeze_chance: 0, - back_chance: 0, - puncture: 0, - wfuny: 0, - fac: FacSet.HERO - }; - const mockEntity = { - eid: -10086, - get: () => mockAttrs - }; - this.mockCasterView = { - node: this.mockCasterNode, - box_group: BoxSet.HERO, - ent: mockEntity - }; - return this.mockCasterView; - } - - private playDebugSkill(skillId: number) { - const conf = SkillSet[skillId]; - if (!conf) { - return; - } - this.destroyCurrentSkill(); - const parent = this.getSkillParent(); - const startPos = v3(-260, -40, 0); - const targetPos = v3(260, -40, 0); - const caster = this.ensureMockCaster(parent, startPos); - const skill = ecs.getEntity(Skill); - skill.load(startPos.clone(), parent, skillId, targetPos, caster, 0); - this.currentSkill = skill; - } - - private destroyCurrentSkill() { - if (!this.currentSkill) { - return; - } - this.currentSkill.destroy(); - this.currentSkill = null; - } - - reset() { - this.destroyCurrentSkill(); - this.clearButtons(); - if (this.mockCasterNode && this.mockCasterNode.isValid) { - this.mockCasterNode.destroy(); - this.mockCasterNode = null; - } - this.node.destroy(); - } -} diff --git a/assets/script/game/map/HSkillComp.ts.meta b/assets/script/game/map/HSkillComp.ts.meta deleted file mode 100644 index dac80f4c..00000000 --- a/assets/script/game/map/HSkillComp.ts.meta +++ /dev/null @@ -1 +0,0 @@ -{"ver":"4.0.24","importer":"typescript","imported":true,"uuid":"34b93128-7505-4579-91c9-a93e9f1040ad","files":[],"subMetas":{},"userData":{}} diff --git a/assets/script/game/skill/Skill.ts b/assets/script/game/skill/Skill.ts index f7cd3480..c9a7a1ca 100644 --- a/assets/script/game/skill/Skill.ts +++ b/assets/script/game/skill/Skill.ts @@ -214,7 +214,6 @@ export class Skill extends ecs.Entity { sDataCom.Attrs[Attrs.critical] = cAttrsComp.critical + addCrt; sDataCom.Attrs[Attrs.freeze_chance] = cAttrsComp.freeze_chance + addFrz; sDataCom.Attrs[Attrs.back_chance] = cAttrsComp.back_chance + addBck; - sDataCom.s_uuid=s_uuid sDataCom.fac=cAttrsComp.fac sDataCom.ext_dmg=ext_dmg