From ab32b0e09d41456a3e0e39987ca7925b8ae464ce Mon Sep 17 00:00:00 2001 From: pan Date: Fri, 11 Sep 2026 15:39:57 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=99=AE=E9=80=9A=E5=85=B3=E5=88=B7?= =?UTF-8?q?=E6=80=AA):=20=E8=B0=83=E6=95=B4=E5=88=B7=E6=80=AA=E9=97=B4?= =?UTF-8?q?=E9=9A=94=E5=B9=B6=E6=96=B0=E5=A2=9E=E6=80=AA=E7=89=A9=E7=A0=B8?= =?UTF-8?q?=E5=9C=B0=E5=87=BB=E9=80=80=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 将普通关后续刷怪间隔从1秒改为2秒,同步更新注释与配置常量 2. 为普通关怪物添加从400码高度掉落入场的效果 3. 新增怪物落地震退逻辑,击退落点100码范围内的英雄 --- assets/script/game/common/config/StageSet.ts | 4 +-- assets/script/game/hero/Mon.ts | 36 ++++++++++++++++++++ assets/script/game/map/MissionMonComp.ts | 6 ++-- assets/script/game/map/RogueConfig.ts | 2 +- 4 files changed, 42 insertions(+), 6 deletions(-) diff --git a/assets/script/game/common/config/StageSet.ts b/assets/script/game/common/config/StageSet.ts index 449276c1..858ae08c 100644 --- a/assets/script/game/common/config/StageSet.ts +++ b/assets/script/game/common/config/StageSet.ts @@ -30,8 +30,8 @@ export const BOSS_MUL = 3.0; export const NORMAL_MON_COUNT = 9; /** 普通关开局立即刷出数量 */ export const NORMAL_FIRST_SPAWN = 3; -/** 普通关后续刷怪间隔(秒):前 3 只立即刷,后续每 1s 刷 1 只 */ -export const NORMAL_SPAWN_INTERVAL = 1; +/** 普通关后续刷怪间隔(秒):前 3 只立即刷,后续每 2s 刷 1 只 */ +export const NORMAL_SPAWN_INTERVAL = 2; /** 精英关精英数量 */ export const ELITE_COUNT = 3; /** Boss 关精英数量 */ diff --git a/assets/script/game/hero/Mon.ts b/assets/script/game/hero/Mon.ts index 44ccbbf7..c0ff9914 100644 --- a/assets/script/game/hero/Mon.ts +++ b/assets/script/game/hero/Mon.ts @@ -28,6 +28,10 @@ export class Monster extends ecs.Entity { static readonly MAX_POOL_SIZE: number = 12; /** 所有路径合计池容量上限 */ static readonly MAX_POOL_TOTAL: number = 60; + /** 落地震退范围(码):怪物砸地时击退落点范围内的英雄 */ + static readonly LANDING_SHOCK_RANGE: number = 100; + /** 英雄实体查询匹配器(惰性缓存,落地震退用) */ + private static heroMatcher: any = null; /** 计算当前所有对象池节点总量 */ private static totalPoolSize(): number { @@ -279,6 +283,11 @@ export class Monster extends ecs.Entity { collider.apply(); } + // 高处砸地:震退落点范围内的英雄 + if (dropDistance > 0) { + this.applyLandingShock(pos.x); + } + // 落地后触发 call 技能 SkillTriggerHelper.trigger(SkillTriggerType.Call, model, view); }; @@ -302,6 +311,33 @@ export class Monster extends ecs.Entity { } + /** + * 落地震退:怪物从高处砸地时,击退落点 LANDING_SHOCK_RANGE 范围内的英雄 + * Why: 复用 HeroAtkSystem 的击退通道(MoveComp.knockbackVelocity), + * 由 MoveSystem 统一指数衰减位移并受 HERO 左边界钳制,不会把英雄推出屏幕 + * @param posX 落点 X 坐标 + */ + private applyLandingShock(posX: number) { + if (!Monster.heroMatcher) { + Monster.heroMatcher = ecs.allOf(HeroAttrsComp); + } + // 击退初速度 = 距离 × 16(0.1s 时间常数衰减,总位移约等于距离),与 HeroAtkSystem 一致 + const knockbackSpeed = FightSet.BACK_RANG * 16; + ecs.query(Monster.heroMatcher).forEach(entity => { + const attrs = entity.get(HeroAttrsComp); + const view = entity.get(HeroViewComp); + if (!attrs || !view || attrs.is_dead || attrs.fac !== FacSet.HERO) return; + if (!view.node || !view.node.isValid) return; + // 仅按 X 轴距离判定(纵向战场无意义) + if (Math.abs(view.node.position.x - posX) > Monster.LANDING_SHOCK_RANGE) return; + const move = entity.get(MoveComp); + if (move) { + // 英雄被击退方向为负(向左后退),叠加而非覆盖,避免打断已有击退 + move.knockbackVelocity -= knockbackSpeed; + } + }); + } + /** 重置入口:复用 destroy 的释放流程 */ reset() { super.destroy(); diff --git a/assets/script/game/map/MissionMonComp.ts b/assets/script/game/map/MissionMonComp.ts index 032d2234..03af4d15 100644 --- a/assets/script/game/map/MissionMonComp.ts +++ b/assets/script/game/map/MissionMonComp.ts @@ -4,7 +4,7 @@ * * 职责: * 1. 按小节配置刷怪:监听 SectionStart 事件,从 StageSpawningEngine 获取怪物列表。 - * 2. 普通关:前 3 只立即刷,后续每 5s 刷 1 只(共 9 只)。 + * 2. 普通关:前 3 只立即刷,后续每 2s 刷 1 只(共 9 只),均从高处掉落入场。 * 3. 精英关:3 只精英同时刷出。 * 4. Boss 关:2 精英先刷,Boss 延迟 1s 刷出。 * 5. 维护小节刷怪计数,供 MissionComp 检测小节结束。 @@ -36,8 +36,8 @@ const { ccclass, property } = _decorator; export class MissionMonCompComp extends CCComp { // ======================== 常量 ======================== - /** 怪物出生掉落高度 */ - private static readonly MON_DROP_HEIGHT = 0; + /** 怪物出生掉落高度(码):从高处砸落入场,落地时震退范围内英雄 */ + private static readonly MON_DROP_HEIGHT = 400; /** * 怪物类型 → 编队优先级(与英雄 HRole 枚举值升序一致): diff --git a/assets/script/game/map/RogueConfig.ts b/assets/script/game/map/RogueConfig.ts index 8de2563c..0272005b 100644 --- a/assets/script/game/map/RogueConfig.ts +++ b/assets/script/game/map/RogueConfig.ts @@ -4,7 +4,7 @@ * * 游戏机制: * - 玩家线性推进 1 章 10 关 × 每关 10 小节,进度精确到小节并持久化。 - * - 普通关(1~4, 6~9):9 只小怪,前 3 只立即刷,后续每 1s 刷 1 只。 + * - 普通关(1~4, 6~9):9 只小怪,前 3 只立即刷,后续每 2s 刷 1 只。 * - 精英关(5):3 只精英同时刷出。 * - Boss 关(10):2 精英先刷,Boss 延迟 1s 刷出。 * - 怪物属性 = 基础 × 0.8 × (1 + 0.05×(lv-1)) × 类型倍率(精英1.5 / Boss3.0)。