1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Add basic HitRenderer framework.

This commit is contained in:
Dean Herbert 2016-09-02 19:25:13 +09:00
parent ec25a50249
commit 2ea5a5c675
5 changed files with 122 additions and 6 deletions

@ -1 +1 @@
Subproject commit 907c74a83cf68208e1bb959ea4a3332ebbd03a22
Subproject commit ea125b07f36cb1f77666fd4f2bd888138f7a5032

View File

@ -0,0 +1,14 @@
//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.Collections.Generic;
using osu.Framework.Graphics.Containers;
using osu.Game.Beatmaps.Objects;
namespace osu.Game.GameModes.Play
{
public abstract class HitRenderer : LargeContainer
{
public abstract List<BaseHit> Objects { get; set; }
}
}

View File

@ -0,0 +1,76 @@
//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.Collections.Generic;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Transformations;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using OpenTK;
namespace osu.Game.GameModes.Play.Osu
{
public class OsuHitRenderer : HitRenderer
{
List<OsuBaseHit> objects;
private OsuPlayfield playfield;
public override List<BaseHit> Objects
{
get
{
return objects.ConvertAll(o => (BaseHit)o);
}
set
{
//osu! mode requires all objects to be of OsuBaseHit type.
objects = value.ConvertAll(o => (OsuBaseHit)o);
if (Parent != null)
Load();
}
}
public override void Load()
{
base.Load();
if (playfield == null)
Add(playfield = new OsuPlayfield());
else
playfield.Clear();
if (objects == null) return;
foreach (OsuBaseHit h in objects)
{
//render stuff!
Sprite s = new Sprite(Game.Textures.Get(@"menu-osu"))
{
Origin = Anchor.Centre,
Scale = 0.2f,
Alpha = 0,
Position = h.Position
};
s.Transformations.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 0, EndValue = 1 });
s.Transformations.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
playfield.Add(s);
}
}
}
public class OsuPlayfield : Container
{
public OsuPlayfield()
{
Size = new Vector2(512, 384);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
}
}
}

View File

@ -5,22 +5,46 @@ using System.Collections.Generic;
using osu.Framework.GameModes;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Objects;
using osu.Game.Beatmaps.Objects.Osu;
using osu.Game.GameModes.Play.Osu;
using OpenTK;
namespace osu.Game.GameModes.Play
{
class PlayTest : GameMode
public class PlayTest : GameMode
{
public override void Load()
{
base.Load();
Beatmap beatmap = new Beatmap();
beatmap.HitObjects = new List<Beatmaps.Objects.BaseHit>()
Beatmap beatmap = new Beatmap
{
new HitObject() { },
HitObjects = new List<BaseHit>()
{
new Circle()
{
StartTime = 500,
Position = new Vector2(0, 0)
},
new Circle()
{
StartTime = 1000,
Position = new Vector2(512, 0)
},
new Circle()
{
StartTime = 1500,
Position = new Vector2(512, 384)
},
new Circle()
{
StartTime = 2000,
Position = new Vector2(0, 384)
},
}
};
Add(new OsuHitRenderer() { Objects = beatmap.HitObjects });
}
}
}

View File

@ -73,6 +73,8 @@
<Compile Include="GameModes\Menu\ButtonSystem.cs" />
<Compile Include="GameModes\Menu\MainMenu.cs" />
<Compile Include="GameModes\FieldTest.cs" />
<Compile Include="GameModes\Play\HitRenderer.cs" />
<Compile Include="GameModes\Play\Osu\OsuHitRenderer.cs" />
<Compile Include="GameModes\Play\PlayTest.cs" />
<Compile Include="Graphics\Containers\OsuComponent.cs" />
<Compile Include="Graphics\Containers\OsuGameMode.cs" />