2019-01-24 16:43:03 +08:00
|
|
|
|
// 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;
|
2020-02-19 16:28:40 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using osu.Framework.Allocation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2020-02-19 16:28:40 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2020-07-01 23:21:45 +08:00
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2020-11-04 15:19:07 +08:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
2020-02-19 13:31:14 +08:00
|
|
|
|
using osuTK;
|
2020-02-19 16:28:40 +08:00
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-02-19 17:01:59 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-08-21 00:41:08 +08:00
|
|
|
|
public abstract class PalpableDrawableCatchHitObject<TObject> : DrawableCatchHitObject<TObject>
|
2020-08-21 00:48:01 +08:00
|
|
|
|
where TObject : PalpableCatchHitObject
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-02-21 09:01:38 +08:00
|
|
|
|
protected Container ScaleContainer { get; private set; }
|
2020-02-19 16:28:40 +08:00
|
|
|
|
|
2020-08-21 00:41:08 +08:00
|
|
|
|
protected PalpableDrawableCatchHitObject(TObject hitObject)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
: 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
|
|
|
|
}
|
2020-02-19 16:28:40 +08:00
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
2020-02-19 17:01:59 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2020-02-19 16:28:40 +08:00
|
|
|
|
{
|
|
|
|
|
ScaleContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ScaleContainer.Scale = new Vector2(HitObject.Scale);
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-20 14:37:15 +08:00
|
|
|
|
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>
|
|
|
|
|
{
|
2020-11-03 17:45:18 +08:00
|
|
|
|
protected override double InitialLifetimeOffset => HitObject.TimePreempt;
|
|
|
|
|
|
2020-08-21 00:48:01 +08:00
|
|
|
|
public virtual bool StaysOnPlate => HitObject.CanBePlated;
|
2018-06-15 14:44:47 +08:00
|
|
|
|
|
2020-02-19 16:28:40 +08:00
|
|
|
|
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
|
|
|
|
|
|
2020-07-01 23:21:45 +08:00
|
|
|
|
protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH;
|
2020-04-12 07:33:25 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
protected DrawableCatchHitObject(CatchHitObject hitObject)
|
|
|
|
|
: base(hitObject)
|
|
|
|
|
{
|
|
|
|
|
X = hitObject.X;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Func<CatchHitObject, bool> CheckPosition;
|
|
|
|
|
|
2019-09-07 23:10:31 +08:00
|
|
|
|
public bool IsOnPlate;
|
|
|
|
|
|
|
|
|
|
public override bool RemoveWhenNotAlive => IsOnPlate;
|
|
|
|
|
|
2018-08-06 10:31:46 +08:00
|
|
|
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
if (CheckPosition == null) return;
|
|
|
|
|
|
2018-08-03 14:38:48 +08:00
|
|
|
|
if (timeOffset >= 0 && Result != null)
|
2020-09-29 13:26:36 +08:00
|
|
|
|
ApplyResult(r => r.Type = CheckPosition.Invoke(HitObject) ? r.Judgement.MaxResult : r.Judgement.MinResult);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
protected override void UpdateHitStateTransforms(ArmedState state)
|
2019-08-26 20:15:23 +08:00
|
|
|
|
{
|
2020-11-04 15:19:07 +08:00
|
|
|
|
switch (state)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-11-04 15:19:07 +08:00
|
|
|
|
case ArmedState.Miss:
|
|
|
|
|
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
|
|
|
|
|
break;
|
2019-04-01 11:44:46 +08:00
|
|
|
|
|
2020-11-04 15:19:07 +08:00
|
|
|
|
case ArmedState.Hit:
|
|
|
|
|
this.FadeOut();
|
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|