Skip to content

Commit 80d3fb8

Browse files
committed
修改寒冰漩涡
1 parent 16fa347 commit 80d3fb8

File tree

19 files changed

+218
-20
lines changed

19 files changed

+218
-20
lines changed

src/actions/BuffActions.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,19 @@ export class SpawnModifierAction implements IBuffAction {
167167
}
168168
}
169169

170+
export class GameEventAction implements IBuffAction {
171+
private eventType: string;
172+
private eventData: any;
173+
174+
constructor(eventType: string, eventData: any = null) {
175+
this.eventType = eventType;
176+
this.eventData = eventData;
177+
}
178+
execute(_ctx: IBuffContext): void {
179+
gameEvents.emit(this.eventType, this.eventData);
180+
}
181+
}
182+
170183

171184
export class SfxAction implements IBuffAction {
172185
private sfxAudioKey: AudioKey;

src/config/AssetKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export const VFXTextureKeys = {
8585
VfxLightningLine: 'vfx_lightning_line',
8686
VfxAlertIcon: 'vfx_alert_icon',
8787
VfxAlertBg: 'vfx_alert_bg',
88+
VfxShield: 'vfx_shield',
8889
} as const;
8990
export type VFXTextureKey = typeof VFXTextureKeys[keyof typeof VFXTextureKeys];
9091

src/config/AssetManifest.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const AssetManifest: IAssetDefinition[] = [
7575
{ key: TextureKeys.TacticsShild, path: 'assets/items/tactics_shild.png', type: 'image' },
7676
{ key: TextureKeys.Bamboo, path: 'assets/items/bamboo.png', type: 'image' },
7777
{ key: TextureKeys.Vulture, path: 'assets/items/vulture.png', type: 'image' },
78+
{ key: TextureKeys.FrostVortex, path: 'assets/items/frost_vortex.png', type: 'image' },
7879
{ key: TextureKeys.IceCrystals, path: 'assets/items/ice_crystals.png', type: 'image' },
7980
{ key: TextureKeys.ChaoticRune, path: 'assets/items/chaotic_rune.png', type: 'image' },
8081
{ key: TextureKeys.WindArrow, path: 'assets/items/arrow_indicator.png', type: 'image' },
@@ -119,7 +120,7 @@ export const AssetManifest: IAssetDefinition[] = [
119120
{ key: VFXTextureKeys.VfxAlertIcon, path: 'assets/vfx/FX_TEX_Alert_01.png', type: 'image' },
120121
// 3x3 网格,256 / 3 = 85.33,向下取整为 85
121122
createSpriteSheet(VFXTextureKeys.VfxAlertBg, 'assets/vfx/FX_TEX_Lightning_04.png', 85, 85, 9),
122-
123+
{key: VFXTextureKeys.VfxShield, path: 'assets/vfx/tactics_effect.png', type: 'image'},
123124

124125

125126
// ✅ 新增:音频资源

src/config/BuffConfig.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
import { ChangeWindAction, ColdnessIncrementAction, DashEnergyIncrementAction, ResetWindAction, ScoreAction, SfxAction, SpawnMode, SummonAction } from "../actions/BuffActions";
1+
import { ChangeWindAction, ColdnessIncrementAction, DashEnergyIncrementAction, GameEventAction, ResetWindAction, ScoreAction, SfxAction, SpawnMode, SummonAction } from "../actions/BuffActions";
22
import { LightningStrikeAction } from "../actions/MechanicActions";
33
import { type IBuffConfig } from "../mechanics/BuffTypes";
44
import { StatType, ModifierType } from "../mechanics/StatDefinitions";
55
import { AudioKeys } from "./AssetKeys";
6+
import { EVENTS } from "./Events";
67
import { SummonId } from "./SummonConfig";
78

89
// --- 公共的操控性修正 (模拟之前的 2.0x 乘数) ---
@@ -202,6 +203,12 @@ export const TacticsBuff: IBuffConfig = {
202203
duration: -1, // 永久
203204
maxStack: 1,
204205
tags: [TacticsConfig.tag],
206+
onAdd: [
207+
new GameEventAction(EVENTS.ADD_SHIELD)
208+
],
209+
onRemove: [
210+
new GameEventAction(EVENTS.REMOVE_SHIELD)
211+
]
205212
};
206213

207214
// 1. 雷暴 Buff
@@ -214,7 +221,7 @@ export const WeatherThunderBuff: IBuffConfig = {
214221
// 机制1:每秒回能 8%
215222
tickInterval: 1.0,
216223
onTick: [
217-
new DashEnergyIncrementAction(8),
224+
new DashEnergyIncrementAction(5),
218225
// ✅ 尝试落雷:40% 概率
219226
// 逻辑:每秒醒来一次 -> 检查场上没雷 -> 40%概率 -> 召唤 -> (雷存在1.5s+0.3s) -> 期间不会再召唤
220227
new LightningStrikeAction(0.4)

src/config/EntityConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export const EntityConfig = {
4646
// color: 0xffffff,
4747
onHit: [
4848
new BoostAction(-900), // 普通力度
49-
new DashEnergyIncrementAction(2), // 增加冲刺能量
49+
new DashEnergyIncrementAction(3), // 增加冲刺能量
5050
new ScoreAction(1),
5151
new VanishAction(150, AudioKeys.SfxJump, EntityTextureScale * 1.2) // 踩了消失
5252
]
@@ -72,7 +72,7 @@ export const EntityConfig = {
7272
type: EntityType.Buff, // ✅ 有益
7373
// color: 0xbd00ff,
7474
onHit: [
75-
new BoostAction(-1200), // 大力度
75+
new BoostAction(-1250), // 大力度
7676
new ColdnessIncrementAction(-25), // 增加体温
7777
new DashEnergyIncrementAction(10), // 增加冲刺能量
7878
new ScoreAction(3),

src/config/Events.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export const EVENTS = {
2525
ADD_SCORE: 'add-score', // Game Logic: 增加分数
2626
ADD_COIN: 'add-coin', // Game Logic: 增加金币
2727

28+
ADD_SHIELD: 'add-shield', // Game Logic: 增加护盾
29+
REMOVE_SHIELD: 'remove-shield', // Game Logic: 移除护盾
30+
2831
INPUT_DIR: 'input-dir', // UI -> Game: 输入方向 (-1/0/1)
2932

3033
WIND_CHANGE: 'wind-change', // 环境风力变化

src/config/GameConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export const GameConfig: IGameConfig = {
3838

3939
// --- 关卡生成 ---
4040
level: {
41-
cloudGap: 200, // 云朵生成的垂直间距
41+
cloudGap: 250, // 云朵生成的垂直间距
4242
cloudCount: 10, // 初始生成的云朵数量
4343
cleanupThreshold: 1280 * 0.8, // 离开屏幕下方多少像素后销毁物体
4444
// ✅ 新增:允许坠落的最大深度

src/config/SummonConfig.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { FogOverlay } from "../entities/summons/FogOverlay";
44
import { WindVane } from "../entities/summons/WindVane";
55
import { FrostVortex } from "../entities/summons/FrostVortex";
66
import { LightningColumn } from "../entities/summons/LightningColumn";
7+
import { Shield } from "../entities/summons/Shield";
78

89
// ✅ 1. 定义召唤物 ID 常量 (替代硬编码字符串)
910
export const SummonId = {
@@ -12,6 +13,7 @@ export const SummonId = {
1213
WindVane: 'wind_vane', // ✅ 新增 ID
1314
FrostVortex: 'frost_vortex',
1415
LightningColumn: 'lightning_column',
16+
Shield: 'shield',
1517
} as const;
1618

1719
export type SummonId = typeof SummonId[keyof typeof SummonId];
@@ -49,5 +51,10 @@ export const SummonConfig: Record<SummonId, ISummonDef> = {
4951
classType: LightningColumn,
5052
space: SpaceType.Screen,
5153
poolSize: 3 // 稍微多给点,防止回收延迟导致的卡死,虽然逻辑限制了1个
54+
},
55+
[SummonId.Shield]: {
56+
classType: Shield,
57+
space: SpaceType.World,
58+
poolSize: 1
5259
}
5360
};

src/entities/Player.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ export default class Player extends Phaser.Physics.Arcade.Sprite {
305305
// 销毁时记得清空 Graphics
306306
destroy(fromScene?: boolean) {
307307
this.magnetZone.destroy();
308+
this.playerState.destroy();
308309
gameEvents.off(EVENTS.INPUT_DIR, this.handleInputDir, this);
309310
// this.statusUI.destroy();
310311
super.destroy(fromScene);

src/entities/PlayerState.ts

Lines changed: 69 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import StatSystem from '../mechanics/StatSystem';
55
import BuffManager from '../managers/BuffManager';
66
import { ModifierType, StatType } from '../mechanics/StatDefinitions';
77
import DataManager from '../managers/DataManager';
8-
import { DashConfig, DashLv1Buff, DashLv2Buff, DashLv3Buff, TransitionDashConfig } from '../config/BuffConfig';
8+
import { DashConfig, DashLv1Buff, DashLv2Buff, DashLv3Buff, TacticsConfig, TransitionDashConfig } from '../config/BuffConfig';
99
import { KiteConfigs } from '../config/KiteBuffConfig';
1010
import { EVENTS, gameEvents } from '../config/Events';
11+
import { SummonId } from '../config/SummonConfig';
12+
import type { BaseSummon } from './summons/BaseSummon';
1113

1214
export default class PlayerState {
1315
private player: Player;
@@ -23,6 +25,9 @@ export default class PlayerState {
2325
public coldness: number = 0; // 0 - 100
2426
public dashEnergy: number = 0; // 0 - 100
2527

28+
private shieldEffect: BaseSummon | null = null;
29+
private wasDashing: boolean = false;
30+
2631
public get isInvincible(): boolean {
2732
return this.buffs.hasTag('State.Invincible');
2833
}
@@ -47,6 +52,9 @@ export default class PlayerState {
4752

4853
// 2. 注入基础属性 (Base Stats)
4954
this.initBaseStats();
55+
56+
gameEvents.on(EVENTS.ADD_SHIELD, this.handleAddShield, this);
57+
gameEvents.on(EVENTS.REMOVE_SHIELD, this.handleRemoveShield, this);
5058
}
5159

5260
private initBaseStats() {
@@ -88,8 +96,10 @@ export default class PlayerState {
8896
}
8997

9098
update(dt: number) {
99+
this.refreshShieldRef();
91100
// 1. 更新 Buff 系统 (转为秒)
92101
this.buffs.update(dt / 1000);
102+
this.syncDashShieldState();
93103
// 2. 更新寒冷值
94104
this.updateColdness(dt);
95105
// 4. ✅ 核心:将寒冷值同步到 StatSystem
@@ -245,7 +255,7 @@ export default class PlayerState {
245255
}
246256

247257
// ⚡️ 冲刺效果:清除所有寒冷
248-
this.coldness = 0;
258+
this.addColdness(-this.coldness);
249259

250260
// ⚡️ 冲刺效果:无敌 & 向上猛冲 (逻辑在 Player.update 里配合)
251261
// this.player.setVelocityY(GameConfig.playerState.dashSpeed);
@@ -329,4 +339,60 @@ export default class PlayerState {
329339
public getStartBoostForce(): number {
330340
return GameConfig.player.startForce;
331341
}
332-
}
342+
343+
public destroy() {
344+
gameEvents.off(EVENTS.ADD_SHIELD, this.handleAddShield, this);
345+
gameEvents.off(EVENTS.REMOVE_SHIELD, this.handleRemoveShield, this);
346+
}
347+
348+
private syncDashShieldState() {
349+
const isDashingNow = this.isDashing;
350+
if (!this.wasDashing && isDashingNow) {
351+
this.ensureShieldSummoned();
352+
} else if (this.wasDashing && !isDashingNow) {
353+
if (!this.buffs.hasTag(TacticsConfig.tag)) {
354+
this.removeShield();
355+
}
356+
}
357+
this.wasDashing = isDashingNow;
358+
}
359+
360+
private handleAddShield() {
361+
this.ensureShieldSummoned();
362+
}
363+
364+
private handleRemoveShield() {
365+
if (!this.isDashing) {
366+
this.removeShield();
367+
}
368+
}
369+
370+
private ensureShieldSummoned() {
371+
if (this.shieldEffect && this.shieldEffect.active) return;
372+
const summonManager = (this.player.scene as any).summonManager;
373+
if (!summonManager) return;
374+
const summoned = summonManager.summon(
375+
SummonId.Shield,
376+
this.player.x,
377+
this.player.y,
378+
{ lifeTime: -1 }
379+
);
380+
if (summoned) {
381+
this.shieldEffect = summoned;
382+
}
383+
}
384+
385+
private removeShield() {
386+
if (this.shieldEffect && this.shieldEffect.active) {
387+
this.shieldEffect.despawn();
388+
} else {
389+
this.shieldEffect = null;
390+
}
391+
}
392+
393+
private refreshShieldRef() {
394+
if (this.shieldEffect && !this.shieldEffect.active) {
395+
this.shieldEffect = null;
396+
}
397+
}
398+
}

0 commit comments

Comments
 (0)