2020-02-17 09:47:22 +00: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.Framework.Graphics.Shapes;
|
2020-03-26 02:38:41 +00:00
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2020-02-17 09:47:22 +00:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-02-19 09:01:59 +00:00
|
|
|
namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
2020-02-17 09:47:22 +00:00
|
|
|
{
|
|
|
|
internal class FruitPiece : CompositeDrawable
|
|
|
|
{
|
2020-02-19 00:39:56 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Because we're adding a border around the fruit, we need to scale down some.
|
|
|
|
/// </summary>
|
2020-02-19 14:32:56 +00:00
|
|
|
public const float RADIUS_ADJUST = 1.1f;
|
2020-02-19 00:39:56 +00:00
|
|
|
|
2020-02-17 09:47:22 +00:00
|
|
|
private Circle border;
|
|
|
|
private CatchHitObject hitObject;
|
|
|
|
|
|
|
|
public FruitPiece()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-04-04 21:02:33 +00:00
|
|
|
private void load(DrawableHitObject drawableObject)
|
2020-02-17 09:47:22 +00:00
|
|
|
{
|
|
|
|
DrawableCatchHitObject drawableCatchObject = (DrawableCatchHitObject)drawableObject;
|
|
|
|
hitObject = drawableCatchObject.HitObject;
|
|
|
|
|
|
|
|
AddRangeInternal(new[]
|
|
|
|
{
|
2020-02-19 14:32:56 +00:00
|
|
|
getFruitFor(drawableCatchObject.HitObject.VisualRepresentation),
|
2020-02-17 09:47:22 +00:00
|
|
|
border = new Circle
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
BorderColour = Color4.White,
|
2020-02-19 14:32:56 +00:00
|
|
|
BorderThickness = 6f * RADIUS_ADJUST,
|
2020-02-19 09:01:59 +00:00
|
|
|
Children = new Drawable[]
|
2020-02-17 09:47:22 +00:00
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
AlwaysPresent = true,
|
|
|
|
Alpha = 0,
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
if (hitObject.HyperDash)
|
|
|
|
{
|
2020-02-26 09:45:06 +00:00
|
|
|
AddInternal(new Circle
|
2020-02-17 09:47:22 +00:00
|
|
|
{
|
2020-02-26 09:45:06 +00:00
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-02-17 09:47:22 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2020-04-08 11:23:29 +00:00
|
|
|
BorderColour = Catcher.DEFAULT_HYPER_DASH_COLOUR,
|
2020-02-26 09:45:06 +00:00
|
|
|
BorderThickness = 12f * RADIUS_ADJUST,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new Box
|
|
|
|
{
|
|
|
|
AlwaysPresent = true,
|
|
|
|
Alpha = 0.3f,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-04-08 11:23:29 +00:00
|
|
|
Colour = Catcher.DEFAULT_HYPER_DASH_COLOUR,
|
2020-02-26 09:45:06 +00:00
|
|
|
}
|
|
|
|
}
|
2020-02-17 09:47:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Update()
|
|
|
|
{
|
|
|
|
base.Update();
|
|
|
|
border.Alpha = (float)Math.Clamp((hitObject.StartTime - Time.Current) / 500, 0, 1);
|
|
|
|
}
|
|
|
|
|
2020-02-19 14:32:56 +00:00
|
|
|
private Drawable getFruitFor(FruitVisualRepresentation representation)
|
2020-02-17 09:47:22 +00:00
|
|
|
{
|
|
|
|
switch (representation)
|
|
|
|
{
|
|
|
|
case FruitVisualRepresentation.Pear:
|
2020-02-19 14:32:56 +00:00
|
|
|
return new PearPiece();
|
2020-02-17 09:47:22 +00:00
|
|
|
|
|
|
|
case FruitVisualRepresentation.Grape:
|
2020-02-19 14:32:56 +00:00
|
|
|
return new GrapePiece();
|
|
|
|
|
|
|
|
case FruitVisualRepresentation.Pineapple:
|
|
|
|
return new PineapplePiece();
|
2020-02-17 09:47:22 +00:00
|
|
|
|
|
|
|
case FruitVisualRepresentation.Banana:
|
2020-02-19 14:32:56 +00:00
|
|
|
return new BananaPiece();
|
2020-02-19 01:28:20 +00:00
|
|
|
|
2020-02-19 14:32:56 +00:00
|
|
|
case FruitVisualRepresentation.Raspberry:
|
|
|
|
return new RaspberryPiece();
|
2020-02-17 09:47:22 +00:00
|
|
|
}
|
2020-02-19 14:32:56 +00:00
|
|
|
|
|
|
|
return Empty();
|
2020-02-17 09:47:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|