1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 07:53:06 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Objects/Drawables/DrawableCatchHitObject.cs

114 lines
3.4 KiB
C#
Raw Normal View History

// 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.
2018-04-13 17:19:50 +08:00
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
2018-04-13 17:19:50 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects;
2018-04-13 17:19:50 +08:00
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
2020-02-19 13:31:14 +08:00
using osuTK;
using osuTK.Graphics;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Rulesets.Catch.Objects.Drawables
2018-04-13 17:19:50 +08:00
{
public abstract class PalpableCatchHitObject<TObject> : DrawableCatchHitObject<TObject>
where TObject : CatchHitObject
{
public override bool CanBePlated => true;
2020-02-21 09:01:38 +08:00
protected Container ScaleContainer { get; private set; }
2018-04-13 17:19:50 +08:00
protected PalpableCatchHitObject(TObject hitObject)
: base(hitObject)
{
2020-02-19 13:31:14 +08:00
Origin = Anchor.Centre;
Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2);
Masking = false;
2018-04-13 17:19:50 +08:00
}
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Drawable[]
{
ScaleContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
}
});
ScaleContainer.Scale = new Vector2(HitObject.Scale);
}
protected override Color4 GetComboColour(IReadOnlyList<Color4> comboColours) =>
comboColours[(HitObject.IndexInBeatmap + 1) % comboColours.Count];
2018-04-13 17:19:50 +08:00
}
public abstract class DrawableCatchHitObject<TObject> : DrawableCatchHitObject
where TObject : CatchHitObject
{
public new TObject HitObject;
protected DrawableCatchHitObject(TObject hitObject)
: base(hitObject)
{
HitObject = hitObject;
Anchor = Anchor.BottomLeft;
}
}
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
{
public virtual bool CanBePlated => false;
public virtual bool StaysOnPlate => CanBePlated;
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
2018-04-13 17:19:50 +08:00
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{
RelativePositionAxes = Axes.X;
X = hitObject.X;
}
public Func<CatchHitObject, bool> CheckPosition;
public bool IsOnPlate;
public override bool RemoveWhenNotAlive => IsOnPlate;
protected override void CheckForResult(bool userTriggered, double timeOffset)
2018-04-13 17:19:50 +08:00
{
if (CheckPosition == null) return;
if (timeOffset >= 0 && Result != null)
ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss);
2018-04-13 17:19:50 +08:00
}
protected override void UpdateStateTransforms(ArmedState state)
{
var endTime = HitObject.GetEndTime();
2018-04-13 17:19:50 +08:00
using (BeginAbsoluteSequence(endTime, true))
{
switch (state)
{
case ArmedState.Miss:
2019-09-12 18:29:08 +08:00
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
2018-04-13 17:19:50 +08:00
break;
2019-04-01 11:44:46 +08:00
2018-04-13 17:19:50 +08:00
case ArmedState.Hit:
2019-09-12 18:29:08 +08:00
this.FadeOut();
2018-04-13 17:19:50 +08:00
break;
}
}
}
}
}