Skip to content

Commit 5bbf483

Browse files
Merge remote-tracking branch 'origin/Sprint-3' into Sprint-3
2 parents 1edc750 + 35a6667 commit 5bbf483

12 files changed

Lines changed: 146 additions & 106 deletions

File tree

Classes/MidiMaestro/MidiMaestro.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ public partial class MidiMaestro : Resource
2323
//The path relative to the Audio folder. Will change later
2424
public MidiMaestro(string filePath)
2525
{
26+
if (!OS.HasFeature("editor"))
27+
{
28+
filePath = OS.GetExecutablePath().GetBaseDir() + "/" + filePath;
29+
}
30+
2631
if (!FileAccess.FileExists(filePath))
2732
{
2833
GD.PrintErr("ERROR: Unable to load level Midi file: " + filePath);

Globals/FunkEngineNameSpace.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ private Stages PickRoomType(int x, int y)
151151
{
152152
if (y % 3 == 0)
153153
return Stages.Chest;
154-
if (StageProducer.GlobalRng.Randf() < .1)
154+
if (StageProducer.GlobalRng.Randf() < .08)
155155
return Stages.Chest;
156156
return Stages.Battle;
157157
}

Globals/Scribe.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public partial class Scribe : Node
1919
1,
2020
(director, note, timing) =>
2121
{
22-
director.Player.TakeDamage(4 - (int)timing);
22+
director.Player.TakeDamage(3 - (int)timing);
2323
}
2424
),
2525
new Note(
@@ -110,7 +110,7 @@ public partial class Scribe : Node
110110
{
111111
new RelicEffect(
112112
BattleEffectTrigger.NotePlaced,
113-
1,
113+
2,
114114
(director, val) =>
115115
{
116116
director.Player.Heal(val);
@@ -126,7 +126,7 @@ public partial class Scribe : Node
126126
{
127127
new RelicEffect(
128128
BattleEffectTrigger.OnLoop,
129-
1,
129+
2,
130130
(director, val) =>
131131
{
132132
director.NotePlacementBar.IncreaseBonusMult(val);

scenes/BattleDirector/scripts/BattleDirector.cs

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ public partial class BattleDirector : Node2D
2828
[Export]
2929
private AudioStreamPlayer Audio;
3030

31+
[Export]
32+
private Button _focusedButton; //Initially start button
33+
3134
private double _timingInterval = .1; //secs, maybe make somewhat note dependent
3235
private double _lastBeat;
3336

@@ -36,15 +39,15 @@ public partial class BattleDirector : Node2D
3639
#endregion
3740

3841
#region Note Handling
39-
private void PlayerAddNote(ArrowType type, int beat)
42+
private bool PlayerAddNote(ArrowType type, int beat)
4043
{
4144
if (!NotePlacementBar.CanPlaceNote())
42-
return;
43-
if (CD.AddNoteToLane(type, beat % CM.BeatsPerLoop, NotePlacementBar.PlacedNote(), false))
44-
{
45-
NotePlaced?.Invoke(this);
46-
GD.Print("Note Placed.");
47-
}
45+
return false;
46+
if (!CD.AddNoteToLane(type, beat % CM.BeatsPerLoop, NotePlacementBar.PlacedNote(), false))
47+
return false;
48+
NotePlaced?.Invoke(this);
49+
GD.Print("Note Placed.");
50+
return true;
4851
}
4952

5053
public PuppetTemplate GetTarget(Note note)
@@ -83,29 +86,27 @@ public override void _Ready()
8386
AddChild(Enemy);
8487
Enemy.Defeated += CheckBattleStatus;
8588

86-
//TODO: This is a temporary measure
87-
Button startButton = new Button();
88-
startButton.Text = "Start";
89-
startButton.Position = GetViewportRect().Size / 2;
90-
AddChild(startButton);
91-
startButton.Pressed += () =>
89+
CM.PrepChart(_curSong);
90+
CD.Prep();
91+
CD.TimedInput += OnTimedInput;
92+
93+
CM.Connect(nameof(InputHandler.NotePressed), new Callable(this, nameof(OnNotePressed)));
94+
CM.Connect(nameof(InputHandler.NoteReleased), new Callable(this, nameof(OnNoteReleased)));
95+
96+
_focusedButton.GrabFocus();
97+
_focusedButton.Pressed += () =>
9298
{
9399
var timer = GetTree().CreateTimer(AudioServer.GetTimeToNextMix());
94100
timer.Timeout += Begin;
95-
startButton.QueueFree();
101+
_focusedButton.QueueFree();
102+
_focusedButton = null;
96103
};
97104
}
98105

99106
//TODO: This will all change
100107
private void Begin()
101108
{
102-
CM.PrepChart(_curSong);
103-
CD.Prep();
104-
CD.TimedInput += OnTimedInput;
105-
106-
CM.Connect(nameof(InputHandler.NotePressed), new Callable(this, nameof(OnNotePressed)));
107-
CM.Connect(nameof(InputHandler.NoteReleased), new Callable(this, nameof(OnNoteReleased)));
108-
109+
CM.BeginTweens();
109110
Audio.Play();
110111
}
111112

@@ -117,6 +118,7 @@ private void EndBattle()
117118

118119
public override void _Process(double delta)
119120
{
121+
_focusedButton?.GrabFocus();
120122
TimeKeeper.CurrentTime = Audio.GetPlaybackPosition();
121123
double realBeat = TimeKeeper.CurrentTime / (60 / (double)TimeKeeper.Bpm) % CM.BeatsPerLoop;
122124
CD.CheckMiss(realBeat);
@@ -152,24 +154,25 @@ private void OnTimedInput(Note note, ArrowType arrowType, int beat, double beatD
152154
GD.Print(arrowType + " " + beat + " difference: " + beatDif);
153155
if (note == null)
154156
{
155-
PlayerAddNote(arrowType, beat);
157+
if (PlayerAddNote(arrowType, beat))
158+
return; //Miss on empty note. This does not apply to inactive existing notes as a balance decision for now.
159+
NotePlacementBar.MissNote();
160+
CM.ComboText(Timing.Miss.ToString(), arrowType, NotePlacementBar.GetCurrentCombo());
161+
Player.TakeDamage(4);
156162
return;
157163
}
158164

159165
Timing timed = CheckTiming(beatDif);
160166

167+
note.OnHit(this, timed);
161168
if (timed == Timing.Miss)
162169
{
163-
note.OnHit(this, timed);
164170
NotePlacementBar.MissNote();
165171
}
166172
else
167173
{
168-
note.OnHit(this, timed);
169-
170174
NotePlacementBar.HitNote();
171175
}
172-
//NotePlacementBar.ComboText(timed.ToString());
173176
CM.ComboText(timed.ToString(), arrowType, NotePlacementBar.GetCurrentCombo());
174177
}
175178

scenes/BattleDirector/scripts/Conductor.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ public bool AddNoteToLane(ArrowType type, int beat, Note note, bool isActive = t
5858
arrow = CM.AddArrowToLane(type, beat, newNote, new Color(1, 0.43f, 0.26f));
5959
}
6060

61-
arrow.IsActive = isActive;
61+
if (!isActive)
62+
arrow.NoteHit();
6263
_laneData[(int)type][beat] = arrow;
6364
return true;
6465
}

scenes/BattleDirector/scripts/NotePlacementBar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public Note PlacedNote()
189189

190190
UpdateNotePlacementBar(_currentBarValue);
191191
//fullBarParticles.Emitting = false;
192-
return GetNote();
192+
return GetNote(Input.IsActionPressed("Secondary"));
193193
}
194194

195195
public bool CanPlaceNote()

scenes/BattleDirector/test_battle_scene.tscn

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,14 @@ gradient = SubResource("Gradient_8uy3a")
1717
fill_from = Vector2(1, 0)
1818
fill_to = Vector2(0.738532, 1)
1919

20-
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio")]
20+
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio", "_focusedButton")]
2121
process_mode = 1
2222
script = ExtResource("1_cwqqr")
2323
CM = NodePath("SubViewport")
2424
NotePlacementBar = NodePath("NotePlacementBar")
2525
CD = NodePath("Conductor")
2626
Audio = NodePath("AudioStreamPlayer")
27+
_focusedButton = NodePath("StartButton")
2728
metadata/_edit_lock_ = true
2829

2930
[node name="AudioStreamPlayer" type="AudioStreamPlayer" parent="."]
@@ -64,3 +65,11 @@ offset_top = 178.0
6465
offset_right = 640.0
6566
offset_bottom = 360.0
6667
texture = ExtResource("6_0ak0g")
68+
69+
[node name="StartButton" type="Button" parent="."]
70+
modulate = Color(5, 5, 5, 1)
71+
offset_left = 241.0
72+
offset_top = 234.0
73+
offset_right = 399.0
74+
offset_bottom = 265.0
75+
text = "Begin Battle [Enter]"

scenes/ChartViewport/scripts/ChartManager.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,10 @@ public void PrepChart(SongData songData)
5353

5454
IH.Connect(nameof(InputHandler.NotePressed), new Callable(this, nameof(OnNotePressed)));
5555
IH.Connect(nameof(InputHandler.NoteReleased), new Callable(this, nameof(OnNoteReleased)));
56+
}
5657

58+
public void BeginTweens()
59+
{
5760
//This could be good as a function to call on something, to have many things animated to the beat.
5861
var tween = GetTree().CreateTween();
5962
tween
@@ -118,7 +121,7 @@ public void ComboText(string text, ArrowType arrow, int currentCombo)
118121
{
119122
TextParticle newText = new TextParticle();
120123
AddChild(newText);
121-
newText.Position = IH.Arrows[(int)arrow].Node.Position - newText.Size/2;
124+
newText.Position = IH.Arrows[(int)arrow].Node.Position - newText.Size / 2;
122125
IH.FeedbackEffect(arrow, text);
123126
newText.Text = text + $" {currentCombo}";
124127
}

scenes/NoteManager/scripts/NoteArrow.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ public partial class NoteArrow : Sprite2D
1010
public ArrowType Type;
1111
public int Beat;
1212
public float Bounds;
13-
public bool IsActive;
13+
public bool IsActive = true;
1414
public Note NoteRef;
1515

1616
[Export]
@@ -48,15 +48,18 @@ public override void _Process(double delta)
4848
Position = newPos;
4949
}
5050

51-
public void OnLoop()
51+
private void OnLoop()
5252
{
53-
Visible = true;
53+
if (!IsActive)
54+
{
55+
Modulate /= .7f;
56+
}
5457
IsActive = true;
5558
}
5659

5760
public void NoteHit()
5861
{
59-
Visible = false;
62+
Modulate *= .7f;
6063
IsActive = false;
6164
}
6265
}

scenes/Puppets/scripts/PuppetTemplate.cs

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -45,30 +45,31 @@ public virtual void TakeDamage(int amount)
4545
{
4646
if (_currentHealth <= 0)
4747
return; //TEMP Only fire once.
48+
amount = Math.Max(0, amount); //Should not be able to heal from damage.
4849
_currentHealth = _healthBar.ChangeHP(-amount);
4950
if (_currentHealth <= 0)
5051
{
5152
Defeated?.Invoke(this);
5253
}
53-
if (amount != 0)
54-
{
55-
TextParticle newText = new TextParticle();
56-
newText.Modulate = Colors.Red;
57-
Sprite.AddChild(newText);
58-
newText.Text = $"-{amount}";
59-
}
54+
55+
if (amount == 0)
56+
return;
57+
TextParticle newText = new TextParticle();
58+
newText.Modulate = Colors.Red;
59+
Sprite.AddChild(newText);
60+
newText.Text = $"-{amount}";
6061
}
6162

6263
public virtual void Heal(int amount)
6364
{
64-
if (amount != 0)
65-
{
66-
TextParticle newText = new TextParticle();
67-
newText.Modulate = Colors.Green;
68-
Sprite.AddChild(newText);
69-
newText.Text = $"+{amount}";
70-
}
7165
_currentHealth = _healthBar.ChangeHP(amount);
66+
67+
if (amount == 0)
68+
return;
69+
TextParticle newText = new TextParticle();
70+
newText.Modulate = Colors.Green;
71+
Sprite.AddChild(newText);
72+
newText.Text = $"+{amount}";
7273
}
7374

7475
public int GetCurrentHealth()

0 commit comments

Comments
 (0)