Skip to content

Commit 5b8d045

Browse files
committed
Refactor Loose Change increase display
Add relic bonus directly into BattleScore Fix issue where battleend could be called multiple times Fix issue where min stage heights weren't being applied correctly
1 parent 0069a09 commit 5b8d045

6 files changed

Lines changed: 30 additions & 26 deletions

File tree

Globals/FunkEngineNameSpace.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,8 @@ private Stages PickRoomType(int x, int y, MapLevels.MapConfig curConfig)
365365
}
366366

367367
//Random roll for the room type.
368-
float[] validRooms = curConfig.StageOdds;
368+
float[] validRooms = new float[curConfig.StageOdds.Length];
369+
curConfig.StageOdds.CopyTo(validRooms, 0);
369370
foreach ((Stages stage, int height) in curConfig.MinHeights)
370371
{
371372
if (y < height)

Globals/Scribe.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ public partial class Scribe : Node
344344
10,
345345
(e, self, val) =>
346346
{
347-
StageProducer.PlayerStats.Money += val;
347+
e.BD.BattleScore.IncRelicBonus(val);
348348
}
349349
),
350350
}

Globals/Translations/Translations.csv

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ HOW_TO_PLAY,How to Play,如何游玩
8888
HOW_TO_PLAY_BLOCK1,"Hit notes to\nbuild combo","点击音符\n以建立连击"
8989
HOW_TO_PLAY_BLOCK2,"Place notes when\ncombo is full","当连击满\n时放置音符"
9090
HOW_TO_PLAY_BLOCK3,"Only placed notes\nhave effects","只有已放置\n的音符才有效"
91+
SCORING_RELICS,"Loose Change income:","零钱收入:"
9192
TUTORIAL_NODYING,"No dying during a tutorial!",(TODO)
9293
TUTORIAL_DIALOGUE_1,"Hello, welcome to Midnight Riff!",(TODO)
9394
TUTORIAL_DIALOGUE_2,"This is a rhythm game where notes more right to left.",(TODO)
@@ -107,5 +108,4 @@ TUTORIAL_PLACE_6,"Now go ahead, place a note in the bottom lane!",(TODO)
107108
TUTORIAL_FINAL_1,"Good job, you placed a note! You either healed yourself, or dealt damage. I can't tell I'm just a Strawman.",(TODO)
108109
TUTORIAL_FINAL_2,"As a refresher: Hit notes to build a combo and fill the bar. When the bar is full, press one of your buttons for a lane that doesn't have a note at the current beat. Notes in the chart will loop around. Keep it up to win.",(TODO)
109110
TUTORIAL_FINAL_3,"Good luck! I believe in you.",(TODO)
110-
TUTORIAL_BOSS,"This may take some getting used to, but death is ok in the grand scheme of things. Just have some patience with yourself, you'll learn in the end.",(TODO)
111-
RELIC_PLACED,"Loose Change income:","零钱收入:"
111+
TUTORIAL_BOSS,"This may take some getting used to, but death is ok in the grand scheme of things. Just have some patience with yourself, you'll learn in the end.",(TODO)

Scenes/BattleDirector/Scripts/BattleDirector.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public override void _Ready()
110110
Harbinger.Instance.InvokeBattleStarted();
111111
}
112112

113-
private ScoringScreen.ScoreGuide _battleScore;
113+
public ScoringScreen.ScoreGuide BattleScore;
114114

115115
private void InitScoringGuide()
116116
{
@@ -119,20 +119,20 @@ private void InitScoringGuide()
119119
{
120120
baseMoney += enem.BaseMoney;
121121
}
122-
_battleScore = new ScoringScreen.ScoreGuide(baseMoney, Player.GetCurrentHealth());
122+
BattleScore = new ScoringScreen.ScoreGuide(baseMoney, Player.GetCurrentHealth());
123123
Harbinger.Instance.NotePlaced += (_) =>
124124
{
125-
_battleScore.IncPlaced();
125+
BattleScore.IncPlaced();
126126
};
127127
Harbinger.Instance.NoteHit += (_) =>
128128
{
129-
_battleScore.IncHits();
129+
BattleScore.IncHits();
130130
};
131131
Harbinger.Instance.NoteHit += (e) =>
132132
{
133133
if (e is Harbinger.NoteHitArgs { Timing: Timing.Perfect })
134-
_battleScore.IncPerfects();
135-
_battleScore.IncHits();
134+
BattleScore.IncPerfects();
135+
BattleScore.IncHits();
136136
};
137137
}
138138

@@ -290,7 +290,6 @@ private void CheckBattleStatus(PuppetTemplate puppet) //Called when a puppet die
290290
{
291291
if (!IsBattleWon())
292292
return;
293-
Harbinger.Instance.InvokeBattleEnded();
294293
CM.ProcessMode = ProcessModeEnum.Disabled;
295294
tween.TweenCallback(Callable.From(OnBattleWon));
296295
}
@@ -303,10 +302,11 @@ private bool IsBattleWon()
303302

304303
private void OnBattleWon()
305304
{
305+
Harbinger.Instance.InvokeBattleEnded();
306306
CleanUpRelics();
307-
_battleScore.SetEndHp(Player.GetCurrentHealth());
307+
BattleScore.SetEndHp(Player.GetCurrentHealth());
308308
Audio.ProcessMode = ProcessModeEnum.Always;
309-
ScoringScreen.CreateScore(this, _battleScore).Finished += () =>
309+
ScoringScreen.CreateScore(this, BattleScore).Finished += () =>
310310
{
311311
ShowRewardSelection(3);
312312
};

Scenes/UI/ScoreScreen.tscn

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ text = "SCORING_PLACED"
148148

149149
[node name="RelicLabel" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"]
150150
layout_mode = 2
151-
text = "RELIC_PLACED"
151+
text = "SCORING_RELICS"
152152

153153
[node name="Placeholder" type="Label" parent="Bg/WindowMargin/PanelBg/VBoxContainer/MarginContainer/BottomPanelBg/HBoxContainer/LabelMargin/LabelVbox"]
154154
layout_mode = 2

Scenes/UI/Scripts/ScoringScreen.cs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public struct ScoreGuide
1212
public int TotalHits = 0;
1313
public int TotalPerfects = 0;
1414
public int TotalPlaced = 0;
15+
public int RelicBonus = 0;
1516
public float StartingHealth = 0;
1617
public float EndingHealth = 0;
1718

@@ -41,6 +42,11 @@ public void IncPlaced()
4142
TotalPlaced++;
4243
}
4344

45+
public void IncRelicBonus(int amount)
46+
{
47+
RelicBonus += amount;
48+
}
49+
4450
public void SetEndHp(float amount)
4551
{
4652
EndingHealth = amount;
@@ -83,24 +89,15 @@ public void SetEndHp(float amount)
8389
private int _totalBaseMoney;
8490
private float _perfectMulti;
8591
private float _placedMulti;
86-
private bool _hasChange;
87-
private int _changeAmount = Scribe.RelicDictionary[10].Effects[0].Value;
88-
private int FinalMoney =>
89-
(int)(_totalBaseMoney * _perfectMulti * _placedMulti) + (_hasChange ? _changeAmount : 0);
92+
private int _relicBonus;
93+
private int FinalMoney => (int)(_totalBaseMoney * _perfectMulti * _placedMulti) + _relicBonus;
9094

9195
public delegate void FinishedHandler();
9296
public event FinishedHandler Finished;
9397

9498
public override void _Ready()
9599
{
96100
_acceptButton.Pressed += FinishScoring;
97-
98-
_hasChange = StageProducer.PlayerStats.CurRelics.Contains(Scribe.RelicDictionary[10]);
99-
if (!_hasChange)
100-
{
101-
_relicLabel.Visible = false;
102-
_relicAmount.Visible = false;
103-
}
104101
}
105102

106103
public override void _Process(double delta)
@@ -128,6 +125,7 @@ private void GenerateScore(ScoreGuide info)
128125
if (float.IsNaN(_perfectMulti))
129126
_perfectMulti = 1;
130127
_placedMulti = Math.Max(2 - (float)Math.Abs(info.TotalPlaced - info.BaseMoney) / 10, 1);
128+
_relicBonus = info.RelicBonus;
131129
DrawScoreLabels();
132130
}
133131

@@ -141,10 +139,15 @@ private int CalcTotalBase(ScoreGuide info)
141139

142140
private void DrawScoreLabels()
143141
{
142+
if (_relicBonus <= 0)
143+
{
144+
_relicLabel.Visible = false;
145+
_relicAmount.Visible = false;
146+
}
144147
_styleAmount.Text = $"{_totalBaseMoney}";
145148
_perfectsAmount.Text = $"X{_perfectMulti:0.00}";
146149
_placedAmount.Text = $"X{_placedMulti:0.00}";
147-
_relicAmount.Text = $"+{_changeAmount}";
150+
_relicAmount.Text = $"+{_relicBonus}";
148151
_totalAmount.Text = $"{FinalMoney}";
149152
}
150153

0 commit comments

Comments
 (0)