forked from ppy/osu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDrawablePippidonHitObject.cs
More file actions
77 lines (65 loc) · 2.46 KB
/
Copy pathDrawablePippidonHitObject.cs
File metadata and controls
77 lines (65 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Game.Audio;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Pippidon.UI;
using Vector2 = System.Numerics.Vector2;
namespace osu.Game.Rulesets.Pippidon.Objects.Drawables
{
public partial class DrawablePippidonHitObject : DrawableHitObject<PippidonHitObject>
{
private BindableNumber<int> currentLane;
public DrawablePippidonHitObject(PippidonHitObject hitObject)
: base(hitObject)
{
Size = new Vector2(40);
Origin = Anchor.Centre;
Y = hitObject.Lane * PippidonPlayfield.LANE_HEIGHT;
}
[BackgroundDependencyLoader]
private void load(PippidonPlayfield playfield, TextureStore textures)
{
AddInternal(new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get("coin"),
});
currentLane = playfield.CurrentLane.GetBoundCopy();
}
public override IEnumerable<HitSampleInfo> GetSamples() => new[]
{
new HitSampleInfo(HitSampleInfo.HIT_NORMAL)
};
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
if (timeOffset >= 0)
{
if (currentLane.Value == HitObject.Lane)
ApplyMaxResult();
else
ApplyMinResult();
}
}
protected override void UpdateHitStateTransforms(ArmedState state)
{
switch (state)
{
case ArmedState.Hit:
this.ScaleTo(5, 1500, Easing.OutQuint).FadeOut(1500, Easing.OutQuint).Expire();
break;
case ArmedState.Miss:
const double duration = 1000;
this.ScaleTo(0.8f, duration, Easing.OutQuint);
this.MoveToOffset(new Vector2(0, 10), duration, Easing.In);
this.FadeColour(Colour4.Red, duration / 2, Easing.OutQuint).Then().FadeOut(duration / 2, Easing.InQuint).Expire();
break;
}
}
}
}