Skip to content

Commit a0e49ef

Browse files
committed
修复金币逻辑
1 parent 97cbbed commit a0e49ef

File tree

13 files changed

+86
-97
lines changed

13 files changed

+86
-97
lines changed

src/actions/EntityActions.ts

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -184,25 +184,6 @@ export class VanishAction implements IEntityAction {
184184

185185

186186

187-
/**
188-
* (预留) 行为:加分
189-
*/
190-
const CoinSfxs = [
191-
AudioKeys.SfxCollectCoin1,
192-
AudioKeys.SfxCollectCoin2,
193-
AudioKeys.SfxCollectCoin3
194-
]
195-
export class CoinAction implements IEntityAction {
196-
private coin: number;
197-
constructor(coin: number) {
198-
this.coin = coin;
199-
}
200-
execute(_ctx: InteractionContext): void {
201-
const pattern = Phaser.Math.RND.pick(CoinSfxs);
202-
AudioManager.playSfx(pattern);
203-
gameEvents.emit(EVENTS.ADD_COIN, this.coin);
204-
}
205-
}
206187
/**
207188
* (预留) 行为:加分
208189
*/
@@ -216,11 +197,20 @@ export class ScoreAction implements IEntityAction {
216197
}
217198
}
218199

200+
201+
const CoinSfxs = [
202+
AudioKeys.SfxCollectCoin1,
203+
AudioKeys.SfxCollectCoin2,
204+
AudioKeys.SfxCollectCoin3
205+
]
219206
export class AddCoinAction implements IEntityAction {
220207
private amount: number;
221208
constructor(amount: number) { this.amount = amount; }
222209

223210
execute(ctx: InteractionContext) {
211+
const pattern = Phaser.Math.RND.pick(CoinSfxs);
212+
AudioManager.playSfx(pattern);
213+
224214
// ✅ 读取倍率 (蜀国默认是 1.0)
225215
const mult = ctx.player.playerState.stats.get(StatType.CoinMultiplier);
226216

src/config/BiomeDataConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ export const BiomeLibrary: Record<BiomeId, IBiomeData> = {
8383
id: BiomeId.L3_CloudMarsh,
8484
name: "云梦泽",
8585
durationMeters: 400,
86-
backgroundTexture: TextureKeys.BgL2,
86+
backgroundTexture: TextureKeys.BgL3,
8787
spawnTable: CloudMarshSpawnTable,
8888
envModifiers: [
8989
{
@@ -99,7 +99,7 @@ export const BiomeLibrary: Record<BiomeId, IBiomeData> = {
9999
id: BiomeId.L4_WindCave,
100100
name: "墨家风洞",
101101
durationMeters: 400,
102-
backgroundTexture: TextureKeys.BgL2,
102+
backgroundTexture: TextureKeys.BgL4,
103103
spawnTable: WindCaveSpawnTable,
104104
// ✅ 挂载机制
105105
buffs: [ WindCaveMechanicBuff ]

src/config/EntityConfig.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
import { ApplyBuffAction, ApplyDamageAction, BoostAction, CoinAction, ColdnessIncrementAction,
2-
DashEnergyIncrementAction, HasBuffTagOrVanishAction, HealAction, RemoveLinkedSummonAction,
3-
ScoreAction, SlowDownAction, SpawnLinkedSummonAction, VanishAction } from "../actions/EntityActions";
1+
import {
2+
AddCoinAction, ApplyBuffAction, ApplyDamageAction,
3+
BoostAction, ColdnessIncrementAction,
4+
DashEnergyIncrementAction, HasBuffTagOrVanishAction,
5+
HealAction, RemoveLinkedSummonAction,
6+
ScoreAction, SlowDownAction,
7+
SpawnLinkedSummonAction, VanishAction
8+
} from "../actions/EntityActions";
49
import { WeiConversionAction } from "../actions/MechanicActions";
510
import { EntityType, type IEntityConfig} from "../types/GameTypes";
611
import { AudioKeys, TextureKeys } from "./AssetKeys";
@@ -40,10 +45,10 @@ export const EntityConfig = {
4045
comment: "借风符",
4146
// color: 0xffffff,
4247
onHit: [
43-
new BoostAction(-750), // 普通力度
48+
new BoostAction(-900), // 普通力度
4449
new DashEnergyIncrementAction(2), // 增加冲刺能量
4550
new ScoreAction(1),
46-
new VanishAction(150, AudioKeys.SfxJump, 0.09) // 踩了消失
51+
new VanishAction(150, AudioKeys.SfxJump, EntityTextureScale * 1.2) // 踩了消失
4752
]
4853
}),
4954
// 孔明灯
@@ -52,7 +57,7 @@ export const EntityConfig = {
5257
scale: EntityTextureScale,
5358
type: EntityType.Buff, // ✅ 有益
5459
onHit: [
55-
new BoostAction(-750), // 力度适中
60+
new BoostAction(-900), // 力度适中
5661
new ColdnessIncrementAction(-15), // 增加体温
5762
new ApplyBuffAction(SkyLaternBuff),
5863
new DashEnergyIncrementAction(6), // 增加冲刺能量
@@ -67,7 +72,7 @@ export const EntityConfig = {
6772
type: EntityType.Buff, // ✅ 有益
6873
// color: 0xbd00ff,
6974
onHit: [
70-
new BoostAction(-1000), // 大力度
75+
new BoostAction(-1200), // 大力度
7176
new ColdnessIncrementAction(-25), // 增加体温
7277
new DashEnergyIncrementAction(10), // 增加冲刺能量
7378
new ScoreAction(3),
@@ -93,7 +98,7 @@ export const EntityConfig = {
9398
type: EntityType.Buff, // ✅ 有益
9499
// color: 0x00ff00,
95100
onHit: [
96-
new BoostAction(-600),
101+
new BoostAction(-900),
97102
new ApplyBuffAction(TacticsBuff),
98103
new ScoreAction(3),
99104
new VanishAction(150, AudioKeys.SfxCollectCoin2, EntityTextureScale * 1.2)
@@ -106,7 +111,7 @@ export const EntityConfig = {
106111
type: EntityType.Coin,
107112
// color: 0xffd700,
108113
onHit: [
109-
new CoinAction(200),
114+
new AddCoinAction(1),
110115
new ScoreAction(1),
111116
new VanishAction(150, null, EntityTextureScale * 0.6)
112117
]
@@ -118,7 +123,7 @@ export const EntityConfig = {
118123
type: EntityType.Buff, // ✅ 有益
119124
// color: 0x00ffdd,
120125
onHit: [
121-
new BoostAction(-600),
126+
new BoostAction(-900),
122127
new HealAction(1), // 恢复1点生命值
123128
new ScoreAction(3),
124129
new VanishAction(150, AudioKeys.SfxHeal, EntityTextureScale * 1.2)

src/config/GameConfig.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ export const GameConfig: IGameConfig = {
3838

3939
// --- 关卡生成 ---
4040
level: {
41-
cloudGap: 350, // 云朵生成的垂直间距
42-
cloudCount: 8, // 初始生成的云朵数量
41+
cloudGap: 250, // 云朵生成的垂直间距
42+
cloudCount: 10, // 初始生成的云朵数量
4343
cleanupThreshold: 1280 * 0.8, // 离开屏幕下方多少像素后销毁物体
4444
// ✅ 新增:允许坠落的最大深度
4545
// 例如:1.5 倍屏幕高度。意味着你可以掉下来一整屏多还能救回来,再多就死

src/entities/summons/LightningColumn.ts

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class LightningColumn extends BaseSummon {
8181
alpha: { from: 0.2, to: 1 },
8282
yoyo: true,
8383
repeat: 4,
84-
duration: 200
84+
duration: 180
8585
});
8686

8787
// 3. 禁用物理 (手动判定)
@@ -123,46 +123,41 @@ export class LightningColumn extends BaseSummon {
123123
}
124124

125125
// 闪电冲击动画 (0.5秒进度 + 0.5秒淡出)
126-
this.scene.tweens.add({
126+
this.scene.tweens.killTweensOf(this);
127+
this.scene.tweens.chain({
127128
targets: this,
128-
strikeProgress: 1,
129-
duration: 500,
130-
ease: 'Sine.easeOut',
131-
onUpdate: () => {
132-
if (pipeline) {
133-
pipeline.setProgress(this.strikeProgress);
134-
}
135-
},
136-
onComplete: () => {
137-
if (!this.strikeSprite) {
138-
this.isStriking = false;
139-
return;
140-
}
141-
this.scene.tweens.add({
142-
targets: this.strikeSprite,
143-
alpha: 0,
144-
duration: 500,
145-
ease: 'Sine.easeOut',
146-
onComplete: () => {
147-
// ? 1. 视觉上:彻底移除闪电,让玩家以为结束了
148-
if (this.strikeSprite) {
149-
this.strikeSprite.destroy();
150-
this.strikeSprite = undefined;
151-
}
152-
153-
// ? 2. 逻辑上:强制关闭伤害判定 (防止隐形电人)
154-
this.isStriking = false;
155-
156-
// ? 3. 核心修改:延迟 2秒 再真正回收
157-
// 这 2秒 期间,getActiveCount() 依然是 1,
158-
// 所以 LightningStrikeAction 会一直返回,不会生成新雷
159-
const COOLDOWN_TIME = 2000;
160-
161-
this.scene.time.delayedCall(COOLDOWN_TIME, () => {
162-
this.despawn();
163-
});
129+
tweens: [
130+
{
131+
strikeProgress: 1,
132+
duration: 500,
133+
ease: 'Sine.easeOut',
134+
onUpdate: () => {
135+
if (pipeline) {
136+
pipeline.setProgress(this.strikeProgress);
164137
}
165-
});
138+
},
139+
},
140+
{
141+
targets: this.strikeSprite,
142+
alpha: 0,
143+
duration: 500,
144+
ease: 'Sine.easeOut',
145+
}
146+
],
147+
onComplete: () => {
148+
this.isStriking = false;
149+
if (this.strikeSprite) {
150+
this.strikeSprite.destroy();
151+
this.strikeSprite = undefined;
152+
}
153+
154+
this.isStriking = false;
155+
156+
const COOLDOWN_TIME = 2000;
157+
158+
this.scene.time.delayedCall(COOLDOWN_TIME, () => {
159+
this.despawn();
160+
});
166161
}
167162
});
168163

src/entities/summons/ThermalVent.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { TextureKeys } from '../../config/AssetKeys';
12
import { GameConfig } from '../../config/GameConfig';
23
import { BaseSummon, type ISummonInitData } from './BaseSummon';
34

@@ -9,7 +10,8 @@ export class ThermalVent extends BaseSummon {
910
constructor(scene: Phaser.Scene, x: number, y: number) {
1011
// 假设你在 preload 加载了一个叫 'vfx_red_column' 的图
1112
// 或者直接用 'pixel' 纯色块拉伸
12-
super(scene, x, y, 'pixel');
13+
super(scene, x, y, TextureKeys.ThermalVent);
14+
this.setVisible(true); // 本体可见
1315
}
1416

1517
protected onStart(_data: ISummonInitData): void {

src/managers/DataManager.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const DEFAULT_SAVE: UserSaveData = {
5656

5757
export default class DataManager {
5858
private static _data: UserSaveData;
59-
private static readonly SAVE_KEY = 'kite_jump_save_v3';
59+
private static readonly SAVE_KEY = 'kite_jump_save_v4';
6060

6161
// --- 基础读写 ---
6262
static load() {
@@ -101,8 +101,8 @@ export default class DataManager {
101101
this.data.highestHeight = height;
102102
}
103103

104-
// 累加金币 (假设分数 1:1 转金币,或者你可以定义转换率)
105-
this.data.currency += Math.floor(score * 0.5);
104+
// 累加金币
105+
this.data.currency += Math.floor(currency);
106106

107107
this.save();
108108
}

src/managers/PhaseManager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,15 @@ export default class PhaseManager {
4949
public onPhaseComplete() {
5050
if (this.currentPhase instanceof NormalPhase) {
5151
// 正常关卡结束 -> 进过渡 (固定2000米过渡,或读取配置)
52+
this.currentBiomeId = this.getNextBiomeId();
5253
this.switchPhase(
5354
new TransitionPhase(GameConfig.level.transitionHeigth),
5455
BiomeLibrary[this.currentBiomeId]
5556
);
5657
}
5758
else if (this.currentPhase instanceof TransitionPhase) {
5859
// 过渡结束 -> 进下一个生态
59-
const nextId = this.getNextBiomeId();
60-
this.switchPhase(new NormalPhase(), BiomeLibrary[nextId]);
60+
this.switchPhase(new NormalPhase(), BiomeLibrary[this.currentBiomeId]);
6161
}
6262
}
6363

src/managers/ScoreManager.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ export default class ScoreManager {
3131
}
3232

3333
private setupListeners() {
34+
gameEvents.off(EVENTS.ADD_SCORE, this.handleAddScore, this);
35+
gameEvents.off(EVENTS.ADD_COIN, this.handleAddCoin, this);
3436
// 监听加分事件 (金币/杀怪)
3537
gameEvents.on(EVENTS.ADD_SCORE, this.handleAddScore, this);
3638
gameEvents.on(EVENTS.ADD_COIN, this.handleAddCoin, this);
@@ -190,7 +192,7 @@ export default class ScoreManager {
190192
}
191193

192194
public destroy() {
193-
gameEvents.off(EVENTS.ADD_SCORE, this.handleAddScore, this);
194-
gameEvents.off(EVENTS.ADD_COIN, this.handleAddCoin, this);
195+
// gameEvents.off(EVENTS.ADD_SCORE, this.handleAddScore, this);
196+
// gameEvents.off(EVENTS.ADD_COIN, this.handleAddCoin, this);
195197
}
196198
}

src/managers/SpawnManager.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ export default class SpawnManager {
3030
private currentDefs: Map<EntityId, ISpawnDefinition> = new Map();
3131
public isSpawningEnabled: boolean = false;
3232

33+
// ✅ 新增:保底计数器 (追踪连续多少层没有正面道具)
34+
private rowsSinceLastPositive: number = 0;
35+
3336
constructor(scene: GameScene, group: Phaser.Physics.Arcade.Group, player: Player) {
3437
this.scene = scene;
3538
this.interactables = group;
@@ -205,6 +208,7 @@ export default class SpawnManager {
205208
private spawnEntity(x: number, y: number) {
206209
// A. 动态计算总权重 (Logic Driven)
207210
const candidates: { id: EntityId, finalWeight: number }[] = [];
211+
let selectedId = candidates[0].id;
208212
let totalWeight = 0;
209213

210214
// 遍历所有有权重的 Stat
@@ -220,7 +224,6 @@ export default class SpawnManager {
220224

221225
// B. 随机取值
222226
let randomWeight = Phaser.Math.Between(0, totalWeight);
223-
let selectedId = candidates[0].id;
224227

225228
for (const candidate of candidates) {
226229
randomWeight -= candidate.finalWeight;

0 commit comments

Comments
 (0)