1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Skinning/Default/PulpFormation.cs

56 lines
1.7 KiB
C#
Raw Normal View History

// 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 11:35:24 +08:00
namespace osu.Game.Rulesets.Catch.Skinning.Default
{
public abstract class PulpFormation : CompositeDrawable
{
public readonly Bindable<Color4> AccentColour = new Bindable<Color4>();
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;
private int numPulps;
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));
protected void Clear()
{
for (; numPulps > 0; numPulps--)
InternalChildren[numPulps - 1].Alpha = 0;
}
protected void Add(Vector2 position, Vector2 size)
{
if (numPulps == InternalChildren.Count)
AddInternal(new Pulp { AccentColour = { BindTarget = AccentColour } });
var pulp = InternalChildren[numPulps];
pulp.Position = position;
pulp.Size = size;
pulp.Alpha = 1;
numPulps++;
}
}
}