1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 21:27:24 +08:00

Fix caught fruit radius being incorrect due to moved scale

This commit is contained in:
Dean Herbert 2020-02-19 17:28:40 +09:00
parent 579638976d
commit e1140d7c91
4 changed files with 41 additions and 64 deletions

View File

@ -2,11 +2,15 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
@ -15,6 +19,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
public override bool CanBePlated => true;
protected Container ScaleContainer;
protected PalpableCatchHitObject(TObject hitObject)
: base(hitObject)
{
@ -22,6 +28,28 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
Size = new Vector2(CatchHitObject.OBJECT_RADIUS * 2);
Masking = false;
}
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Framework.Graphics.Drawable[]
{
ScaleContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
}
});
ScaleContainer.Scale = new Vector2(HitObject.Scale);
}
protected override void UpdateComboColour(Color4 proposedColour, IReadOnlyList<Color4> comboColours)
{
// ignore the incoming combo colour as we use a custom lookup
AccentColour.Value = comboColours[(HitObject.IndexInBeatmap + 1) % comboColours.Count];
}
}
public abstract class DrawableCatchHitObject<TObject> : DrawableCatchHitObject
@ -43,6 +71,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
public virtual bool StaysOnPlate => CanBePlated;
public float DisplayRadius => DrawSize.X / 2 * Scale.X * HitObject.Scale;
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{

View File

@ -1,13 +1,9 @@
// 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.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Catch.Objects.Drawable.Pieces;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
@ -16,8 +12,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
public override bool StaysOnPlate => false;
protected Container ScaleContainer;
public DrawableDroplet(Droplet h)
: base(h)
{
@ -26,32 +20,12 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Framework.Graphics.Drawable[]
{
ScaleContainer = new Container
ScaleContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Droplet), _ => new Pulp
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Children = new Framework.Graphics.Drawable[]
{
new SkinnableDrawable(
new CatchSkinComponent(CatchSkinComponents.Droplet), _ => new Pulp
{
Size = Size / 4,
AccentColour = { Value = Color4.White }
})
}
}
});
ScaleContainer.Scale = new Vector2(HitObject.Scale);
}
protected override void UpdateComboColour(Color4 proposedColour, IReadOnlyList<Color4> comboColours)
{
// ignore the incoming combo colour as we use a custom lookup
AccentColour.Value = comboColours[(HitObject.IndexInBeatmap + 1) % comboColours.Count];
Size = Size / 4,
AccentColour = { Value = Color4.White }
});
}
}
}

View File

@ -2,21 +2,14 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Utils;
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
public class DrawableFruit : PalpableCatchHitObject<Fruit>
{
private Container scaleContainer;
public DrawableFruit(Fruit h)
: base(h)
{
@ -26,28 +19,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
[BackgroundDependencyLoader]
private void load()
{
AddRangeInternal(new Framework.Graphics.Drawable[]
{
scaleContainer = new Container
{
RelativeSizeAxes = Axes.Both,
Origin = Anchor.Centre,
Anchor = Anchor.Centre,
Children = new Framework.Graphics.Drawable[]
{
new SkinnableDrawable(
new CatchSkinComponent(getComponent(HitObject.VisualRepresentation)), _ => new FruitPiece())
}
}
});
scaleContainer.Scale = new Vector2(HitObject.Scale);
}
protected override void UpdateComboColour(Color4 proposedColour, IReadOnlyList<Color4> comboColours)
{
// ignore the incoming combo colour as we use a custom lookup
AccentColour.Value = comboColours[(HitObject.IndexInBeatmap + 1) % comboColours.Count];
ScaleContainer.Child = new SkinnableDrawable(
new CatchSkinComponent(getComponent(HitObject.VisualRepresentation)), _ => new FruitPiece());
}
private CatchSkinComponents getComponent(FruitVisualRepresentation hitObjectVisualRepresentation)

View File

@ -74,11 +74,11 @@ namespace osu.Game.Rulesets.Catch.UI
caughtFruit.Anchor = Anchor.TopCentre;
caughtFruit.Origin = Anchor.Centre;
caughtFruit.Scale *= 0.7f;
caughtFruit.Scale *= 0.5f;
caughtFruit.LifetimeStart = caughtFruit.HitObject.StartTime;
caughtFruit.LifetimeEnd = double.MaxValue;
MovableCatcher.Add(caughtFruit);
MovableCatcher.PlaceOnPlate(caughtFruit);
lastPlateableFruit = caughtFruit;
if (!fruit.StaysOnPlate)
@ -221,9 +221,9 @@ namespace osu.Game.Rulesets.Catch.UI
/// Add a caught fruit to the catcher's stack.
/// </summary>
/// <param name="fruit">The fruit that was caught.</param>
public void Add(DrawableHitObject fruit)
public void PlaceOnPlate(DrawableHitObject fruit)
{
float ourRadius = fruit.DrawSize.X / 2 * fruit.Scale.X;
float ourRadius = ((DrawableCatchHitObject)fruit).DisplayRadius;
float theirRadius = 0;
const float allowance = 6;