Skip to content

Commit 9567f84

Browse files
committed
Added a reference to the Note in NoteArrow
NoteArrow has been given a variable of type Note to represent what special note is held in there. Notes created by the chart or enemy are assigned the type enemy, while notes placed by the player are assigned based on the noteQueue. Also, the queue doesn't "loop" so when the player runs out, they can no longer place notes.
1 parent a7f9dee commit 9567f84

File tree

6 files changed

+30
-37
lines changed

6 files changed

+30
-37
lines changed

scenes/BattleDirector/scripts/BattleDirector.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,15 @@ private void PlayerAddNote(ArrowType type, int beat)
4848
return;
4949
}
5050

51-
GD.Print($"Player trying to place {type} typed note at beat: " + beat);
51+
GD.Print($"Player trying to place {note.Name}:{type} typed note at beat: " + beat);
5252
if (!NotePlacementBar.CanPlaceNote())
5353
return;
54-
if (CD.AddNoteToLane(type, beat % CM.BeatsPerLoop, false))
54+
if (CD.AddNoteToLane(type, beat % CM.BeatsPerLoop, note, false))
5555
{
5656
NotePlacementBar.PlacedNote();
5757
NotePlaced?.Invoke(this);
5858
GD.Print("Note Placed.");
59+
NQ.DequeueNote();
5960
}
6061
}
6162

scenes/BattleDirector/scripts/Conductor.cs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ private bool IsNoteActive(ArrowType type, int beat)
4242
return _laneData[(int)type][beat] != null && _laneData[(int)type][beat].IsActive;
4343
}
4444

45-
public bool AddNoteToLane(ArrowType type, int beat, bool isActive = true)
45+
public bool AddNoteToLane(ArrowType type, int beat, Note note, bool isActive = true)
4646
{
4747
beat %= CM.BeatsPerLoop;
4848
//Don't add dupe notes //Beat at 0 is too messy.
@@ -54,12 +54,18 @@ public bool AddNoteToLane(ArrowType type, int beat, bool isActive = true)
5454
NoteArrow arrow;
5555
if (isActive)
5656
{
57-
arrow = CM.AddArrowToLane(type, beat, Notes.Length - 1);
57+
arrow = CM.AddArrowToLane(type, beat, Notes.Length - 1, note);
5858
arrow.NoteIdx = 1;
5959
}
6060
else
6161
{
62-
arrow = CM.AddArrowToLane(type, beat, Notes.Length - 1, new Color(1, 0.43f, 0.26f));
62+
arrow = CM.AddArrowToLane(
63+
type,
64+
beat,
65+
Notes.Length - 1,
66+
note,
67+
new Color(1, 0.43f, 0.26f)
68+
);
6369
arrow.NoteIdx = 0;
6470
}
6571

@@ -85,22 +91,22 @@ private void AddExampleNotes()
8591
GD.Print(CM.BeatsPerLoop);
8692
for (int i = 1; i < 15; i++)
8793
{
88-
AddNoteToLane(ArrowType.Up, i * 4);
94+
AddNoteToLane(ArrowType.Up, i * 4, Scribe.NoteDictionary[0]);
8995
}
9096

9197
for (int i = 1; i < 15; i++)
9298
{
93-
AddNoteToLane(ArrowType.Left, 4 * i + 1);
99+
AddNoteToLane(ArrowType.Left, 4 * i + 1, Scribe.NoteDictionary[0]);
94100
}
95101

96102
for (int i = 0; i < 10; i++)
97103
{
98-
AddNoteToLane(ArrowType.Right, 3 * i + 32);
104+
AddNoteToLane(ArrowType.Right, 3 * i + 32, Scribe.NoteDictionary[0]);
99105
}
100106

101107
for (int i = 0; i < 3; i++)
102108
{
103-
AddNoteToLane(ArrowType.Down, 8 * i + 16);
109+
AddNoteToLane(ArrowType.Down, 8 * i + 16, Scribe.NoteDictionary[0]);
104110
}
105111
}
106112

scenes/BattleDirector/test_battle_scene.tscn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@
99
[ext_resource type="AudioStream" uid="uid://cv6lqjj6lu36h" path="res://Audio/335571__magntron__gamemusic_120bpm.mp3" id="8_caqms"]
1010
[ext_resource type="Script" path="res://scenes/SceneTransitions/scripts/SceneChange.cs" id="9_bxa6e"]
1111

12-
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio")]
12+
[node name="ProtoBattleDirector" type="Node2D" node_paths=PackedStringArray("CM", "NotePlacementBar", "CD", "Audio", "NQ")]
1313
script = ExtResource("1_cwqqr")
1414
CM = NodePath("SubViewport")
1515
NotePlacementBar = NodePath("NotePlacementBar")
1616
CD = NodePath("Conductor")
1717
Audio = NodePath("AudioStreamPlayer")
18+
NQ = NodePath("NoteQueue")
1819

1920
[node name="Conductor" type="Node" parent="." node_paths=PackedStringArray("CM")]
2021
script = ExtResource("2_pcp76")

scenes/ChartViewport/ChartManager.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,12 @@ public NoteArrow AddArrowToLane(
102102
ArrowType type,
103103
int beat,
104104
int noteIdx,
105+
Note note,
105106
Color colorOverride = default
106107
)
107108
{
108-
var newNote = CreateNote(type, beat);
109-
var loopArrow = CreateNote(type, beat + BeatsPerLoop); //Create a dummy arrow for looping visuals
109+
var newNote = CreateNote(type, note, beat);
110+
var loopArrow = CreateNote(type, note, beat + BeatsPerLoop); //Create a dummy arrow for looping visuals
110111
if (colorOverride != default)
111112
{
112113
newNote.Modulate = colorOverride;
@@ -116,11 +117,11 @@ public NoteArrow AddArrowToLane(
116117
return newNote;
117118
}
118119

119-
private NoteArrow CreateNote(ArrowType arrow, int beat = 0)
120+
private NoteArrow CreateNote(ArrowType arrow, Note note, int beat = 0)
120121
{
121122
var noteScene = ResourceLoader.Load<PackedScene>("res://scenes/NoteManager/note.tscn");
122123
NoteArrow newArrow = noteScene.Instantiate<NoteArrow>();
123-
newArrow.Init(IH.Arrows[(int)arrow], beat);
124+
newArrow.Init(IH.Arrows[(int)arrow], beat, note);
124125

125126
_arrowGroup.AddChild(newArrow);
126127
newArrow.Bounds = (float)((double)beat / BeatsPerLoop * (ChartLength / 2));

scenes/CustomNotes/NoteQueue.cs

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public void LoadQueueFromSave()
3838

3939
for (int i = 0; i < numNotes; i++)
4040
{
41+
GD.Print($"Creating note from noteName: {noteName}");
4142
AddNoteToQueue(CreateNoteFromName(noteName));
4243
}
4344
}
@@ -47,30 +48,12 @@ public void LoadQueueFromSave()
4748
private Note CreateNoteFromName(string noteName)
4849
{
4950
if (noteName == "PlayerBase")
50-
{
51-
return new Note(
52-
"PlayerBase",
53-
null,
54-
1,
55-
(director, note, timing) =>
56-
{
57-
director.Enemy.TakeDamage((int)timing);
58-
}
59-
);
60-
}
51+
return Scribe.NoteDictionary[1];
52+
6153
if (noteName == "PlayerDouble")
62-
{
63-
return new Note(
64-
"PlayerDouble",
65-
null,
66-
1,
67-
(director, note, timing) =>
68-
{
69-
director.Enemy.TakeDamage(2 * (int)timing);
70-
}
71-
);
72-
}
54+
return Scribe.NoteDictionary[2];
7355

56+
GD.Print($"Failed to create not from noteName: {noteName}");
7457
return null;
7558
}
7659

scenes/NoteManager/scripts/NoteArrow.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ public partial class NoteArrow : Sprite2D
1212
public int Beat;
1313
public float Bounds;
1414
public bool IsActive;
15+
public Note NoteRef;
1516

16-
public void Init(ArrowData parentArrowData, int beat)
17+
public void Init(ArrowData parentArrowData, int beat, Note note)
1718
{
1819
ZIndex = 1;
1920

0 commit comments

Comments
 (0)