2020-02-19 14:32:56 +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.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-07 03:35:24 +00:00
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning.Default
|
2020-02-19 14:32:56 +00:00
|
|
|
{
|
|
|
|
public abstract class PulpFormation : CompositeDrawable
|
|
|
|
{
|
2020-12-07 04:56:22 +00:00
|
|
|
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
|
2020-02-19 14:32:56 +00:00
|
|
|
|
|
|
|
protected const float LARGE_PULP_3 = 16f * FruitPiece.RADIUS_ADJUST;
|
|
|
|
protected const float DISTANCE_FROM_CENTRE_3 = 0.15f;
|
|
|
|
|
|
|
|
protected const float LARGE_PULP_4 = LARGE_PULP_3 * 0.925f;
|
|
|
|
protected const float DISTANCE_FROM_CENTRE_4 = DISTANCE_FROM_CENTRE_3 / 0.925f;
|
|
|
|
|
|
|
|
protected const float SMALL_PULP = LARGE_PULP_3 / 2;
|
|
|
|
|
2020-12-08 01:32:46 +00:00
|
|
|
private int pulpsInUse;
|
2020-12-07 04:56:22 +00:00
|
|
|
|
2020-02-19 14:32:56 +00:00
|
|
|
protected PulpFormation()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
protected static Vector2 PositionAt(float angle, float distance) => new Vector2(
|
|
|
|
distance * MathF.Sin(angle * MathF.PI / 180),
|
|
|
|
distance * MathF.Cos(angle * MathF.PI / 180));
|
|
|
|
|
2020-12-07 04:56:22 +00:00
|
|
|
protected void Clear()
|
|
|
|
{
|
2020-12-08 01:32:46 +00:00
|
|
|
for (int i = 0; i < pulpsInUse; i++)
|
|
|
|
InternalChildren[i].Alpha = 0;
|
|
|
|
pulpsInUse = 0;
|
2020-12-07 04:56:22 +00:00
|
|
|
}
|
|
|
|
|
2020-12-08 01:32:46 +00:00
|
|
|
protected void AddPulp(Vector2 position, Vector2 size)
|
2020-02-19 14:32:56 +00:00
|
|
|
{
|
2020-12-08 01:32:46 +00:00
|
|
|
if (pulpsInUse == InternalChildren.Count)
|
2020-12-07 04:56:22 +00:00
|
|
|
AddInternal(new Pulp { AccentColour = { BindTarget = AccentColour } });
|
|
|
|
|
2020-12-08 01:32:46 +00:00
|
|
|
var pulp = InternalChildren[pulpsInUse];
|
2020-12-07 04:56:22 +00:00
|
|
|
pulp.Position = position;
|
|
|
|
pulp.Size = size;
|
|
|
|
pulp.Alpha = 1;
|
|
|
|
|
2020-12-08 01:32:46 +00:00
|
|
|
pulpsInUse++;
|
2020-02-19 14:32:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|