@@ -19,6 +19,8 @@ public partial class BattleDirector : Node2D
1919 private HealthBar Player ;
2020 private HealthBar Enemy ;
2121
22+ private NotePlacementBar NotePlacementBar ;
23+
2224 private double _timingInterval = .1 ; //secs
2325
2426 [ Signal ]
@@ -35,6 +37,7 @@ public struct SongData
3537 }
3638
3739 private SongData _curSong ;
40+
3841 //Assume queue structure for notes in each lane.
3942 private readonly Note [ ] [ ] _laneNotes = new Note [ ] [ ]
4043 {
@@ -52,6 +55,7 @@ public override void _Ready()
5255
5356 Player = GetNode < HealthBar > ( "PlayerHP" ) ;
5457 Enemy = GetNode < HealthBar > ( "EnemyHP" ) ;
58+ NotePlacementBar = GetNode < NotePlacementBar > ( "NotePlacementBar" ) ;
5559
5660 CM . Connect ( nameof ( NoteManager . NotePressed ) , new Callable ( this , nameof ( OnNotePressed ) ) ) ;
5761 CM . Connect ( nameof ( NoteManager . NoteReleased ) , new Callable ( this , nameof ( OnNoteReleased ) ) ) ;
@@ -64,7 +68,8 @@ public override void _Process(double delta)
6468 double curBeat = TimeKeeper . CurrentTime / ( 60 / ( double ) _curSong . Bpm ) ;
6569 for ( int i = 0 ; i < _laneNotes . Length ; i ++ )
6670 {
67- if ( _laneNotes [ i ] . Length <= 0 ) continue ;
71+ if ( _laneNotes [ i ] . Length <= 0 )
72+ continue ;
6873 double beatDif = ( curBeat - _laneNotes [ i ] . First ( ) . Beat ) ;
6974 if ( beatDif > 1 )
7075 {
@@ -105,9 +110,7 @@ private void OnNotePressed(NoteArrow.ArrowType type)
105110 CheckNoteTiming ( type ) ;
106111 }
107112
108- private void OnNoteReleased ( NoteArrow . ArrowType arrowType )
109- {
110- }
113+ private void OnNoteReleased ( NoteArrow . ArrowType arrowType ) { }
111114
112115 private void handleTiming ( NoteArrow . ArrowType type , double beatDif )
113116 {
@@ -122,34 +125,64 @@ private void handleTiming(NoteArrow.ArrowType type, double beatDif)
122125 {
123126 GD . Print ( "Perfect" ) ;
124127 Enemy . TakeDamage ( 10 ) ;
128+ NotePlacementBar . HitNote ( ) ;
125129 }
126130 else if ( beatDif < _timingInterval * 4 )
127131 {
128132 GD . Print ( "Good" ) ;
129133 Enemy . TakeDamage ( 5 ) ;
134+ NotePlacementBar . HitNote ( ) ;
130135 }
131136 else if ( beatDif < _timingInterval * 6 )
132137 {
133138 GD . Print ( "Okay" ) ;
134139 Enemy . TakeDamage ( 1 ) ;
140+ NotePlacementBar . HitNote ( ) ;
135141 }
136142 else
137143 {
138144 GD . Print ( "Miss" ) ;
139145 Player . TakeDamage ( 10 ) ;
146+ NotePlacementBar . MissNote ( ) ;
140147 }
141148 }
142149
143150 private void CheckNoteTiming ( NoteArrow . ArrowType type )
144151 {
145152 double curBeat = TimeKeeper . CurrentTime / ( 60 / ( double ) _curSong . Bpm ) ;
146153 if ( _laneNotes [ ( int ) type ] . Length == 0 )
154+ {
155+ PlayerAddNote ( type , ( int ) curBeat ) ;
147156 return ;
157+ }
148158 double beatDif = Math . Abs ( curBeat - _laneNotes [ ( int ) type ] . First ( ) . Beat ) ;
149159 if ( beatDif > 1 )
160+ {
161+ PlayerAddNote ( type , ( int ) curBeat ) ;
150162 return ;
163+ }
151164 GD . Print ( "Note Hit. Dif: " + beatDif ) ;
152165 CM . HandleNote ( type ) ;
153166 handleTiming ( type , beatDif ) ;
154167 }
168+
169+ private void PlayerAddNote ( NoteArrow . ArrowType type , int beat )
170+ {
171+ //TODO: notes currently can only be placed in first loop.
172+ // placed notes are also non-interactable
173+
174+ // can also add some sort of keybind here to also have pressed
175+ // in case the user just presses the note too early and spawns a note
176+ GD . Print (
177+ $ "Player trying to place { type } typed note at beat: "
178+ + beat
179+ + " Verdict: "
180+ + NotePlacementBar . CanPlaceNote ( )
181+ ) ;
182+ if ( NotePlacementBar . CanPlaceNote ( ) )
183+ {
184+ CM . CreateNote ( type , beat ) ;
185+ NotePlacementBar . PlacedNote ( ) ;
186+ }
187+ }
155188}
0 commit comments