@@ -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
0 commit comments