mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 16:12:54 +08:00
Merge branch 'master' into tournament-resolution-selector
This commit is contained in:
commit
70a17ae6cc
@ -23,7 +23,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
SetContents(() => new CatcherArea.Catcher
|
SetContents(() => new Catcher
|
||||||
{
|
{
|
||||||
RelativePositionAxes = Axes.None,
|
RelativePositionAxes = Axes.None,
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
{
|
{
|
||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(CatcherArea.Catcher),
|
typeof(Catcher),
|
||||||
typeof(DrawableCatchRuleset),
|
typeof(DrawableCatchRuleset),
|
||||||
typeof(DrawableFruit),
|
typeof(DrawableFruit),
|
||||||
typeof(DrawableJuiceStream),
|
typeof(DrawableJuiceStream),
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CatcherArea.Catcher getCatcher() => Player.ChildrenOfType<CatcherArea>().First().MovableCatcher;
|
private Catcher getCatcher() => Player.ChildrenOfType<CatcherArea>().First().MovableCatcher;
|
||||||
|
|
||||||
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset)
|
||||||
{
|
{
|
||||||
|
@ -227,7 +227,7 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
|
|||||||
int thisDirection = nextObject.X > currentObject.X ? 1 : -1;
|
int thisDirection = nextObject.X > currentObject.X ? 1 : -1;
|
||||||
double timeToNext = nextObject.StartTime - currentObject.StartTime - 1000f / 60f / 4; // 1/4th of a frame of grace time, taken from osu-stable
|
double timeToNext = nextObject.StartTime - currentObject.StartTime - 1000f / 60f / 4; // 1/4th of a frame of grace time, taken from osu-stable
|
||||||
double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth);
|
double distanceToNext = Math.Abs(nextObject.X - currentObject.X) - (lastDirection == thisDirection ? lastExcess : halfCatcherWidth);
|
||||||
float distanceToHyper = (float)(timeToNext * CatcherArea.Catcher.BASE_SPEED - distanceToNext);
|
float distanceToHyper = (float)(timeToNext * Catcher.BASE_SPEED - distanceToNext);
|
||||||
|
|
||||||
if (distanceToHyper < 0)
|
if (distanceToHyper < 0)
|
||||||
{
|
{
|
||||||
|
@ -23,6 +23,8 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
|
|
||||||
protected override int SectionLength => 750;
|
protected override int SectionLength => 750;
|
||||||
|
|
||||||
|
private float halfCatcherWidth;
|
||||||
|
|
||||||
public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
public CatchDifficultyCalculator(Ruleset ruleset, WorkingBeatmap beatmap)
|
||||||
: base(ruleset, beatmap)
|
: base(ruleset, beatmap)
|
||||||
{
|
{
|
||||||
@ -48,14 +50,6 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
|
|
||||||
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
protected override IEnumerable<DifficultyHitObject> CreateDifficultyHitObjects(IBeatmap beatmap, double clockRate)
|
||||||
{
|
{
|
||||||
float halfCatchWidth;
|
|
||||||
|
|
||||||
using (var catcher = new CatcherArea.Catcher(beatmap.BeatmapInfo.BaseDifficulty))
|
|
||||||
{
|
|
||||||
halfCatchWidth = catcher.CatchWidth * 0.5f;
|
|
||||||
halfCatchWidth *= 0.8f; // We're only using 80% of the catcher's width to simulate imperfect gameplay.
|
|
||||||
}
|
|
||||||
|
|
||||||
CatchHitObject lastObject = null;
|
CatchHitObject lastObject = null;
|
||||||
|
|
||||||
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
|
// In 2B beatmaps, it is possible that a normal Fruit is placed in the middle of a JuiceStream.
|
||||||
@ -69,16 +63,25 @@ namespace osu.Game.Rulesets.Catch.Difficulty
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (lastObject != null)
|
if (lastObject != null)
|
||||||
yield return new CatchDifficultyHitObject(hitObject, lastObject, clockRate, halfCatchWidth);
|
yield return new CatchDifficultyHitObject(hitObject, lastObject, clockRate, halfCatcherWidth);
|
||||||
|
|
||||||
lastObject = hitObject;
|
lastObject = hitObject;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Skill[] CreateSkills(IBeatmap beatmap) => new Skill[]
|
protected override Skill[] CreateSkills(IBeatmap beatmap)
|
||||||
{
|
{
|
||||||
new Movement(),
|
using (var catcher = new Catcher(beatmap.BeatmapInfo.BaseDifficulty))
|
||||||
};
|
{
|
||||||
|
halfCatcherWidth = catcher.CatchWidth * 0.5f;
|
||||||
|
halfCatcherWidth *= 0.8f; // We're only using 80% of the catcher's width to simulate imperfect gameplay.
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Skill[]
|
||||||
|
{
|
||||||
|
new Movement(halfCatcherWidth),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
protected override Mod[] DifficultyAdjustmentMods => new Mod[]
|
||||||
{
|
{
|
||||||
|
@ -20,9 +20,16 @@ namespace osu.Game.Rulesets.Catch.Difficulty.Skills
|
|||||||
|
|
||||||
protected override double DecayWeight => 0.94;
|
protected override double DecayWeight => 0.94;
|
||||||
|
|
||||||
|
protected readonly float HalfCatcherWidth;
|
||||||
|
|
||||||
private float? lastPlayerPosition;
|
private float? lastPlayerPosition;
|
||||||
private float lastDistanceMoved;
|
private float lastDistanceMoved;
|
||||||
|
|
||||||
|
public Movement(float halfCatcherWidth)
|
||||||
|
{
|
||||||
|
HalfCatcherWidth = halfCatcherWidth;
|
||||||
|
}
|
||||||
|
|
||||||
protected override double StrainValueOf(DifficultyHitObject current)
|
protected override double StrainValueOf(DifficultyHitObject current)
|
||||||
{
|
{
|
||||||
var catchCurrent = (CatchDifficultyHitObject)current;
|
var catchCurrent = (CatchDifficultyHitObject)current;
|
||||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
|
|
||||||
private class MouseInputHelper : Drawable, IKeyBindingHandler<CatchAction>, IRequireHighFrequencyMousePosition
|
private class MouseInputHelper : Drawable, IKeyBindingHandler<CatchAction>, IRequireHighFrequencyMousePosition
|
||||||
{
|
{
|
||||||
private readonly CatcherArea.Catcher catcher;
|
private readonly Catcher catcher;
|
||||||
|
|
||||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Catch.Replays
|
|||||||
public override Replay Generate()
|
public override Replay Generate()
|
||||||
{
|
{
|
||||||
// todo: add support for HT DT
|
// todo: add support for HT DT
|
||||||
const double dash_speed = CatcherArea.Catcher.BASE_SPEED;
|
const double dash_speed = Catcher.BASE_SPEED;
|
||||||
const double movement_speed = dash_speed / 2;
|
const double movement_speed = dash_speed / 2;
|
||||||
float lastPosition = 0.5f;
|
float lastPosition = 0.5f;
|
||||||
double lastTime = 0;
|
double lastTime = 0;
|
||||||
|
460
osu.Game.Rulesets.Catch/UI/Catcher.cs
Normal file
460
osu.Game.Rulesets.Catch/UI/Catcher.cs
Normal file
@ -0,0 +1,460 @@
|
|||||||
|
// 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;
|
||||||
|
using System.Linq;
|
||||||
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Animations;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.UI
|
||||||
|
{
|
||||||
|
public class Catcher : Container, IKeyBindingHandler<CatchAction>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we are hyper-dashing or not.
|
||||||
|
/// </summary>
|
||||||
|
public bool HyperDashing => hyperDashModifier != 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The relative space to cover in 1 millisecond. based on 1 game pixel per millisecond as in osu-stable.
|
||||||
|
/// </summary>
|
||||||
|
public const double BASE_SPEED = 1.0 / 512;
|
||||||
|
|
||||||
|
public Container ExplodingFruitTarget;
|
||||||
|
|
||||||
|
public Container AdditiveTarget;
|
||||||
|
|
||||||
|
public CatcherAnimationState CurrentState { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Width of the area that can be used to attempt catches during gameplay.
|
||||||
|
/// </summary>
|
||||||
|
internal float CatchWidth => CatcherArea.CATCHER_SIZE * Math.Abs(Scale.X);
|
||||||
|
|
||||||
|
protected bool Dashing
|
||||||
|
{
|
||||||
|
get => dashing;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == dashing) return;
|
||||||
|
|
||||||
|
dashing = value;
|
||||||
|
|
||||||
|
Trail |= dashing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Activate or deactive the trail. Will be automatically deactivated when conditions to keep the trail displayed are no longer met.
|
||||||
|
/// </summary>
|
||||||
|
protected bool Trail
|
||||||
|
{
|
||||||
|
get => trail;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value == trail) return;
|
||||||
|
|
||||||
|
trail = value;
|
||||||
|
|
||||||
|
if (Trail)
|
||||||
|
beginTrail();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Container<DrawableHitObject> caughtFruit;
|
||||||
|
|
||||||
|
private CatcherSprite catcherIdle;
|
||||||
|
private CatcherSprite catcherKiai;
|
||||||
|
private CatcherSprite catcherFail;
|
||||||
|
|
||||||
|
private int currentDirection;
|
||||||
|
|
||||||
|
private bool dashing;
|
||||||
|
|
||||||
|
private bool trail;
|
||||||
|
|
||||||
|
private double hyperDashModifier = 1;
|
||||||
|
private int hyperDashDirection;
|
||||||
|
private float hyperDashTargetPosition;
|
||||||
|
|
||||||
|
public Catcher(BeatmapDifficulty difficulty = null)
|
||||||
|
{
|
||||||
|
RelativePositionAxes = Axes.X;
|
||||||
|
X = 0.5f;
|
||||||
|
|
||||||
|
Origin = Anchor.TopCentre;
|
||||||
|
|
||||||
|
Size = new Vector2(CatcherArea.CATCHER_SIZE);
|
||||||
|
if (difficulty != null)
|
||||||
|
Scale = new Vector2(1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load()
|
||||||
|
{
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
caughtFruit = new Container<DrawableHitObject>
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Origin = Anchor.BottomCentre,
|
||||||
|
},
|
||||||
|
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
catcherKiai = new CatcherSprite(CatcherAnimationState.Kiai)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Alpha = 0,
|
||||||
|
},
|
||||||
|
catcherFail = new CatcherSprite(CatcherAnimationState.Fail)
|
||||||
|
{
|
||||||
|
Anchor = Anchor.TopCentre,
|
||||||
|
Alpha = 0,
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateCatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Add a caught fruit to the catcher's stack.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fruit">The fruit that was caught.</param>
|
||||||
|
public void PlaceOnPlate(DrawableCatchHitObject fruit)
|
||||||
|
{
|
||||||
|
var ourRadius = fruit.DisplayRadius;
|
||||||
|
float theirRadius = 0;
|
||||||
|
|
||||||
|
const float allowance = 6;
|
||||||
|
|
||||||
|
while (caughtFruit.Any(f =>
|
||||||
|
f.LifetimeEnd == double.MaxValue &&
|
||||||
|
Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2)))
|
||||||
|
{
|
||||||
|
var diff = (ourRadius + theirRadius) / allowance;
|
||||||
|
fruit.X += (RNG.NextSingle() - 0.5f) * 2 * diff;
|
||||||
|
fruit.Y -= RNG.NextSingle() * diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
fruit.X = Math.Clamp(fruit.X, -CatcherArea.CATCHER_SIZE / 2, CatcherArea.CATCHER_SIZE / 2);
|
||||||
|
|
||||||
|
caughtFruit.Add(fruit);
|
||||||
|
|
||||||
|
Add(new HitExplosion(fruit)
|
||||||
|
{
|
||||||
|
X = fruit.X,
|
||||||
|
Scale = new Vector2(fruit.HitObject.Scale)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Let the catcher attempt to catch a fruit.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fruit">The fruit to catch.</param>
|
||||||
|
/// <returns>Whether the catch is possible.</returns>
|
||||||
|
public bool AttemptCatch(CatchHitObject fruit)
|
||||||
|
{
|
||||||
|
var halfCatchWidth = CatchWidth * 0.5f;
|
||||||
|
|
||||||
|
// this stuff wil disappear once we move fruit to non-relative coordinate space in the future.
|
||||||
|
var catchObjectPosition = fruit.X * CatchPlayfield.BASE_WIDTH;
|
||||||
|
var catcherPosition = Position.X * CatchPlayfield.BASE_WIDTH;
|
||||||
|
|
||||||
|
var validCatch =
|
||||||
|
catchObjectPosition >= catcherPosition - halfCatchWidth &&
|
||||||
|
catchObjectPosition <= catcherPosition + halfCatchWidth;
|
||||||
|
|
||||||
|
// only update hyperdash state if we are catching a fruit.
|
||||||
|
// exceptions are Droplets and JuiceStreams.
|
||||||
|
if (!(fruit is Fruit)) return validCatch;
|
||||||
|
|
||||||
|
if (validCatch && fruit.HyperDash)
|
||||||
|
{
|
||||||
|
var target = fruit.HyperDashTarget;
|
||||||
|
var timeDifference = target.StartTime - fruit.StartTime;
|
||||||
|
double positionDifference = target.X * CatchPlayfield.BASE_WIDTH - catcherPosition;
|
||||||
|
var velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
|
||||||
|
|
||||||
|
SetHyperDashState(Math.Abs(velocity), target.X);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SetHyperDashState();
|
||||||
|
|
||||||
|
if (validCatch)
|
||||||
|
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
|
||||||
|
else if (!(fruit is Banana))
|
||||||
|
updateState(CatcherAnimationState.Fail);
|
||||||
|
|
||||||
|
return validCatch;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Set hyper-dash state.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modifier">The speed multiplier. If this is less or equals to 1, this catcher will be non-hyper-dashing state.</param>
|
||||||
|
/// <param name="targetPosition">When this catcher crosses this position, this catcher ends hyper-dashing.</param>
|
||||||
|
public void SetHyperDashState(double modifier = 1, float targetPosition = -1)
|
||||||
|
{
|
||||||
|
const float hyper_dash_transition_length = 180;
|
||||||
|
|
||||||
|
var wasHyperDashing = HyperDashing;
|
||||||
|
|
||||||
|
if (modifier <= 1 || X == targetPosition)
|
||||||
|
{
|
||||||
|
hyperDashModifier = 1;
|
||||||
|
hyperDashDirection = 0;
|
||||||
|
|
||||||
|
if (wasHyperDashing)
|
||||||
|
{
|
||||||
|
this.FadeColour(Color4.White, hyper_dash_transition_length, Easing.OutQuint);
|
||||||
|
this.FadeTo(1, hyper_dash_transition_length, Easing.OutQuint);
|
||||||
|
Trail &= Dashing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
hyperDashModifier = modifier;
|
||||||
|
hyperDashDirection = Math.Sign(targetPosition - X);
|
||||||
|
hyperDashTargetPosition = targetPosition;
|
||||||
|
|
||||||
|
if (!wasHyperDashing)
|
||||||
|
{
|
||||||
|
this.FadeColour(Color4.OrangeRed, hyper_dash_transition_length, Easing.OutQuint);
|
||||||
|
this.FadeTo(0.2f, hyper_dash_transition_length, Easing.OutQuint);
|
||||||
|
Trail = true;
|
||||||
|
|
||||||
|
var hyperDashEndGlow = createAdditiveSprite(true);
|
||||||
|
|
||||||
|
hyperDashEndGlow.MoveToOffset(new Vector2(0, -20), 1200, Easing.In);
|
||||||
|
hyperDashEndGlow.ScaleTo(hyperDashEndGlow.Scale * 0.9f).ScaleTo(hyperDashEndGlow.Scale * 1.2f, 1200, Easing.In);
|
||||||
|
hyperDashEndGlow.FadeOut(1200);
|
||||||
|
hyperDashEndGlow.Expire(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(CatchAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case CatchAction.MoveLeft:
|
||||||
|
currentDirection--;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case CatchAction.MoveRight:
|
||||||
|
currentDirection++;
|
||||||
|
return true;
|
||||||
|
|
||||||
|
case CatchAction.Dash:
|
||||||
|
Dashing = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(CatchAction action)
|
||||||
|
{
|
||||||
|
switch (action)
|
||||||
|
{
|
||||||
|
case CatchAction.MoveLeft:
|
||||||
|
currentDirection++;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CatchAction.MoveRight:
|
||||||
|
currentDirection--;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CatchAction.Dash:
|
||||||
|
Dashing = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void UpdatePosition(float position)
|
||||||
|
{
|
||||||
|
position = Math.Clamp(position, 0, 1);
|
||||||
|
|
||||||
|
if (position == X)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Scale = new Vector2(Math.Abs(Scale.X) * (position > X ? 1 : -1), Scale.Y);
|
||||||
|
X = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drop any fruit off the plate.
|
||||||
|
/// </summary>
|
||||||
|
public void Drop()
|
||||||
|
{
|
||||||
|
foreach (var f in caughtFruit.ToArray())
|
||||||
|
Drop(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Explode any fruit off the plate.
|
||||||
|
/// </summary>
|
||||||
|
public void Explode()
|
||||||
|
{
|
||||||
|
foreach (var f in caughtFruit.ToArray())
|
||||||
|
Explode(f);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Drop(DrawableHitObject fruit)
|
||||||
|
{
|
||||||
|
removeFromPlateWithTransform(fruit, f =>
|
||||||
|
{
|
||||||
|
f.MoveToY(f.Y + 75, 750, Easing.InSine);
|
||||||
|
f.FadeOut(750);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Explode(DrawableHitObject fruit)
|
||||||
|
{
|
||||||
|
var originalX = fruit.X * Scale.X;
|
||||||
|
|
||||||
|
removeFromPlateWithTransform(fruit, f =>
|
||||||
|
{
|
||||||
|
f.MoveToY(f.Y - 50, 250, Easing.OutSine).Then().MoveToY(f.Y + 50, 500, Easing.InSine);
|
||||||
|
f.MoveToX(f.X + originalX * 6, 1000);
|
||||||
|
f.FadeOut(750);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
if (currentDirection == 0) return;
|
||||||
|
|
||||||
|
var direction = Math.Sign(currentDirection);
|
||||||
|
|
||||||
|
var dashModifier = Dashing ? 1 : 0.5;
|
||||||
|
var speed = BASE_SPEED * dashModifier * hyperDashModifier;
|
||||||
|
|
||||||
|
UpdatePosition((float)(X + direction * Clock.ElapsedFrameTime * speed));
|
||||||
|
|
||||||
|
// Correct overshooting.
|
||||||
|
if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) ||
|
||||||
|
(hyperDashDirection < 0 && hyperDashTargetPosition > X))
|
||||||
|
{
|
||||||
|
X = hyperDashTargetPosition;
|
||||||
|
SetHyperDashState();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCatcher()
|
||||||
|
{
|
||||||
|
catcherIdle.Hide();
|
||||||
|
catcherKiai.Hide();
|
||||||
|
catcherFail.Hide();
|
||||||
|
|
||||||
|
CatcherSprite current;
|
||||||
|
|
||||||
|
switch (CurrentState)
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
current = catcherIdle;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CatcherAnimationState.Fail:
|
||||||
|
current = catcherFail;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case CatcherAnimationState.Kiai:
|
||||||
|
current = catcherKiai;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
current.Show();
|
||||||
|
(current.Drawable as IAnimation)?.GotoFrame(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void beginTrail()
|
||||||
|
{
|
||||||
|
Trail &= dashing || HyperDashing;
|
||||||
|
Trail &= AdditiveTarget != null;
|
||||||
|
|
||||||
|
if (!Trail) return;
|
||||||
|
|
||||||
|
var additive = createAdditiveSprite(HyperDashing);
|
||||||
|
|
||||||
|
additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint);
|
||||||
|
additive.Expire(true);
|
||||||
|
|
||||||
|
Scheduler.AddDelayed(beginTrail, HyperDashing ? 25 : 50);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable createAdditiveSprite(bool hyperDash)
|
||||||
|
{
|
||||||
|
var additive = createCatcherSprite();
|
||||||
|
|
||||||
|
additive.Anchor = Anchor;
|
||||||
|
additive.Scale = Scale;
|
||||||
|
additive.Colour = hyperDash ? Color4.Red : Color4.White;
|
||||||
|
additive.Blending = BlendingParameters.Additive;
|
||||||
|
additive.RelativePositionAxes = RelativePositionAxes;
|
||||||
|
additive.Position = Position;
|
||||||
|
|
||||||
|
AdditiveTarget.Add(additive);
|
||||||
|
|
||||||
|
return additive;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Drawable createCatcherSprite()
|
||||||
|
{
|
||||||
|
return new CatcherSprite(CurrentState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateState(CatcherAnimationState state)
|
||||||
|
{
|
||||||
|
if (CurrentState == state)
|
||||||
|
return;
|
||||||
|
|
||||||
|
CurrentState = state;
|
||||||
|
updateCatcher();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void removeFromPlateWithTransform(DrawableHitObject fruit, Action<DrawableHitObject> action)
|
||||||
|
{
|
||||||
|
if (ExplodingFruitTarget != null)
|
||||||
|
{
|
||||||
|
fruit.Anchor = Anchor.TopLeft;
|
||||||
|
fruit.Position = caughtFruit.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget);
|
||||||
|
|
||||||
|
if (!caughtFruit.Remove(fruit))
|
||||||
|
// we may have already been removed by a previous operation (due to the weird OnLoadComplete scheduling).
|
||||||
|
// this avoids a crash on potentially attempting to Add a fruit to ExplodingFruitTarget twice.
|
||||||
|
return;
|
||||||
|
|
||||||
|
ExplodingFruitTarget.Add(fruit);
|
||||||
|
}
|
||||||
|
|
||||||
|
var actionTime = Clock.CurrentTime;
|
||||||
|
|
||||||
|
fruit.ApplyCustomUpdateState += onFruitOnApplyCustomUpdateState;
|
||||||
|
onFruitOnApplyCustomUpdateState(fruit, fruit.State.Value);
|
||||||
|
|
||||||
|
void onFruitOnApplyCustomUpdateState(DrawableHitObject o, ArmedState state)
|
||||||
|
{
|
||||||
|
using (fruit.BeginAbsoluteSequence(actionTime))
|
||||||
|
action(fruit);
|
||||||
|
|
||||||
|
fruit.Expire();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,15 +2,8 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Animations;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Effects;
|
|
||||||
using osu.Framework.Input.Bindings;
|
|
||||||
using osu.Framework.Utils;
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Rulesets.Catch.Judgements;
|
using osu.Game.Rulesets.Catch.Judgements;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
@ -20,7 +13,6 @@ using osu.Game.Rulesets.Judgements;
|
|||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.UI
|
namespace osu.Game.Rulesets.Catch.UI
|
||||||
{
|
{
|
||||||
@ -28,8 +20,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
{
|
{
|
||||||
public const float CATCHER_SIZE = 106.75f;
|
public const float CATCHER_SIZE = 106.75f;
|
||||||
|
|
||||||
protected internal readonly Catcher MovableCatcher;
|
|
||||||
|
|
||||||
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
|
public Func<CatchHitObject, DrawableHitObject<CatchHitObject>> CreateDrawableRepresentation;
|
||||||
|
|
||||||
public Container ExplodingFruitTarget
|
public Container ExplodingFruitTarget
|
||||||
@ -37,6 +27,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
set => MovableCatcher.ExplodingFruitTarget = value;
|
set => MovableCatcher.ExplodingFruitTarget = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DrawableCatchHitObject lastPlateableFruit;
|
||||||
|
|
||||||
public CatcherArea(BeatmapDifficulty difficulty = null)
|
public CatcherArea(BeatmapDifficulty difficulty = null)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -47,7 +39,10 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private DrawableCatchHitObject lastPlateableFruit;
|
public static float GetCatcherSize(BeatmapDifficulty difficulty)
|
||||||
|
{
|
||||||
|
return CATCHER_SIZE / CatchPlayfield.BASE_WIDTH * (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
|
||||||
|
}
|
||||||
|
|
||||||
public void OnResult(DrawableCatchHitObject fruit, JudgementResult result)
|
public void OnResult(DrawableCatchHitObject fruit, JudgementResult result)
|
||||||
{
|
{
|
||||||
@ -100,6 +95,15 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void OnReleased(CatchAction action)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool AttemptCatch(CatchHitObject obj)
|
||||||
|
{
|
||||||
|
return MovableCatcher.AttemptCatch(obj);
|
||||||
|
}
|
||||||
|
|
||||||
protected override void UpdateAfterChildren()
|
protected override void UpdateAfterChildren()
|
||||||
{
|
{
|
||||||
base.UpdateAfterChildren();
|
base.UpdateAfterChildren();
|
||||||
@ -110,559 +114,6 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
MovableCatcher.X = state.CatcherX.Value;
|
MovableCatcher.X = state.CatcherX.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnReleased(CatchAction action)
|
protected internal readonly Catcher MovableCatcher;
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool AttemptCatch(CatchHitObject obj) => MovableCatcher.AttemptCatch(obj);
|
|
||||||
|
|
||||||
public static float GetCatcherSize(BeatmapDifficulty difficulty)
|
|
||||||
{
|
|
||||||
return CATCHER_SIZE / CatchPlayfield.BASE_WIDTH * (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Catcher : Container, IKeyBindingHandler<CatchAction>
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Width of the area that can be used to attempt catches during gameplay.
|
|
||||||
/// </summary>
|
|
||||||
internal float CatchWidth => CATCHER_SIZE * Math.Abs(Scale.X);
|
|
||||||
|
|
||||||
private Container<DrawableHitObject> caughtFruit;
|
|
||||||
|
|
||||||
public Container ExplodingFruitTarget;
|
|
||||||
|
|
||||||
public Container AdditiveTarget;
|
|
||||||
|
|
||||||
public Catcher(BeatmapDifficulty difficulty = null)
|
|
||||||
{
|
|
||||||
RelativePositionAxes = Axes.X;
|
|
||||||
X = 0.5f;
|
|
||||||
|
|
||||||
Origin = Anchor.TopCentre;
|
|
||||||
|
|
||||||
Size = new Vector2(CATCHER_SIZE);
|
|
||||||
if (difficulty != null)
|
|
||||||
Scale = new Vector2(1.0f - 0.7f * (difficulty.CircleSize - 5) / 5);
|
|
||||||
}
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load()
|
|
||||||
{
|
|
||||||
Children = new Drawable[]
|
|
||||||
{
|
|
||||||
caughtFruit = new Container<DrawableHitObject>
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Origin = Anchor.BottomCentre,
|
|
||||||
},
|
|
||||||
catcherIdle = new CatcherSprite(CatcherAnimationState.Idle)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Alpha = 0,
|
|
||||||
},
|
|
||||||
catcherKiai = new CatcherSprite(CatcherAnimationState.Kiai)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Alpha = 0,
|
|
||||||
},
|
|
||||||
catcherFail = new CatcherSprite(CatcherAnimationState.Fail)
|
|
||||||
{
|
|
||||||
Anchor = Anchor.TopCentre,
|
|
||||||
Alpha = 0,
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
updateCatcher();
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatcherSprite catcherIdle;
|
|
||||||
private CatcherSprite catcherKiai;
|
|
||||||
private CatcherSprite catcherFail;
|
|
||||||
|
|
||||||
private void updateCatcher()
|
|
||||||
{
|
|
||||||
catcherIdle.Hide();
|
|
||||||
catcherKiai.Hide();
|
|
||||||
catcherFail.Hide();
|
|
||||||
|
|
||||||
CatcherSprite current;
|
|
||||||
|
|
||||||
switch (CurrentState)
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
current = catcherIdle;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CatcherAnimationState.Fail:
|
|
||||||
current = catcherFail;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CatcherAnimationState.Kiai:
|
|
||||||
current = catcherKiai;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
current.Show();
|
|
||||||
(current.Drawable as IAnimation)?.GotoFrame(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
private int currentDirection;
|
|
||||||
|
|
||||||
private bool dashing;
|
|
||||||
|
|
||||||
protected bool Dashing
|
|
||||||
{
|
|
||||||
get => dashing;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == dashing) return;
|
|
||||||
|
|
||||||
dashing = value;
|
|
||||||
|
|
||||||
Trail |= dashing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private bool trail;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Activate or deactive the trail. Will be automatically deactivated when conditions to keep the trail displayed are no longer met.
|
|
||||||
/// </summary>
|
|
||||||
protected bool Trail
|
|
||||||
{
|
|
||||||
get => trail;
|
|
||||||
set
|
|
||||||
{
|
|
||||||
if (value == trail) return;
|
|
||||||
|
|
||||||
trail = value;
|
|
||||||
|
|
||||||
if (Trail)
|
|
||||||
beginTrail();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void beginTrail()
|
|
||||||
{
|
|
||||||
Trail &= dashing || HyperDashing;
|
|
||||||
Trail &= AdditiveTarget != null;
|
|
||||||
|
|
||||||
if (!Trail) return;
|
|
||||||
|
|
||||||
var additive = createAdditiveSprite(HyperDashing);
|
|
||||||
|
|
||||||
additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint);
|
|
||||||
additive.Expire(true);
|
|
||||||
|
|
||||||
Scheduler.AddDelayed(beginTrail, HyperDashing ? 25 : 50);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Drawable createAdditiveSprite(bool hyperDash)
|
|
||||||
{
|
|
||||||
var additive = createCatcherSprite();
|
|
||||||
|
|
||||||
additive.Anchor = Anchor;
|
|
||||||
additive.Scale = Scale;
|
|
||||||
additive.Colour = hyperDash ? Color4.Red : Color4.White;
|
|
||||||
additive.Blending = BlendingParameters.Additive;
|
|
||||||
additive.RelativePositionAxes = RelativePositionAxes;
|
|
||||||
additive.Position = Position;
|
|
||||||
|
|
||||||
AdditiveTarget.Add(additive);
|
|
||||||
|
|
||||||
return additive;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Drawable createCatcherSprite() => new CatcherSprite(CurrentState);
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Add a caught fruit to the catcher's stack.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fruit">The fruit that was caught.</param>
|
|
||||||
public void PlaceOnPlate(DrawableCatchHitObject fruit)
|
|
||||||
{
|
|
||||||
float ourRadius = fruit.DisplayRadius;
|
|
||||||
float theirRadius = 0;
|
|
||||||
|
|
||||||
const float allowance = 6;
|
|
||||||
|
|
||||||
while (caughtFruit.Any(f =>
|
|
||||||
f.LifetimeEnd == double.MaxValue &&
|
|
||||||
Vector2Extensions.Distance(f.Position, fruit.Position) < (ourRadius + (theirRadius = f.DrawSize.X / 2 * f.Scale.X)) / (allowance / 2)))
|
|
||||||
{
|
|
||||||
float diff = (ourRadius + theirRadius) / allowance;
|
|
||||||
fruit.X += (RNG.NextSingle() - 0.5f) * 2 * diff;
|
|
||||||
fruit.Y -= RNG.NextSingle() * diff;
|
|
||||||
}
|
|
||||||
|
|
||||||
fruit.X = Math.Clamp(fruit.X, -CATCHER_SIZE / 2, CATCHER_SIZE / 2);
|
|
||||||
|
|
||||||
caughtFruit.Add(fruit);
|
|
||||||
|
|
||||||
Add(new HitExplosion(fruit)
|
|
||||||
{
|
|
||||||
X = fruit.X,
|
|
||||||
Scale = new Vector2(fruit.HitObject.Scale)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Let the catcher attempt to catch a fruit.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="fruit">The fruit to catch.</param>
|
|
||||||
/// <returns>Whether the catch is possible.</returns>
|
|
||||||
public bool AttemptCatch(CatchHitObject fruit)
|
|
||||||
{
|
|
||||||
float halfCatchWidth = CatchWidth * 0.5f;
|
|
||||||
|
|
||||||
// this stuff wil disappear once we move fruit to non-relative coordinate space in the future.
|
|
||||||
var catchObjectPosition = fruit.X * CatchPlayfield.BASE_WIDTH;
|
|
||||||
var catcherPosition = Position.X * CatchPlayfield.BASE_WIDTH;
|
|
||||||
|
|
||||||
var validCatch =
|
|
||||||
catchObjectPosition >= catcherPosition - halfCatchWidth &&
|
|
||||||
catchObjectPosition <= catcherPosition + halfCatchWidth;
|
|
||||||
|
|
||||||
// only update hyperdash state if we are catching a fruit.
|
|
||||||
// exceptions are Droplets and JuiceStreams.
|
|
||||||
if (!(fruit is Fruit)) return validCatch;
|
|
||||||
|
|
||||||
if (validCatch && fruit.HyperDash)
|
|
||||||
{
|
|
||||||
var target = fruit.HyperDashTarget;
|
|
||||||
double timeDifference = target.StartTime - fruit.StartTime;
|
|
||||||
double positionDifference = target.X * CatchPlayfield.BASE_WIDTH - catcherPosition;
|
|
||||||
double velocity = positionDifference / Math.Max(1.0, timeDifference - 1000.0 / 60.0);
|
|
||||||
|
|
||||||
SetHyperDashState(Math.Abs(velocity), target.X);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
SetHyperDashState();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (validCatch)
|
|
||||||
updateState(fruit.Kiai ? CatcherAnimationState.Kiai : CatcherAnimationState.Idle);
|
|
||||||
else if (!(fruit is Banana))
|
|
||||||
updateState(CatcherAnimationState.Fail);
|
|
||||||
|
|
||||||
return validCatch;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updateState(CatcherAnimationState state)
|
|
||||||
{
|
|
||||||
if (CurrentState == state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
CurrentState = state;
|
|
||||||
updateCatcher();
|
|
||||||
}
|
|
||||||
|
|
||||||
public CatcherAnimationState CurrentState { get; private set; }
|
|
||||||
|
|
||||||
private double hyperDashModifier = 1;
|
|
||||||
private int hyperDashDirection;
|
|
||||||
private float hyperDashTargetPosition;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Whether we are hyper-dashing or not.
|
|
||||||
/// </summary>
|
|
||||||
public bool HyperDashing => hyperDashModifier != 1;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Set hyper-dash state.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="modifier">The speed multiplier. If this is less or equals to 1, this catcher will be non-hyper-dashing state.</param>
|
|
||||||
/// <param name="targetPosition">When this catcher crosses this position, this catcher ends hyper-dashing.</param>
|
|
||||||
public void SetHyperDashState(double modifier = 1, float targetPosition = -1)
|
|
||||||
{
|
|
||||||
const float hyper_dash_transition_length = 180;
|
|
||||||
|
|
||||||
bool wasHyperDashing = HyperDashing;
|
|
||||||
|
|
||||||
if (modifier <= 1 || X == targetPosition)
|
|
||||||
{
|
|
||||||
hyperDashModifier = 1;
|
|
||||||
hyperDashDirection = 0;
|
|
||||||
|
|
||||||
if (wasHyperDashing)
|
|
||||||
{
|
|
||||||
this.FadeColour(Color4.White, hyper_dash_transition_length, Easing.OutQuint);
|
|
||||||
this.FadeTo(1, hyper_dash_transition_length, Easing.OutQuint);
|
|
||||||
Trail &= Dashing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hyperDashModifier = modifier;
|
|
||||||
hyperDashDirection = Math.Sign(targetPosition - X);
|
|
||||||
hyperDashTargetPosition = targetPosition;
|
|
||||||
|
|
||||||
if (!wasHyperDashing)
|
|
||||||
{
|
|
||||||
this.FadeColour(Color4.OrangeRed, hyper_dash_transition_length, Easing.OutQuint);
|
|
||||||
this.FadeTo(0.2f, hyper_dash_transition_length, Easing.OutQuint);
|
|
||||||
Trail = true;
|
|
||||||
|
|
||||||
var hyperDashEndGlow = createAdditiveSprite(true);
|
|
||||||
|
|
||||||
hyperDashEndGlow.MoveToOffset(new Vector2(0, -20), 1200, Easing.In);
|
|
||||||
hyperDashEndGlow.ScaleTo(hyperDashEndGlow.Scale * 0.9f).ScaleTo(hyperDashEndGlow.Scale * 1.2f, 1200, Easing.In);
|
|
||||||
hyperDashEndGlow.FadeOut(1200);
|
|
||||||
hyperDashEndGlow.Expire(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool OnPressed(CatchAction action)
|
|
||||||
{
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case CatchAction.MoveLeft:
|
|
||||||
currentDirection--;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case CatchAction.MoveRight:
|
|
||||||
currentDirection++;
|
|
||||||
return true;
|
|
||||||
|
|
||||||
case CatchAction.Dash:
|
|
||||||
Dashing = true;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnReleased(CatchAction action)
|
|
||||||
{
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case CatchAction.MoveLeft:
|
|
||||||
currentDirection++;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CatchAction.MoveRight:
|
|
||||||
currentDirection--;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CatchAction.Dash:
|
|
||||||
Dashing = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The relative space to cover in 1 millisecond. based on 1 game pixel per millisecond as in osu-stable.
|
|
||||||
/// </summary>
|
|
||||||
public const double BASE_SPEED = 1.0 / 512;
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (currentDirection == 0) return;
|
|
||||||
|
|
||||||
var direction = Math.Sign(currentDirection);
|
|
||||||
|
|
||||||
double dashModifier = Dashing ? 1 : 0.5;
|
|
||||||
double speed = BASE_SPEED * dashModifier * hyperDashModifier;
|
|
||||||
|
|
||||||
UpdatePosition((float)(X + direction * Clock.ElapsedFrameTime * speed));
|
|
||||||
|
|
||||||
// Correct overshooting.
|
|
||||||
if ((hyperDashDirection > 0 && hyperDashTargetPosition < X) ||
|
|
||||||
(hyperDashDirection < 0 && hyperDashTargetPosition > X))
|
|
||||||
{
|
|
||||||
X = hyperDashTargetPosition;
|
|
||||||
SetHyperDashState();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void UpdatePosition(float position)
|
|
||||||
{
|
|
||||||
position = Math.Clamp(position, 0, 1);
|
|
||||||
|
|
||||||
if (position == X)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Scale = new Vector2(Math.Abs(Scale.X) * (position > X ? 1 : -1), Scale.Y);
|
|
||||||
X = position;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Drop any fruit off the plate.
|
|
||||||
/// </summary>
|
|
||||||
public void Drop()
|
|
||||||
{
|
|
||||||
foreach (var f in caughtFruit.ToArray())
|
|
||||||
Drop(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Explode any fruit off the plate.
|
|
||||||
/// </summary>
|
|
||||||
public void Explode()
|
|
||||||
{
|
|
||||||
foreach (var f in caughtFruit.ToArray())
|
|
||||||
Explode(f);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Drop(DrawableHitObject fruit) => removeFromPlateWithTransform(fruit, f =>
|
|
||||||
{
|
|
||||||
f.MoveToY(f.Y + 75, 750, Easing.InSine);
|
|
||||||
f.FadeOut(750);
|
|
||||||
});
|
|
||||||
|
|
||||||
public void Explode(DrawableHitObject fruit)
|
|
||||||
{
|
|
||||||
var originalX = fruit.X * Scale.X;
|
|
||||||
|
|
||||||
removeFromPlateWithTransform(fruit, f =>
|
|
||||||
{
|
|
||||||
f.MoveToY(f.Y - 50, 250, Easing.OutSine).Then().MoveToY(f.Y + 50, 500, Easing.InSine);
|
|
||||||
f.MoveToX(f.X + originalX * 6, 1000);
|
|
||||||
f.FadeOut(750);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void removeFromPlateWithTransform(DrawableHitObject fruit, Action<DrawableHitObject> action)
|
|
||||||
{
|
|
||||||
if (ExplodingFruitTarget != null)
|
|
||||||
{
|
|
||||||
fruit.Anchor = Anchor.TopLeft;
|
|
||||||
fruit.Position = caughtFruit.ToSpaceOfOtherDrawable(fruit.DrawPosition, ExplodingFruitTarget);
|
|
||||||
|
|
||||||
if (!caughtFruit.Remove(fruit))
|
|
||||||
// we may have already been removed by a previous operation (due to the weird OnLoadComplete scheduling).
|
|
||||||
// this avoids a crash on potentially attempting to Add a fruit to ExplodingFruitTarget twice.
|
|
||||||
return;
|
|
||||||
|
|
||||||
ExplodingFruitTarget.Add(fruit);
|
|
||||||
}
|
|
||||||
|
|
||||||
double actionTime = Clock.CurrentTime;
|
|
||||||
|
|
||||||
fruit.ApplyCustomUpdateState += onFruitOnApplyCustomUpdateState;
|
|
||||||
onFruitOnApplyCustomUpdateState(fruit, fruit.State.Value);
|
|
||||||
|
|
||||||
void onFruitOnApplyCustomUpdateState(DrawableHitObject o, ArmedState state)
|
|
||||||
{
|
|
||||||
using (fruit.BeginAbsoluteSequence(actionTime))
|
|
||||||
action(fruit);
|
|
||||||
|
|
||||||
fruit.Expire();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public class HitExplosion : CompositeDrawable
|
|
||||||
{
|
|
||||||
private readonly CircularContainer largeFaint;
|
|
||||||
|
|
||||||
public HitExplosion(DrawableCatchHitObject fruit)
|
|
||||||
{
|
|
||||||
Size = new Vector2(20);
|
|
||||||
Anchor = Anchor.TopCentre;
|
|
||||||
Origin = Anchor.BottomCentre;
|
|
||||||
|
|
||||||
Color4 objectColour = fruit.AccentColour.Value;
|
|
||||||
|
|
||||||
// scale roughly in-line with visual appearance of notes
|
|
||||||
|
|
||||||
const float angle_variangle = 15; // should be less than 45
|
|
||||||
|
|
||||||
const float roundness = 100;
|
|
||||||
|
|
||||||
const float initial_height = 10;
|
|
||||||
|
|
||||||
var colour = Interpolation.ValueAt(0.4f, objectColour, Color4.White, 0, 1);
|
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
largeFaint = new CircularContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Masking = true,
|
|
||||||
// we want our size to be very small so the glow dominates it.
|
|
||||||
Size = new Vector2(0.8f),
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = Interpolation.ValueAt(0.1f, objectColour, Color4.White, 0, 1).Opacity(0.3f),
|
|
||||||
Roundness = 160,
|
|
||||||
Radius = 200,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new CircularContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Masking = true,
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = Interpolation.ValueAt(0.6f, objectColour, Color4.White, 0, 1),
|
|
||||||
Roundness = 20,
|
|
||||||
Radius = 50,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new CircularContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Masking = true,
|
|
||||||
Size = new Vector2(0.01f, initial_height),
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = colour,
|
|
||||||
Roundness = roundness,
|
|
||||||
Radius = 40,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
new CircularContainer
|
|
||||||
{
|
|
||||||
Anchor = Anchor.Centre,
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Masking = true,
|
|
||||||
Size = new Vector2(0.01f, initial_height),
|
|
||||||
Blending = BlendingParameters.Additive,
|
|
||||||
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
|
||||||
EdgeEffect = new EdgeEffectParameters
|
|
||||||
{
|
|
||||||
Type = EdgeEffectType.Glow,
|
|
||||||
Colour = colour,
|
|
||||||
Roundness = roundness,
|
|
||||||
Radius = 40,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
const double duration = 400;
|
|
||||||
|
|
||||||
largeFaint
|
|
||||||
.ResizeTo(largeFaint.Size * new Vector2(5, 1), duration, Easing.OutQuint)
|
|
||||||
.FadeOut(duration * 2);
|
|
||||||
|
|
||||||
this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out);
|
|
||||||
Expire(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
122
osu.Game.Rulesets.Catch/UI/HitExplosion.cs
Normal file
122
osu.Game.Rulesets.Catch/UI/HitExplosion.cs
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
// 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 osu.Framework.Extensions.Color4Extensions;
|
||||||
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Effects;
|
||||||
|
using osu.Framework.Utils;
|
||||||
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||||
|
using osuTK;
|
||||||
|
using osuTK.Graphics;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.UI
|
||||||
|
{
|
||||||
|
public class HitExplosion : CompositeDrawable
|
||||||
|
{
|
||||||
|
private readonly CircularContainer largeFaint;
|
||||||
|
|
||||||
|
public HitExplosion(DrawableCatchHitObject fruit)
|
||||||
|
{
|
||||||
|
Size = new Vector2(20);
|
||||||
|
Anchor = Anchor.TopCentre;
|
||||||
|
Origin = Anchor.BottomCentre;
|
||||||
|
|
||||||
|
Color4 objectColour = fruit.AccentColour.Value;
|
||||||
|
|
||||||
|
// scale roughly in-line with visual appearance of notes
|
||||||
|
|
||||||
|
const float angle_variangle = 15; // should be less than 45
|
||||||
|
|
||||||
|
const float roundness = 100;
|
||||||
|
|
||||||
|
const float initial_height = 10;
|
||||||
|
|
||||||
|
var colour = Interpolation.ValueAt(0.4f, objectColour, Color4.White, 0, 1);
|
||||||
|
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
largeFaint = new CircularContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
// we want our size to be very small so the glow dominates it.
|
||||||
|
Size = new Vector2(0.8f),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = Interpolation.ValueAt(0.1f, objectColour, Color4.White, 0, 1).Opacity(0.3f),
|
||||||
|
Roundness = 160,
|
||||||
|
Radius = 200,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new CircularContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = Interpolation.ValueAt(0.6f, objectColour, Color4.White, 0, 1),
|
||||||
|
Roundness = 20,
|
||||||
|
Radius = 50,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new CircularContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
Size = new Vector2(0.01f, initial_height),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = colour,
|
||||||
|
Roundness = roundness,
|
||||||
|
Radius = 40,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
new CircularContainer
|
||||||
|
{
|
||||||
|
Anchor = Anchor.Centre,
|
||||||
|
Origin = Anchor.Centre,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Masking = true,
|
||||||
|
Size = new Vector2(0.01f, initial_height),
|
||||||
|
Blending = BlendingParameters.Additive,
|
||||||
|
Rotation = RNG.NextSingle(-angle_variangle, angle_variangle),
|
||||||
|
EdgeEffect = new EdgeEffectParameters
|
||||||
|
{
|
||||||
|
Type = EdgeEffectType.Glow,
|
||||||
|
Colour = colour,
|
||||||
|
Roundness = roundness,
|
||||||
|
Radius = 40,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
const double duration = 400;
|
||||||
|
|
||||||
|
largeFaint
|
||||||
|
.ResizeTo(largeFaint.Size * new Vector2(5, 1), duration, Easing.OutQuint)
|
||||||
|
.FadeOut(duration * 2);
|
||||||
|
|
||||||
|
this.FadeInFromZero(50).Then().FadeOut(duration, Easing.Out);
|
||||||
|
Expire(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -185,7 +185,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
base.ApplySkin(skin, allowFallback);
|
base.ApplySkin(skin, allowFallback);
|
||||||
|
|
||||||
bool allowBallTint = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.AllowSliderBallTint)?.Value ?? false;
|
bool allowBallTint = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.AllowSliderBallTint)?.Value ?? false;
|
||||||
Ball.Colour = allowBallTint ? AccentColour.Value : Color4.White;
|
Ball.AccentColour = allowBallTint ? AccentColour.Value : Color4.White;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||||
|
@ -16,16 +16,24 @@ using osu.Game.Rulesets.Osu.Skinning;
|
|||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
using osu.Game.Skinning;
|
using osu.Game.Skinning;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
using osu.Game.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
public class SliderBall : CircularContainer, ISliderProgress, IRequireHighFrequencyMousePosition
|
public class SliderBall : CircularContainer, ISliderProgress, IRequireHighFrequencyMousePosition, IHasAccentColour
|
||||||
{
|
{
|
||||||
public Func<OsuAction?> GetInitialHitAction;
|
public Func<OsuAction?> GetInitialHitAction;
|
||||||
|
|
||||||
|
public Color4 AccentColour
|
||||||
|
{
|
||||||
|
get => ball.Colour;
|
||||||
|
set => ball.Colour = value;
|
||||||
|
}
|
||||||
|
|
||||||
private readonly Slider slider;
|
private readonly Slider slider;
|
||||||
private readonly Drawable followCircle;
|
private readonly Drawable followCircle;
|
||||||
private readonly DrawableSlider drawableSlider;
|
private readonly DrawableSlider drawableSlider;
|
||||||
|
private readonly CircularContainer ball;
|
||||||
|
|
||||||
public SliderBall(Slider slider, DrawableSlider drawableSlider = null)
|
public SliderBall(Slider slider, DrawableSlider drawableSlider = null)
|
||||||
{
|
{
|
||||||
@ -47,7 +55,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle()),
|
Child = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderFollowCircle), _ => new DefaultFollowCircle()),
|
||||||
},
|
},
|
||||||
new CircularContainer
|
ball = new CircularContainer
|
||||||
{
|
{
|
||||||
Masking = true,
|
Masking = true,
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
@ -16,7 +16,6 @@ using osu.Game.Beatmaps;
|
|||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Tournament.Models;
|
using osu.Game.Tournament.Models;
|
||||||
using osuTK;
|
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Tournament.Components
|
namespace osu.Game.Tournament.Components
|
||||||
@ -125,13 +124,21 @@ namespace osu.Game.Tournament.Components
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(mods))
|
if (!string.IsNullOrEmpty(mods))
|
||||||
{
|
{
|
||||||
AddInternal(new Sprite
|
AddInternal(new Container
|
||||||
{
|
{
|
||||||
Texture = textures.Get($"mods/{mods}"),
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
Width = 60,
|
||||||
Anchor = Anchor.CentreRight,
|
Anchor = Anchor.CentreRight,
|
||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
Margin = new MarginPadding(10),
|
Margin = new MarginPadding(10),
|
||||||
Scale = new Vector2(0.8f)
|
Child = new Sprite
|
||||||
|
{
|
||||||
|
FillMode = FillMode.Fit,
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Anchor = Anchor.CentreRight,
|
||||||
|
Origin = Anchor.CentreRight,
|
||||||
|
Texture = textures.Get($"mods/{mods}"),
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
|
|||||||
|
|
||||||
if (split.Length > 7)
|
if (split.Length > 7)
|
||||||
{
|
{
|
||||||
length = Math.Max(0, Parsing.ParseDouble(split[7]));
|
length = Math.Max(0, Parsing.ParseDouble(split[7], Parsing.MAX_COORDINATE_VALUE));
|
||||||
if (length == 0)
|
if (length == 0)
|
||||||
length = null;
|
length = null;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user