11using System ;
22using System . Collections . Generic ;
3- using FunkEngine ;
43using Godot ;
54
65public partial class NoteQueue : Node
@@ -23,15 +22,56 @@ public override void _Ready()
2322 "res://scenes/CustomNotes/assets/double_note.png"
2423 ) ;
2524
25+ LoadQueueFromSave ( ) ;
26+ ScrambleQueue ( ) ;
2627 UpdateQueue ( ) ;
2728 }
2829
29- public void LoadQueue ( PlayerPuppet player )
30+ // Loads the notes from SaveData.json, and adds them to the queue
31+ public void LoadQueueFromSave ( )
3032 {
31- for ( int i = 0 ; i < player . Stats . CurNotes . Length ; i ++ )
33+ Dictionary < string , int > savedNotes = SaveSystem . LoadNotes ( ) ;
34+ foreach ( var noteEntry in savedNotes )
3235 {
33- AddNoteToQueue ( player . Stats . CurNotes [ i ] ) ;
36+ string noteName = noteEntry . Key ;
37+ int numNotes = noteEntry . Value ;
38+
39+ for ( int i = 0 ; i < numNotes ; i ++ )
40+ {
41+ AddNoteToQueue ( CreateNoteFromName ( noteName ) ) ;
42+ }
43+ }
44+ }
45+
46+ // Creates a note from a string of the note's name.
47+ private Note CreateNoteFromName ( string noteName )
48+ {
49+ 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+ }
61+ 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+ ) ;
3472 }
73+
74+ return null ;
3575 }
3676
3777 public void AddNoteToQueue ( Note noteType )
@@ -40,7 +80,7 @@ public void AddNoteToQueue(Note noteType)
4080 UpdateQueue ( ) ;
4181 }
4282
43- //returns current note, and removes it from the queue
83+ // Returns current note, and removes it from the queue
4484 public Note GetCurrentNote ( )
4585 {
4686 if ( _noteQueue . Count > 0 )
@@ -52,6 +92,7 @@ public Note GetCurrentNote()
5292 return null ;
5393 }
5494
95+ // Updates the queue's graphics
5596 private void UpdateQueue ( )
5697 {
5798 if ( _noteQueue . Count > 0 && _noteSprites . ContainsKey ( _noteQueue . Peek ( ) . Name ) )
@@ -73,7 +114,7 @@ private void UpdateQueue()
73114 }
74115 }
75116
76- //Fisher-Yates shuffle from: https://stackoverflow.com/a/1262619
117+ // Fisher-Yates shuffle from: https://stackoverflow.com/a/1262619
77118 public void ScrambleQueue ( )
78119 {
79120 List < Note > tempList = new List < Note > ( _noteQueue ) ;
0 commit comments