Skip to content

Commit 55f968f

Browse files
authored
Added simple money system (#191)
* Smooth out end of battle Pause chart scrolling and tween fade last enemy(s) Allow audio to continue if it doesn't need to be stopped on battle end and chest open * Prototype score screen * Added money vars Saveable player money Enemies have a base money amount * Money implemented A player can gain money from battle TODO: Where to see current money TODO: What to use money on * Update inventory to show money
1 parent bd62146 commit 55f968f

File tree

16 files changed

+451
-10
lines changed

16 files changed

+451
-10
lines changed

Globals/SaveSystem.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,7 @@ public class SaveFile
373373
public int LastRoomIdx { get; init; }
374374
public int Area { get; init; }
375375

376+
public int Money { get; init; }
376377
public int[] NoteIds { get; init; }
377378
public int[] RelicIds { get; init; }
378379
public int PlayerHealth { get; init; }
@@ -384,7 +385,8 @@ public SaveFile(
384385
int[] noteIds,
385386
int[] relicIds,
386387
int playerHealth,
387-
int area
388+
int area,
389+
int money
388390
)
389391
{
390392
RngSeed = rngSeed;
@@ -394,6 +396,7 @@ int area
394396
RelicIds = relicIds;
395397
PlayerHealth = playerHealth;
396398
Area = area;
399+
Money = money;
397400
}
398401
}
399402

@@ -408,7 +411,8 @@ public static void SaveGame()
408411
noteIds,
409412
relicIds,
410413
StageProducer.PlayerStats.CurrentHealth,
411-
(int)StageProducer.CurArea
414+
(int)StageProducer.CurArea,
415+
StageProducer.PlayerStats.Money
412416
);
413417
string json = JsonSerializer.Serialize(sv);
414418

Globals/StageProducer.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ private bool LoadGame()
114114
PlayerStats.AddRelic(Scribe.RelicDictionary[relicId]);
115115
}
116116
PlayerStats.CurrentHealth = sv.PlayerHealth;
117+
PlayerStats.Money = sv.Money;
117118
IsInitialized = true;
118119
return true;
119120
}

Scenes/BattleDirector/Scripts/BattleDirector.cs

Lines changed: 49 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,41 @@ public override void _Ready()
6767
Harbinger.Init(this);
6868
InitPlayer();
6969
InitEnemies();
70+
InitScoringGuide();
7071
CD.Initialize(curSong);
7172
CD.NoteInputEvent += OnTimedInput;
7273

7374
_focusedButton.GrabFocus();
7475
_focusedButton.Pressed += SyncStartWithMix;
7576
}
7677

78+
private ScoringScreen.ScoreGuide _battleScore;
79+
80+
private void InitScoringGuide()
81+
{
82+
int baseMoney = 0;
83+
foreach (EnemyPuppet enem in _enemies)
84+
{
85+
baseMoney += enem.BaseMoney;
86+
}
87+
88+
_battleScore = new ScoringScreen.ScoreGuide(baseMoney, Player.GetCurrentHealth());
89+
Harbinger.Instance.NotePlaced += (_) =>
90+
{
91+
_battleScore.IncPlaced();
92+
};
93+
Harbinger.Instance.NoteHit += (_) =>
94+
{
95+
_battleScore.IncHits();
96+
};
97+
Harbinger.Instance.NoteHit += (e) =>
98+
{
99+
if (e is Harbinger.NoteHitArgs { Timing: Timing.Perfect })
100+
_battleScore.IncPerfects();
101+
_battleScore.IncHits();
102+
};
103+
}
104+
77105
private void InitPlayer()
78106
{
79107
Player = GD.Load<PackedScene>(PlayerPuppet.LoadPath).Instantiate<PlayerPuppet>();
@@ -213,8 +241,21 @@ private void CheckBattleStatus(PuppetTemplate puppet) //Called when a puppet die
213241
OnBattleLost();
214242
return;
215243
}
216-
if (puppet is EnemyPuppet && IsBattleWon())
217-
OnBattleWon(); //will have to adjust this to account for when we have multiple enemies at once
244+
245+
if (puppet is EnemyPuppet)
246+
{
247+
if (IsBattleWon())
248+
{
249+
CM.ProcessMode = ProcessModeEnum.Disabled;
250+
var tween = CreateTween();
251+
tween.TweenProperty(puppet, "modulate:a", 0, 2f);
252+
tween.TweenCallback(Callable.From(OnBattleWon));
253+
}
254+
else
255+
{
256+
puppet.Visible = false;
257+
}
258+
}
218259
}
219260

220261
private bool IsBattleWon()
@@ -224,9 +265,13 @@ private bool IsBattleWon()
224265

225266
private void OnBattleWon()
226267
{
227-
Audio.StreamPaused = true;
228268
CleanUpRelics();
229-
ShowRewardSelection(3);
269+
_battleScore.SetEndHp(Player.GetCurrentHealth());
270+
Audio.ProcessMode = ProcessModeEnum.Always;
271+
ScoringScreen.CreateScore(this, _battleScore).Finished += () =>
272+
{
273+
ShowRewardSelection(3);
274+
};
230275
}
231276

232277
private void OnBattleLost()

Scenes/ChestScene/ChestScene.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ public override void _Process(double delta)
3333

3434
private void GetLoot()
3535
{
36+
GetNode<AudioStreamPlayer>("%Audio").ProcessMode = ProcessModeEnum.Always;
3637
ChestButton.Disabled = true;
3738
RewardSelect.CreateSelection(this, _player.Stats, 3, Stages.Chest).Selected += EndBattle;
3839
}

Scenes/ChestScene/ChestScene.tscn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ script = ExtResource("1_ardd2")
2323
ChestButton = NodePath("CenterContainer/VBoxContainer/ChestButton")
2424
PlayerMarker = NodePath("PlayerMarker")
2525

26-
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
26+
[node name="Audio" type="AudioStreamPlayer" parent="."]
27+
unique_name_in_owner = true
2728
stream = ExtResource("2_x78jo")
2829
autoplay = true
2930

Scenes/Puppets/Enemies/BossBlood/P_BossBlood.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public override void _Ready()
1010
{
1111
CurrentHealth = 100;
1212
MaxHealth = 100;
13+
BaseMoney = 15;
1314
base._Ready();
1415
var enemTween = CreateTween();
1516
enemTween.TweenProperty(Sprite, "position", Vector2.Down * 5, 1f).AsRelative();

Scenes/Puppets/Enemies/EnemyPuppet.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
public partial class EnemyPuppet : PuppetTemplate
44
{
55
protected EnemyEffect[] BattleEvents = Array.Empty<EnemyEffect>();
6+
public int BaseMoney { get; protected set; } = 0;
67

78
public virtual EnemyEffect[] GetBattleEvents()
89
{

Scenes/Puppets/Enemies/Parasifly/P_Parasifly.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public override void _Ready()
1010
{
1111
CurrentHealth = 50;
1212
MaxHealth = 50;
13+
BaseMoney = 5;
1314
base._Ready();
1415
var enemTween = CreateTween();
1516
enemTween.TweenProperty(Sprite, "position", Vector2.Down * 2, 2f).AsRelative();

Scenes/Puppets/Enemies/TheGWS/P_TheGWS.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ public override void _Ready()
99
{
1010
CurrentHealth = 75;
1111
MaxHealth = 75;
12+
BaseMoney = 10;
1213
base._Ready();
1314
var enemTween = CreateTween();
1415
enemTween.TweenProperty(Sprite, "position", Vector2.Down * 10, 3f).AsRelative();

Scenes/Puppets/Scripts/PlayerStats.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
public partial class PlayerStats : Resource
77
{
8+
public int Money = 0;
9+
810
public int MaxHealth = 100;
911
public int CurrentHealth = 100;
1012
public int MaxComboBar = 60;

0 commit comments

Comments
 (0)