mirror of
https://github.com/ppy/osu
synced 2024-12-11 17:42:28 +00:00
Store a DHO in FruitPiece
to animate itself.
This commit is contained in:
parent
5e0e4e9db7
commit
4228977c86
@ -16,8 +16,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
|
|
||||||
protected virtual FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => (FruitVisualRepresentation)(indexInBeatmap % 4);
|
protected virtual FruitVisualRepresentation GetVisualRepresentation(int indexInBeatmap) => (FruitVisualRepresentation)(indexInBeatmap % 4);
|
||||||
|
|
||||||
private FruitPiece fruitPiece;
|
|
||||||
|
|
||||||
public DrawableFruit(CatchHitObject h)
|
public DrawableFruit(CatchHitObject h)
|
||||||
: base(h)
|
: base(h)
|
||||||
{
|
{
|
||||||
@ -41,21 +39,13 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
{
|
{
|
||||||
ScaleContainer.Child = new SkinnableDrawable(
|
ScaleContainer.Child = new SkinnableDrawable(
|
||||||
new CatchSkinComponent(getComponent(VisualRepresentation.Value)),
|
new CatchSkinComponent(getComponent(VisualRepresentation.Value)),
|
||||||
_ => fruitPiece = new FruitPiece
|
_ => new FruitPiece
|
||||||
{
|
{
|
||||||
VisualRepresentation = { BindTarget = VisualRepresentation },
|
VisualRepresentation = { BindTarget = VisualRepresentation },
|
||||||
HyperDash = { BindTarget = HyperDash },
|
HyperDash = { BindTarget = HyperDash },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
if (fruitPiece != null)
|
|
||||||
fruitPiece.Border.Alpha = (float)Math.Clamp((StartTimeBindable.Value - Time.Current) / 500, 0, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private CatchSkinComponents getComponent(FruitVisualRepresentation hitObjectVisualRepresentation)
|
private CatchSkinComponents getComponent(FruitVisualRepresentation hitObjectVisualRepresentation)
|
||||||
{
|
{
|
||||||
switch (hitObjectVisualRepresentation)
|
switch (hitObjectVisualRepresentation)
|
||||||
|
@ -1,10 +1,13 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
|
||||||
{
|
{
|
||||||
@ -18,26 +21,36 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
|
|||||||
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
|
public readonly Bindable<FruitVisualRepresentation> VisualRepresentation = new Bindable<FruitVisualRepresentation>();
|
||||||
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
public readonly Bindable<bool> HyperDash = new Bindable<bool>();
|
||||||
|
|
||||||
public BorderPiece Border { get; private set; }
|
[CanBeNull]
|
||||||
|
private DrawableCatchHitObject drawableHitObject;
|
||||||
|
|
||||||
|
[CanBeNull]
|
||||||
|
private BorderPiece borderPiece;
|
||||||
|
|
||||||
public FruitPiece()
|
public FruitPiece()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load()
|
private void load([CanBeNull] DrawableHitObject drawable)
|
||||||
{
|
{
|
||||||
AddRangeInternal(new[]
|
drawableHitObject = (DrawableCatchHitObject)drawable;
|
||||||
{
|
|
||||||
getFruitFor(VisualRepresentation.Value),
|
AddInternal(getFruitFor(VisualRepresentation.Value));
|
||||||
Border = new BorderPiece(),
|
|
||||||
});
|
// if it is not part of a DHO, the border is always invisible.
|
||||||
|
if (drawableHitObject != null)
|
||||||
|
AddInternal(borderPiece = new BorderPiece());
|
||||||
|
|
||||||
if (HyperDash.Value)
|
if (HyperDash.Value)
|
||||||
{
|
|
||||||
AddInternal(new HyperBorderPiece());
|
AddInternal(new HyperBorderPiece());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
if (borderPiece != null && drawableHitObject.HitObject != null)
|
||||||
|
borderPiece.Alpha = (float)Math.Clamp((drawableHitObject.HitObject.StartTime - Time.Current) / 500, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Drawable getFruitFor(FruitVisualRepresentation representation)
|
private Drawable getFruitFor(FruitVisualRepresentation representation)
|
||||||
|
Loading…
Reference in New Issue
Block a user