1010 */
1111public partial class BattleDirector : Node2D
1212{
13+ #region Declarations
1314 private HealthBar Player ;
1415 private HealthBar Enemy ;
1516
@@ -37,7 +38,9 @@ public struct SongData
3738 public double SongLength ;
3839 public int NumLoops ;
3940 }
41+ #endregion
4042
43+ #region Note Handling
4144 //Assume queue structure for notes in each lane.
4245 //Can eventually make this its own structure
4346 private readonly NoteArrow [ ] [ ] _laneData = new NoteArrow [ ] [ ]
@@ -72,6 +75,36 @@ private Note GetNote(NoteArrow arrow)
7275 return _notes [ arrow . NoteIdx ] ;
7376 }
7477
78+ private bool AddNoteToLane ( Note note )
79+ {
80+ //Don't add dupe notes
81+ if ( _notes . Any ( nt => nt . Type == note . Type && nt . Beat == note . Beat ) )
82+ {
83+ return false ;
84+ }
85+ _notes = _notes . Append ( note ) . ToArray ( ) ;
86+ //Get noteArrow from CM
87+ var arrow = CM . AddArrowToLane ( note , _notes . Length - 1 ) ;
88+ _laneData [ ( int ) note . Type ] = _laneData [ ( int ) note . Type ] . Append ( arrow ) . ToArray ( ) ;
89+ return true ;
90+ }
91+ #endregion
92+
93+ //Creeate dummy notes
94+ private void AddExampleNote ( )
95+ {
96+ for ( int i = 0 ; i < 4 ; i ++ )
97+ {
98+ Note exampleNote = new Note ( NoteArrow . ArrowType . Up , i + 3 ) ;
99+ AddNoteToLane ( exampleNote ) ;
100+ }
101+ for ( int i = 0 ; i < 1 ; i ++ )
102+ {
103+ Note exampleNote = new Note ( NoteArrow . ArrowType . Left , i + 4 ) ;
104+ AddNoteToLane ( exampleNote ) ;
105+ }
106+ }
107+
75108 public override void _Ready ( )
76109 {
77110 _curSong = new SongData
@@ -97,34 +130,7 @@ public override void _Process(double delta)
97130 CheckMiss ( ) ;
98131 }
99132
100- //Creeate dummy notes
101- private void AddExampleNote ( )
102- {
103- for ( int i = 0 ; i < 4 ; i ++ )
104- {
105- Note exampleNote = new Note ( NoteArrow . ArrowType . Up , i + 3 ) ;
106- AddNoteToLane ( exampleNote ) ;
107- }
108- for ( int i = 0 ; i < 1 ; i ++ )
109- {
110- Note exampleNote = new Note ( NoteArrow . ArrowType . Left , i + 4 ) ;
111- AddNoteToLane ( exampleNote ) ;
112- }
113- }
114-
115- private bool AddNoteToLane ( Note note )
116- {
117- //Don't add dupe notes
118- if ( _notes . Any ( nt => nt . Type == note . Type && nt . Beat == note . Beat ) )
119- {
120- return false ;
121- }
122- _notes = _notes . Append ( note ) . ToArray ( ) ;
123- //Get noteArrow from CM
124- var arrow = CM . AddArrowToLane ( note , _notes . Length - 1 ) ;
125- _laneData [ ( int ) note . Type ] = _laneData [ ( int ) note . Type ] . Append ( arrow ) . ToArray ( ) ;
126- return true ;
127- }
133+ #region Input
128134
129135 private void OnNotePressed ( NoteArrow . ArrowType type )
130136 {
@@ -149,6 +155,19 @@ private void CheckMiss()
149155 }
150156 }
151157
158+ private void CheckNoteTiming ( NoteArrow . ArrowType type )
159+ {
160+ double curBeat = TimeKeeper . CurrentTime / ( 60 / ( double ) _curSong . Bpm ) ;
161+ if ( _laneData [ ( int ) type ] . Length == 0 )
162+ return ;
163+ double beatDif = Math . Abs ( curBeat - GetFirstNote ( type ) . Beat ) ;
164+ if ( beatDif > 1 )
165+ return ;
166+ GD . Print ( "Note Hit. Dif: " + beatDif ) ;
167+ _laneData [ ( int ) type ] . First ( ) . NoteHit ( ) ;
168+ HandleTiming ( type , beatDif ) ;
169+ }
170+
152171 private void HandleTiming ( NoteArrow . ArrowType type , double beatDif )
153172 {
154173 //Cycle note queue
@@ -179,25 +198,7 @@ private void HandleTiming(NoteArrow.ArrowType type, double beatDif)
179198 NotePlacementBar . MissNote ( ) ;
180199 }
181200 }
182-
183- private void CheckNoteTiming ( NoteArrow . ArrowType type )
184- {
185- double curBeat = TimeKeeper . CurrentTime / ( 60 / ( double ) _curSong . Bpm ) ;
186- if ( _laneData [ ( int ) type ] . Length == 0 )
187- {
188- PlayerAddNote ( type , ( int ) curBeat ) ;
189- return ;
190- }
191- double beatDif = Math . Abs ( curBeat - GetFirstNote ( type ) . Beat ) ;
192- if ( beatDif > 1 )
193- {
194- PlayerAddNote ( type , ( int ) curBeat ) ;
195- return ;
196- }
197- GD . Print ( "Note Hit. Dif: " + beatDif ) ;
198- _laneData [ ( int ) type ] . First ( ) . NoteHit ( ) ;
199- HandleTiming ( type , beatDif ) ;
200- }
201+ #endregion
201202
202203 private void PlayerAddNote ( NoteArrow . ArrowType type , int beat )
203204 {
0 commit comments