Files
pixelheros/assets/script/game/common/ScreenShake.ts
pan 409113e269 feat: 完成肉鸽回合制游戏核心玩法迭代
新增连杀系统、金币飞行特效、波次HUD、屏幕震动等表现功能,重构怪物刷出逻辑与难度动态调节,调整回合回血比例,优化游戏节奏与体验。

主要变更:
1.  调整回合回血比例从0.5到0.4,优化前期节奏
2.  新增连杀计数与奖励系统,支持5/10/20连杀触发对应表现
3.  实现怪物死亡掉落金币的抛物线飞行特效
4.  增加波次进度HUD,显示剩余怪物与全局回合进度
5.  新增屏幕震动工具与战斗横幅统一展示系统
6.  重构怪物刷出逻辑,支持按回合类型调整刷怪间隔,加入清场加速机制
7.  优化动态难度调节算法,增加滞回与指数平滑,避免难度突变
8.  新增Boss预警、登场事件与回合清屏事件,完善事件总线
9.  调整怪物数量阈值与回合倒计时档位,适配新的节奏设计
2026-08-11 19:00:23 +08:00

46 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* @file ScreenShake.ts
* @description 屏幕震动静态工具(表现层)
*
* 项目内无现成相机震动能力MapViewScene.camera 可能为 null 且从未使用),
* 改为抖动地图根节点 smc.map.MapView.node地图+实体一起震UI 层不受影响)。
*
* 用法:
* ScreenShake.shake(10, 0.4); // 强度 10 像素,持续 0.4 秒
*/
import { tween, Tween, v3, Vec3 } from "cc";
import { smc } from "./SingletonModuleComp";
export class ScreenShake {
/** 地图根节点的基准位置(首次震动时快照,用于收敛回原位,防多次震动漂移) */
private static basePos: Vec3 | null = null;
/**
* 触发一次屏幕震动
* @param strength 像素振幅(建议 4~10
* @param duration 总时长(秒,建议 0.2~0.4
*/
static shake(strength: number = 8, duration: number = 0.3) {
const target = smc.map?.MapView?.node;
if (!target || !target.isValid) return;
if (!this.basePos) this.basePos = target.position.clone();
// 打断进行中的震动(新震动覆盖旧震动,不做强度叠加,避免失控)
Tween.stopAllByTarget(target);
const steps = Math.max(1, Math.floor(duration / 0.04));
const t = tween(target);
for (let i = 0; i < steps; i++) {
t.to(0.04, {
position: v3(
this.basePos.x + (Math.random() * 2 - 1) * strength,
this.basePos.y + (Math.random() * 2 - 1) * strength,
this.basePos.z),
});
}
// 收敛回原位
t.to(0.05, { position: this.basePos }).start();
}
}