mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:03:11 +08:00
Create an abstract base class for drawable catch objects
This commit is contained in:
parent
b1a2da58bc
commit
26215b4488
@ -0,0 +1,50 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||||
|
{
|
||||||
|
public abstract class DrawableCatchHitObject : DrawableScrollingHitObject<CatchBaseHit>
|
||||||
|
{
|
||||||
|
protected DrawableCatchHitObject(CatchBaseHit hitObject)
|
||||||
|
: base(hitObject)
|
||||||
|
{
|
||||||
|
Origin = Anchor.Centre;
|
||||||
|
RelativePositionAxes = Axes.Both;
|
||||||
|
X = hitObject.X;
|
||||||
|
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Func<CatchBaseHit, bool> CheckPosition;
|
||||||
|
|
||||||
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
||||||
|
{
|
||||||
|
if (timeOffset > 0)
|
||||||
|
AddJudgement(new Judgement { Result = CheckPosition?.Invoke(HitObject) ?? false ? HitResult.Perfect : HitResult.Miss });
|
||||||
|
}
|
||||||
|
|
||||||
|
private const float preempt = 1000;
|
||||||
|
|
||||||
|
protected override void UpdateState(ArmedState state)
|
||||||
|
{
|
||||||
|
using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
|
||||||
|
{
|
||||||
|
// animation
|
||||||
|
this.FadeIn(200);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case ArmedState.Miss:
|
||||||
|
using (BeginAbsoluteSequence(HitObject.StartTime, true))
|
||||||
|
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,72 +1,29 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.MathUtils;
|
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Rulesets.Judgements;
|
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
||||||
{
|
{
|
||||||
public class DrawableFruit : DrawableScrollingHitObject<CatchBaseHit>
|
public class DrawableFruit : DrawableCatchHitObject
|
||||||
{
|
{
|
||||||
private const float pulp_size = 20;
|
private const float pulp_size = 20;
|
||||||
|
|
||||||
private class Pulp : Circle, IHasAccentColour
|
|
||||||
{
|
|
||||||
public Pulp()
|
|
||||||
{
|
|
||||||
Size = new Vector2(pulp_size);
|
|
||||||
|
|
||||||
Blending = BlendingMode.Additive;
|
|
||||||
Colour = Color4.White.Opacity(0.9f);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Color4 accentColour;
|
|
||||||
public Color4 AccentColour
|
|
||||||
{
|
|
||||||
get { return accentColour; }
|
|
||||||
set
|
|
||||||
{
|
|
||||||
accentColour = value;
|
|
||||||
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Radius = 5,
|
|
||||||
Colour = accentColour.Lighten(100),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public DrawableFruit(CatchBaseHit h)
|
public DrawableFruit(CatchBaseHit h)
|
||||||
: base(h)
|
: base(h)
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre;
|
|
||||||
Size = new Vector2(pulp_size * 2.2f, pulp_size * 2.8f);
|
Size = new Vector2(pulp_size * 2.2f, pulp_size * 2.8f);
|
||||||
|
|
||||||
RelativePositionAxes = Axes.Both;
|
|
||||||
X = h.X;
|
|
||||||
|
|
||||||
AccentColour = HitObject.ComboColour;
|
AccentColour = HitObject.ComboColour;
|
||||||
|
|
||||||
Masking = false;
|
Masking = false;
|
||||||
|
|
||||||
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Func<CatchBaseHit, bool> CheckPosition;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
@ -115,28 +72,31 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private const float preempt = 1000;
|
private class Pulp : Circle, IHasAccentColour
|
||||||
|
|
||||||
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
|
||||||
{
|
{
|
||||||
if (timeOffset > 0)
|
public Pulp()
|
||||||
AddJudgement(new Judgement { Result = CheckPosition?.Invoke(HitObject) ?? false ? HitResult.Perfect : HitResult.Miss });
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void UpdateState(ArmedState state)
|
|
||||||
{
|
|
||||||
using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
|
|
||||||
{
|
{
|
||||||
// animation
|
Size = new Vector2(pulp_size);
|
||||||
this.FadeIn(200);
|
|
||||||
|
Blending = BlendingMode.Additive;
|
||||||
|
Colour = Color4.White.Opacity(0.9f);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state)
|
private Color4 accentColour;
|
||||||
|
public Color4 AccentColour
|
||||||
{
|
{
|
||||||
case ArmedState.Miss:
|
get { return accentColour; }
|
||||||
using (BeginAbsoluteSequence(HitObject.StartTime, true))
|
set
|
||||||
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
|
{
|
||||||
break;
|
accentColour = value;
|
||||||
|
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Radius = 5,
|
||||||
|
Colour = accentColour.Lighten(100),
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,7 @@
|
|||||||
<Compile Include="Beatmaps\CatchBeatmapProcessor.cs" />
|
<Compile Include="Beatmaps\CatchBeatmapProcessor.cs" />
|
||||||
<Compile Include="CatchDifficultyCalculator.cs" />
|
<Compile Include="CatchDifficultyCalculator.cs" />
|
||||||
<Compile Include="CatchInputManager.cs" />
|
<Compile Include="CatchInputManager.cs" />
|
||||||
|
<Compile Include="Objects\Drawable\DrawableCatchHitObject.cs" />
|
||||||
<Compile Include="Scoring\CatchScoreProcessor.cs" />
|
<Compile Include="Scoring\CatchScoreProcessor.cs" />
|
||||||
<Compile Include="Judgements\CatchJudgement.cs" />
|
<Compile Include="Judgements\CatchJudgement.cs" />
|
||||||
<Compile Include="Objects\CatchBaseHit.cs" />
|
<Compile Include="Objects\CatchBaseHit.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user