2017-02-07 12:59:30 +08:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
2016-11-14 17:03:20 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-08-03 07:32:38 +08:00
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-08-03 07:32:38 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-08-02 18:37:20 +08:00
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.MathUtils;
|
2017-08-03 07:32:38 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2017-08-02 18:37:20 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.Judgements;
|
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using OpenTK;
|
2017-08-03 07:32:38 +08:00
|
|
|
|
using OpenTK.Graphics;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2017-08-08 09:35:56 +08:00
|
|
|
|
internal class DrawableFruit : DrawableScrollingHitObject<CatchBaseHit, CatchJudgement>
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2017-08-08 09:36:05 +08:00
|
|
|
|
private Box box;
|
|
|
|
|
|
2017-08-03 07:32:38 +08:00
|
|
|
|
private class Pulp : Circle, IHasAccentColour
|
|
|
|
|
{
|
|
|
|
|
public Pulp()
|
|
|
|
|
{
|
|
|
|
|
EdgeEffect = new EdgeEffectParameters
|
|
|
|
|
{
|
|
|
|
|
Type = EdgeEffectType.Glow,
|
|
|
|
|
Radius = 5,
|
|
|
|
|
Colour = AccentColour.Opacity(0.5f),
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Color4 AccentColour { get; set; } = Color4.White;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2017-08-02 18:37:20 +08:00
|
|
|
|
public DrawableFruit(CatchBaseHit h) : base(h)
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre;
|
2017-08-02 18:37:20 +08:00
|
|
|
|
Size = new Vector2(50);
|
2017-08-08 09:35:56 +08:00
|
|
|
|
|
2017-08-02 18:37:20 +08:00
|
|
|
|
RelativePositionAxes = Axes.Both;
|
2017-08-08 09:35:56 +08:00
|
|
|
|
X = h.Position;
|
2017-08-02 18:37:20 +08:00
|
|
|
|
|
2017-08-08 09:35:56 +08:00
|
|
|
|
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
2017-08-02 18:37:20 +08:00
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
2017-08-08 09:36:05 +08:00
|
|
|
|
box = new Box
|
2017-08-07 15:02:14 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2017-08-08 09:36:05 +08:00
|
|
|
|
Colour = Color4.Blue,
|
2017-08-07 15:02:14 +08:00
|
|
|
|
},
|
2017-08-03 07:32:38 +08:00
|
|
|
|
new Pulp
|
2017-08-02 18:37:20 +08:00
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0.12f),
|
|
|
|
|
Y = 0.08f,
|
|
|
|
|
},
|
2017-08-03 07:32:38 +08:00
|
|
|
|
new Pulp
|
2017-08-02 18:37:20 +08:00
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0.32f),
|
|
|
|
|
Position = new Vector2(-0.16f, 0.3f),
|
|
|
|
|
},
|
2017-08-03 07:32:38 +08:00
|
|
|
|
new Pulp
|
2017-08-02 18:37:20 +08:00
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0.32f),
|
|
|
|
|
Position = new Vector2(0.16f, 0.3f),
|
|
|
|
|
},
|
2017-08-03 07:32:38 +08:00
|
|
|
|
new Pulp
|
2017-08-02 18:37:20 +08:00
|
|
|
|
{
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Scale = new Vector2(0.32f),
|
|
|
|
|
Position = new Vector2(0, 0.6f),
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override CatchJudgement CreateJudgement() => new CatchJudgement();
|
|
|
|
|
|
|
|
|
|
private const float preempt = 1000;
|
|
|
|
|
|
2017-08-08 09:36:05 +08:00
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (Judgement.TimeOffset > 0)
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
|
2017-08-02 18:37:20 +08:00
|
|
|
|
protected override void UpdateState(ArmedState state)
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2017-08-02 18:37:20 +08:00
|
|
|
|
using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
|
|
|
|
|
{
|
|
|
|
|
// animation
|
2017-08-08 09:35:56 +08:00
|
|
|
|
this.FadeIn(200);
|
2017-08-02 18:37:20 +08:00
|
|
|
|
}
|
2017-08-08 09:36:05 +08:00
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
using (BeginAbsoluteSequence(HitObject.StartTime, true))
|
|
|
|
|
{
|
|
|
|
|
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
|
|
|
|
|
box.FadeColour(Color4.OrangeRed);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
2016-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|