2020-02-17 17:47:22 +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.
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
2020-11-26 13:26:38 +08:00
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables.Pieces
|
2020-02-17 17:47:22 +08:00
|
|
|
{
|
|
|
|
internal class FruitPiece : CompositeDrawable
|
|
|
|
{
|
2020-02-19 08:39:56 +08:00
|
|
|
/// <summary>
|
|
|
|
/// Because we're adding a border around the fruit, we need to scale down some.
|
|
|
|
/// </summary>
|
2020-02-19 22:32:56 +08:00
|
|
|
public const float RADIUS_ADJUST = 1.1f;
|
2020-02-19 08:39:56 +08:00
|
|
|
|
2020-11-26 13:36:42 +08:00
|
|
|
private BorderPiece border;
|
2020-11-24 18:57:37 +08:00
|
|
|
private PalpableCatchHitObject hitObject;
|
2020-02-17 17:47:22 +08:00
|
|
|
|
|
|
|
public FruitPiece()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-04-05 05:02:33 +08:00
|
|
|
private void load(DrawableHitObject drawableObject)
|
2020-02-17 17:47:22 +08:00
|
|
|
{
|
2020-11-25 07:07:59 +08:00
|
|
|
var drawableCatchObject = (DrawablePalpableCatchHitObject)drawableObject;
|
|
|
|
hitObject = drawableCatchObject.HitObject;
|
2020-02-17 17:47:22 +08:00
|
|
|
|
|
|
|
AddRangeInternal(new[]
|
|
|
|
{
|
2020-11-25 07:07:59 +08:00
|
|
|
getFruitFor(hitObject.VisualRepresentation),
|
2020-11-26 13:36:42 +08:00
|
|
|
border = new BorderPiece(),
|
2020-02-17 17:47:22 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
if (hitObject.HyperDash)
|
|
|
|
{
|
2020-11-26 13:36:42 +08:00
|
|
|
AddInternal(new HyperBorderPiece());
|
2020-02-17 17:47:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
border.Alpha = (float)Math.Clamp((hitObject.StartTime - Time.Current) / 500, 0, 1);
|
|
|
|
}
|
|
|
|
|
2020-02-19 22:32:56 +08:00
|
|
|
private Drawable getFruitFor(FruitVisualRepresentation representation)
|
2020-02-17 17:47:22 +08:00
|
|
|
{
|
|
|
|
switch (representation)
|
|
|
|
{
|
|
|
|
case FruitVisualRepresentation.Pear:
|
2020-02-19 22:32:56 +08:00
|
|
|
return new PearPiece();
|
2020-02-17 17:47:22 +08:00
|
|
|
|
|
|
|
case FruitVisualRepresentation.Grape:
|
2020-02-19 22:32:56 +08:00
|
|
|
return new GrapePiece();
|
|
|
|
|
|
|
|
case FruitVisualRepresentation.Pineapple:
|
|
|
|
return new PineapplePiece();
|
2020-02-17 17:47:22 +08:00
|
|
|
|
|
|
|
case FruitVisualRepresentation.Banana:
|
2020-02-19 22:32:56 +08:00
|
|
|
return new BananaPiece();
|
2020-02-19 09:28:20 +08:00
|
|
|
|
2020-02-19 22:32:56 +08:00
|
|
|
case FruitVisualRepresentation.Raspberry:
|
|
|
|
return new RaspberryPiece();
|
2020-02-17 17:47:22 +08:00
|
|
|
}
|
2020-02-19 22:32:56 +08:00
|
|
|
|
|
|
|
return Empty();
|
2020-02-17 17:47:22 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|