mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 18:12:56 +08:00
Make Triangles more flexible and more random.
This commit is contained in:
parent
6554a4ea58
commit
11f958030f
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Textures;
|
|||||||
using osu.Framework.MathUtils;
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -128,45 +129,5 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Triangles : Container
|
|
||||||
{
|
|
||||||
private Texture triangle;
|
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
|
||||||
private void load(TextureStore textures)
|
|
||||||
{
|
|
||||||
triangle = textures.Get(@"Play/osu/triangle@2x");
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
|
||||||
{
|
|
||||||
base.LoadComplete();
|
|
||||||
for (int i = 0; i < 10; i++)
|
|
||||||
{
|
|
||||||
Add(new Sprite
|
|
||||||
{
|
|
||||||
Texture = triangle,
|
|
||||||
Origin = Anchor.TopCentre,
|
|
||||||
RelativePositionAxes = Axes.Both,
|
|
||||||
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
|
|
||||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
|
||||||
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 / 880)));
|
|
||||||
if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
|
|
||||||
d.MoveToY(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
63
osu.Game/Graphics/Backgrounds/Triangles.cs
Normal file
63
osu.Game/Graphics/Backgrounds/Triangles.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
|
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.Graphics.Backgrounds
|
||||||
|
{
|
||||||
|
public class Triangles : Container
|
||||||
|
{
|
||||||
|
private Texture triangle;
|
||||||
|
|
||||||
|
public Triangles()
|
||||||
|
{
|
||||||
|
Masking = true;
|
||||||
|
Alpha = 0.3f;
|
||||||
|
}
|
||||||
|
|
||||||
|
[BackgroundDependencyLoader]
|
||||||
|
private void load(TextureStore textures)
|
||||||
|
{
|
||||||
|
triangle = textures.Get(@"Play/osu/triangle@2x");
|
||||||
|
}
|
||||||
|
|
||||||
|
private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800);
|
||||||
|
|
||||||
|
protected override void Update()
|
||||||
|
{
|
||||||
|
base.Update();
|
||||||
|
|
||||||
|
foreach (Drawable d in Children)
|
||||||
|
{
|
||||||
|
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 880)));
|
||||||
|
if (d.DrawPosition.Y + d.DrawSize.Y * d.Scale.Y < 0)
|
||||||
|
d.Expire();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool useRandomX = Children.Count() < aimTriangleCount / 2;
|
||||||
|
while (Children.Count() < aimTriangleCount)
|
||||||
|
addTriangle(useRandomX);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void addTriangle(bool randomX)
|
||||||
|
{
|
||||||
|
Add(new Sprite
|
||||||
|
{
|
||||||
|
Texture = triangle,
|
||||||
|
Origin = Anchor.TopCentre,
|
||||||
|
RelativePositionAxes = Axes.Both,
|
||||||
|
Position = new Vector2(RNG.NextSingle(), randomX ? RNG.NextSingle() : 1),
|
||||||
|
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
||||||
|
Alpha = RNG.NextSingle()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,8 +6,10 @@ using osu.Framework.Graphics;
|
|||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.Transformations;
|
||||||
using osu.Framework.Input;
|
using osu.Framework.Input;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
|
|
||||||
@ -64,8 +66,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
HoverBackground = new Box
|
HoverBackground = new Box
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
BlendingMode = BlendingMode.Additive,
|
Colour = new Color4(80, 80, 80, 180),
|
||||||
Colour = new Color4(60, 60, 60, 255),
|
|
||||||
Alpha = 0,
|
Alpha = 0,
|
||||||
},
|
},
|
||||||
Flow = new FlowContainer
|
Flow = new FlowContainer
|
||||||
@ -131,21 +132,43 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
protected override bool OnClick(InputState state)
|
protected override bool OnClick(InputState state)
|
||||||
{
|
{
|
||||||
Action?.Invoke();
|
Action?.Invoke();
|
||||||
HoverBackground.FlashColour(Color4.White, 400);
|
HoverBackground.FlashColour(new Color4(255, 255, 255, 180), 800, EasingTypes.OutQuint);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnHover(InputState state)
|
protected override bool OnHover(InputState state)
|
||||||
{
|
{
|
||||||
HoverBackground.FadeTo(0.4f, 200);
|
HoverBackground.FadeIn(200);
|
||||||
tooltipContainer.FadeIn(100);
|
tooltipContainer.FadeIn(100);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnHoverLost(InputState state)
|
protected override void OnHoverLost(InputState state)
|
||||||
{
|
{
|
||||||
HoverBackground.FadeTo(0, 200);
|
HoverBackground.FadeOut(200);
|
||||||
tooltipContainer.FadeOut(100);
|
tooltipContainer.FadeOut(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class OpaqueBackground : Container
|
||||||
|
{
|
||||||
|
public OpaqueBackground()
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
|
Children = new Drawable[]
|
||||||
|
{
|
||||||
|
new Box
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Colour = new Color4(30, 30, 30, 255)
|
||||||
|
},
|
||||||
|
new Triangles
|
||||||
|
{
|
||||||
|
RelativeSizeAxes = Axes.Both,
|
||||||
|
Alpha = 0.05f,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.Transformations;
|
using osu.Framework.Graphics.Transformations;
|
||||||
|
using osu.Game.Graphics.Backgrounds;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
@ -31,11 +32,7 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new Box
|
new OpaqueBackground(),
|
||||||
{
|
|
||||||
RelativeSizeAxes = Axes.Both,
|
|
||||||
Colour = new Color4(20, 20, 20, 255)
|
|
||||||
},
|
|
||||||
modeButtons = new FlowContainer
|
modeButtons = new FlowContainer
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Y,
|
RelativeSizeAxes = Axes.Y,
|
||||||
|
@ -27,6 +27,8 @@ namespace osu.Game.Overlays.Toolbar
|
|||||||
{
|
{
|
||||||
DrawableText.Font = @"Exo2.0-MediumItalic";
|
DrawableText.Font = @"Exo2.0-MediumItalic";
|
||||||
|
|
||||||
|
Add(new OpaqueBackground { Depth = 1 });
|
||||||
|
|
||||||
Flow.Add(avatar = new Avatar());
|
Flow.Add(avatar = new Avatar());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,6 +64,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
<Compile Include="Beatmaps\Drawables\BeatmapBackgroundSprite.cs" />
|
||||||
|
<Compile Include="Graphics\Backgrounds\Triangles.cs" />
|
||||||
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
<Compile Include="Graphics\Cursor\CursorTrail.cs" />
|
||||||
<Compile Include="Graphics\UserInterface\BackButton.cs" />
|
<Compile Include="Graphics\UserInterface\BackButton.cs" />
|
||||||
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
<Compile Include="Modes\Objects\HitObjectParser.cs" />
|
||||||
|
Loading…
Reference in New Issue
Block a user