mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Combine triangle system implementations.
This commit is contained in:
@ -14,9 +14,8 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
|||||||
{
|
{
|
||||||
public class CirclePiece : Container
|
public class CirclePiece : Container
|
||||||
{
|
{
|
||||||
|
|
||||||
private Sprite disc;
|
private Sprite disc;
|
||||||
private Triangles triangles;
|
|
||||||
|
|
||||||
public Func<bool> Hit;
|
public Func<bool> Hit;
|
||||||
|
|
||||||
@ -36,10 +35,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
|||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre
|
Origin = Anchor.Centre
|
||||||
},
|
},
|
||||||
triangles = new Triangles
|
new TrianglesPiece
|
||||||
{
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
BlendingMode = BlendingMode.Additive,
|
BlendingMode = BlendingMode.Additive,
|
||||||
RelativeSizeAxes = Axes.Both
|
Alpha = 0.5f,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -21,10 +21,11 @@ namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Triangles
|
new TrianglesPiece
|
||||||
{
|
{
|
||||||
BlendingMode = BlendingMode.Additive,
|
BlendingMode = BlendingMode.Additive,
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.1f,
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
||||||
|
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Graphics;
|
|
||||||
using osu.Framework.Graphics.Containers;
|
|
||||||
using osu.Framework.Graphics.Sprites;
|
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.MathUtils;
|
|
||||||
using OpenTK;
|
|
||||||
|
|
||||||
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
|
||||||
{
|
|
||||||
public class Triangles : Container<Triangle>
|
|
||||||
{
|
|
||||||
public override bool HandleInput => false;
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
|
|
||||||
const float size = 100;
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
Add(new Triangle
|
|
||||||
{
|
|
||||||
Origin = Anchor.Centre,
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
|
|
||||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
|
||||||
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
|
|
||||||
Size = new Vector2(size, 0.866f * size),
|
|
||||||
Alpha = RNG.NextSingle() * 0.3f,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
|
||||||
{
|
|
||||||
base.Update();
|
|
||||||
|
|
||||||
foreach (Drawable d in Children)
|
|
||||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 2880)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
|
|
||||||
|
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
|
||||||
|
{
|
||||||
|
public class TrianglesPiece : Triangles
|
||||||
|
{
|
||||||
|
protected override bool ExpireOffScreenTriangles => false;
|
||||||
|
protected override bool CreateNewTriangles => false;
|
||||||
|
protected override float SpawnRatio => 0.5f;
|
||||||
|
|
||||||
|
public TrianglesPiece()
|
||||||
|
{
|
||||||
|
TriangleScale = 1.2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
if (IsPresent)
|
||||||
|
base.Update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -62,7 +62,7 @@
|
|||||||
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
|
<Compile Include="Objects\Drawables\Pieces\RingPiece.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\SliderBouncer.cs" />
|
<Compile Include="Objects\Drawables\Pieces\SliderBouncer.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\SpinnerDisc.cs" />
|
<Compile Include="Objects\Drawables\Pieces\SpinnerDisc.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\Triangles.cs" />
|
<Compile Include="Objects\Drawables\Pieces\TrianglesPiece.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\SliderBall.cs" />
|
<Compile Include="Objects\Drawables\Pieces\SliderBall.cs" />
|
||||||
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
|
<Compile Include="Objects\Drawables\Pieces\SliderBody.cs" />
|
||||||
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
<Compile Include="Objects\OsuHitObjectParser.cs" />
|
||||||
|
@ -2,12 +2,10 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Textures;
|
|
||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -22,6 +20,21 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
public Color4 ColourLight = Color4.White;
|
public Color4 ColourLight = Color4.White;
|
||||||
public Color4 ColourDark = Color4.Black;
|
public Color4 ColourDark = Color4.Black;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we want to expire triangles as they exit our draw area completely.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual bool ExpireOffScreenTriangles => true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Whether we should create new triangles as others expire.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual bool CreateNewTriangles => true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The amount of triangles we want compared to the default distribution.
|
||||||
|
/// </summary>
|
||||||
|
protected virtual float SpawnRatio => 1;
|
||||||
|
|
||||||
private float triangleScale = 1;
|
private float triangleScale = 1;
|
||||||
|
|
||||||
public float TriangleScale
|
public float TriangleScale
|
||||||
@ -29,9 +42,11 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
get { return triangleScale; }
|
get { return triangleScale; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
|
float change = value / triangleScale;
|
||||||
triangleScale = value;
|
triangleScale = value;
|
||||||
|
|
||||||
Children.ForEach(t => t.ScaleTo(triangleScale));
|
if (change != 1)
|
||||||
|
Children.ForEach(t => t.Scale *= change);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,20 +57,20 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
addTriangle(true);
|
addTriangle(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale));
|
private int aimTriangleCount => (int)(DrawWidth * DrawHeight * 0.002f / (triangleScale * triangleScale) * SpawnRatio);
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
base.Update();
|
base.Update();
|
||||||
|
|
||||||
foreach (Drawable d in Children)
|
foreach (var t in Children)
|
||||||
{
|
{
|
||||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
|
t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
|
||||||
if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
|
if (ExpireOffScreenTriangles && t.DrawPosition.Y + t.DrawSize.Y * t.Scale.Y < 0)
|
||||||
d.Expire();
|
t.Expire();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (Children.Count() < aimTriangleCount)
|
while (CreateNewTriangles && Children.Count() < aimTriangleCount)
|
||||||
addTriangle(false);
|
addTriangle(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,8 +92,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
RelativePositionAxes = Axes.Both,
|
RelativePositionAxes = Axes.Both,
|
||||||
Scale = new Vector2(scale),
|
Scale = new Vector2(scale),
|
||||||
EdgeSmoothness = new Vector2(1),
|
EdgeSmoothness = new Vector2(1),
|
||||||
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
|
|
||||||
Colour = GetTriangleShade(),
|
Colour = GetTriangleShade(),
|
||||||
|
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
|
||||||
Size = new Vector2(size, 0.866f * size),
|
Size = new Vector2(size, 0.866f * size),
|
||||||
Depth = scale,
|
Depth = scale,
|
||||||
};
|
};
|
||||||
@ -89,8 +104,8 @@ namespace osu.Game.Graphics.Backgrounds
|
|||||||
private void addTriangle(bool randomY)
|
private void addTriangle(bool randomY)
|
||||||
{
|
{
|
||||||
var sprite = CreateTriangle();
|
var sprite = CreateTriangle();
|
||||||
var triangleHeight = sprite.DrawHeight / DrawHeight;
|
float triangleHeight = (sprite.DrawHeight / DrawHeight);
|
||||||
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? (RNG.NextSingle() * (1 + triangleHeight) - triangleHeight) : 1);
|
sprite.Position = new Vector2(RNG.NextSingle(), randomY ? RNG.NextSingle() * (1 + triangleHeight) - triangleHeight : 1);
|
||||||
Add(sprite);
|
Add(sprite);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user