mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 09:27:29 +08:00
Combine DisplayRadius and Scale to DisplaySize
This commit is contained in:
parent
e097b6e61c
commit
2634c6b8d9
@ -5,6 +5,7 @@ using NUnit.Framework;
|
||||
using osu.Game.Rulesets.Catch.Objects;
|
||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||
using osu.Game.Tests.Visual;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Tests
|
||||
@ -37,16 +38,16 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
|
||||
float fruitRotation = 0;
|
||||
float bananaRotation = 0;
|
||||
float bananaScale = 0;
|
||||
Vector2 bananaSize = new Vector2();
|
||||
Color4 bananaColour = new Color4();
|
||||
|
||||
AddStep("Initialize start time", () =>
|
||||
{
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||
|
||||
fruitRotation = drawableFruit.Rotation;
|
||||
bananaRotation = drawableBanana.Rotation;
|
||||
bananaScale = drawableBanana.Scale.X;
|
||||
fruitRotation = drawableFruit.DisplayRotation;
|
||||
bananaRotation = drawableBanana.DisplayRotation;
|
||||
bananaSize = drawableBanana.DisplaySize;
|
||||
bananaColour = drawableBanana.AccentColour.Value;
|
||||
});
|
||||
|
||||
@ -55,9 +56,9 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = another_start_time;
|
||||
});
|
||||
|
||||
AddAssert("fruit rotation is changed", () => drawableFruit.Rotation != fruitRotation);
|
||||
AddAssert("banana rotation is changed", () => drawableBanana.Rotation != bananaRotation);
|
||||
AddAssert("banana scale is changed", () => drawableBanana.Scale.X != bananaScale);
|
||||
AddAssert("fruit rotation is changed", () => drawableFruit.DisplayRotation != fruitRotation);
|
||||
AddAssert("banana rotation is changed", () => drawableBanana.DisplayRotation != bananaRotation);
|
||||
AddAssert("banana size is changed", () => drawableBanana.DisplaySize != bananaSize);
|
||||
AddAssert("banana colour is changed", () => drawableBanana.AccentColour.Value != bananaColour);
|
||||
|
||||
AddStep("reset start time", () =>
|
||||
@ -65,10 +66,10 @@ namespace osu.Game.Rulesets.Catch.Tests
|
||||
drawableFruit.HitObject.StartTime = drawableBanana.HitObject.StartTime = initial_start_time;
|
||||
});
|
||||
|
||||
AddAssert("rotation and scale restored", () =>
|
||||
drawableFruit.Rotation == fruitRotation &&
|
||||
drawableBanana.Rotation == bananaRotation &&
|
||||
drawableBanana.Scale.X == bananaScale &&
|
||||
AddAssert("rotation and size restored", () =>
|
||||
drawableFruit.DisplayRotation == fruitRotation &&
|
||||
drawableBanana.DisplayRotation == bananaRotation &&
|
||||
drawableBanana.DisplaySize == bananaSize &&
|
||||
drawableBanana.AccentColour.Value == bananaColour);
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,9 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
public Bindable<Color4> AccentColour { get; } = new Bindable<Color4>();
|
||||
public Bindable<bool> HyperDash { get; } = new Bindable<bool>();
|
||||
|
||||
float IHasCatchObjectState.Scale => Scale.X;
|
||||
public Vector2 DisplaySize => Size * Scale;
|
||||
|
||||
public float DisplayRotation => Rotation;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this hit object should stay on the catcher plate when the object is caught by the catcher.
|
||||
@ -45,8 +47,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
public virtual void CopyStateFrom(IHasCatchObjectState objectState)
|
||||
{
|
||||
HitObject = objectState.HitObject;
|
||||
Scale = new Vector2(objectState.Scale);
|
||||
Rotation = objectState.Rotation;
|
||||
Scale = Vector2.Divide(objectState.DisplaySize, Size);
|
||||
Rotation = objectState.DisplayRotation;
|
||||
AccentColour.Value = objectState.AccentColour.Value;
|
||||
HyperDash.Value = objectState.HyperDash.Value;
|
||||
}
|
||||
|
@ -29,16 +29,14 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
/// </summary>
|
||||
protected virtual float ScaleFactor => 1;
|
||||
|
||||
public float DisplayRadius => CatchHitObject.OBJECT_RADIUS * HitObject.Scale * ScaleFactor;
|
||||
|
||||
/// <summary>
|
||||
/// The container internal transforms (such as scaling based on the circle size) are applied to.
|
||||
/// </summary>
|
||||
protected readonly Container ScalingContainer;
|
||||
|
||||
float IHasCatchObjectState.Scale => HitObject.Scale * ScaleFactor;
|
||||
public Vector2 DisplaySize => ScalingContainer.Size * ScalingContainer.Scale;
|
||||
|
||||
float IHasCatchObjectState.Rotation => ScalingContainer.Rotation;
|
||||
public float DisplayRotation => ScalingContainer.Rotation;
|
||||
|
||||
protected DrawablePalpableCatchHitObject([CanBeNull] CatchHitObject h)
|
||||
: base(h)
|
||||
@ -65,7 +63,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
ScaleBindable.BindValueChanged(scale =>
|
||||
{
|
||||
ScalingContainer.Scale = new Vector2(scale.NewValue * ScaleFactor);
|
||||
Size = ScalingContainer.Size * ScalingContainer.Scale;
|
||||
Size = DisplaySize;
|
||||
}, true);
|
||||
|
||||
IndexInBeatmap.BindValueChanged(_ => UpdateComboColour());
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using osuTK;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
@ -15,7 +16,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
Bindable<Color4> AccentColour { get; }
|
||||
Bindable<bool> HyperDash { get; }
|
||||
|
||||
float Rotation { get; }
|
||||
float Scale { get; }
|
||||
Vector2 DisplaySize { get; }
|
||||
float DisplayRotation { get; }
|
||||
}
|
||||
}
|
||||
|
@ -235,7 +235,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
if (result.IsHit)
|
||||
{
|
||||
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplayRadius);
|
||||
var positionInStack = computePositionInStack(new Vector2(palpableObject.X - X, 0), palpableObject.DisplaySize.X / 2);
|
||||
|
||||
placeCaughtObject(palpableObject, positionInStack);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user