7
7
using osu . Framework . Graphics ;
8
8
using osu . Framework . Graphics . Containers ;
9
9
using osu . Framework . Graphics . Shapes ;
10
+ using osu . Framework . Graphics . Sprites ;
10
11
using osu . Framework . Graphics . Textures ;
11
12
using osu . Framework . Input . Bindings ;
12
13
using osu . Game . Rulesets . Judgements ;
13
14
using osu . Game . Rulesets . Objects . Drawables ;
15
+ using osu . Game . Rulesets . Rush . Judgements ;
14
16
using osu . Game . Rulesets . Rush . Objects ;
15
17
using osu . Game . Rulesets . Rush . Objects . Drawables ;
16
18
using osu . Game . Rulesets . UI ;
@@ -37,6 +39,7 @@ public class RushPlayfield : ScrollingPlayfield, IKeyBindingHandler<RushAction>
37
39
private readonly Container underEffectContainer ;
38
40
private readonly Container overEffectContainer ;
39
41
private readonly Container halfPaddingOverEffectContainer ;
42
+ private readonly Container overPlayerEffectsContainer ;
40
43
private readonly JudgementContainer < DrawableRushJudgement > judgementContainer ;
41
44
42
45
public RushPlayfield ( )
@@ -81,7 +84,7 @@ public RushPlayfield()
81
84
RelativeSizeAxes = Axes . Both ,
82
85
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET }
83
86
} ,
84
- judgementContainer = new JudgementContainer < DrawableRushJudgement > ( )
87
+ judgementContainer = new JudgementContainer < DrawableRushJudgement >
85
88
{
86
89
Name = "Judgement" ,
87
90
RelativeSizeAxes = Axes . Both ,
@@ -102,7 +105,7 @@ public RushPlayfield()
102
105
} ,
103
106
halfPaddingOverEffectContainer = new Container
104
107
{
105
- Name = "Over Effects (No Padding)" ,
108
+ Name = "Over Effects (Half Padding)" ,
106
109
RelativeSizeAxes = Axes . Both ,
107
110
Padding = new MarginPadding { Left = HIT_TARGET_OFFSET / 2f }
108
111
}
@@ -130,6 +133,12 @@ public RushPlayfield()
130
133
Position = new Vector2 ( PLAYER_OFFSET , DEFAULT_HEIGHT ) ,
131
134
Scale = new Vector2 ( 0.75f ) ,
132
135
} ,
136
+ overPlayerEffectsContainer = new Container
137
+ {
138
+ Origin = Anchor . Centre ,
139
+ Anchor = Anchor . Centre ,
140
+ RelativeSizeAxes = Axes . Both ,
141
+ }
133
142
}
134
143
}
135
144
}
@@ -178,6 +187,9 @@ private void onMiniBossAttacked(DrawableMiniBoss drawableMiniBoss, double timeOf
178
187
private void onNewResult ( DrawableHitObject judgedObject , JudgementResult result )
179
188
{
180
189
DrawableRushHitObject rushJudgedObject = ( DrawableRushHitObject ) judgedObject ;
190
+ int healthAmount = ( int ) ( ( result . Judgement as RushJudgement ) ? . HealthPoints ?? 0 ) ;
191
+ var healthPosition = new Vector2 ( overPlayerEffectsContainer . DrawWidth * 0.75f , overPlayerEffectsContainer . DrawHeight * 0.5f ) ;
192
+
181
193
PlayerSprite . HandleResult ( rushJudgedObject , result ) ;
182
194
183
195
const float animation_time = 200f ;
@@ -233,9 +245,25 @@ private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
233
245
underEffectContainer . Add ( explosion ) ;
234
246
explosion . ScaleTo ( 0.5f , 200f ) . FadeOutFromOne ( 200f ) . OnComplete ( d => d . Expire ( ) ) ;
235
247
}
236
- else
248
+ else if ( PlayerSprite . CollidesWith ( result . HitObject ) )
237
249
{
238
- // TODO: ouch!!!
250
+ var damageText = new SpriteText
251
+ {
252
+ Origin = Anchor . Centre ,
253
+ Colour = Color4 . Red ,
254
+ Font = FontUsage . Default . With ( size : 40 ) ,
255
+ Scale = new Vector2 ( 1.2f ) ,
256
+ Text = $ "{ healthAmount : D} ",
257
+ Position = healthPosition ,
258
+ } ;
259
+
260
+ overPlayerEffectsContainer . Add ( damageText ) ;
261
+
262
+ damageText . ScaleTo ( 1f , animation_time )
263
+ . Then ( )
264
+ . FadeOutFromOne ( animation_time )
265
+ . MoveToOffset ( new Vector2 ( 0f , - 20f ) , animation_time )
266
+ . OnComplete ( d => d . Expire ( ) ) ;
239
267
}
240
268
241
269
break ;
@@ -249,12 +277,30 @@ private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
249
277
Scale = new Vector2 ( 0.5f )
250
278
} ;
251
279
280
+ var healthIncrease = new SpriteText
281
+ {
282
+ Origin = Anchor . Centre ,
283
+ Colour = Color4 . Green ,
284
+ Font = FontUsage . Default . With ( size : 40 ) ,
285
+ Scale = new Vector2 ( 1.2f ) ,
286
+ Text = $ "+{ healthAmount : D} ",
287
+ Position = healthPosition ,
288
+ } ;
289
+
252
290
overEffectContainer . Add ( heartFlash ) ;
253
291
254
292
heartFlash . ScaleTo ( 1.25f , animation_time )
255
293
. FadeOutFromOne ( animation_time )
256
294
. OnComplete ( d => d . Expire ( ) ) ;
257
295
296
+ overPlayerEffectsContainer . Add ( healthIncrease ) ;
297
+
298
+ healthIncrease . ScaleTo ( 1f , animation_time )
299
+ . Then ( )
300
+ . FadeOutFromOne ( animation_time )
301
+ . MoveToOffset ( new Vector2 ( 0f , - 20f ) , animation_time )
302
+ . OnComplete ( d => d . Expire ( ) ) ;
303
+
258
304
// TODO: green floating plus signs
259
305
260
306
break ;
0 commit comments