mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 14:13:18 +08:00
Add basic TaikoHitRenderer.
This commit is contained in:
parent
677a1b0e56
commit
93744f7372
@ -7,6 +7,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.GameModes.Play.Osu;
|
||||
using osu.Game.GameModes.Play.Taiko;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
@ -23,28 +24,29 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 500,
|
||||
StartTime = 1500,
|
||||
Position = new Vector2(0, 0)
|
||||
},
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 1000,
|
||||
StartTime = 2000,
|
||||
Position = new Vector2(512, 0)
|
||||
},
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 1500,
|
||||
StartTime = 2500,
|
||||
Position = new Vector2(512, 384)
|
||||
},
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 2000,
|
||||
StartTime = 3000,
|
||||
Position = new Vector2(0, 384)
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
Add(new OsuHitRenderer() { Objects = beatmap.HitObjects });
|
||||
Add(new TaikoHitRenderer() { Objects = beatmap.HitObjects });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
116
osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs
Normal file
116
osu.Game/GameModes/Play/Taiko/TaikoHitRenderer.cs
Normal file
@ -0,0 +1,116 @@
|
||||
//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;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.Beatmaps.Objects.Taiko;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Taiko
|
||||
{
|
||||
public class TaikoHitRenderer : HitRenderer
|
||||
{
|
||||
List<TaikoBaseHit> objects;
|
||||
private TaikoPlayfield playfield;
|
||||
|
||||
public override List<BaseHit> Objects
|
||||
{
|
||||
get
|
||||
{
|
||||
return objects.ConvertAll(o => (BaseHit)o);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
//osu! mode requires all objects to be of TaikoBaseHit type.
|
||||
objects = value.ConvertAll(convertForTaiko);
|
||||
|
||||
if (Parent != null)
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
private TaikoBaseHit convertForTaiko(BaseHit input)
|
||||
{
|
||||
TaikoBaseHit h = input as TaikoBaseHit;
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuBaseHit o = input as OsuBaseHit;
|
||||
|
||||
if (o == null) throw new Exception(@"Can't convert!");
|
||||
|
||||
h = new TaikoBaseHit()
|
||||
{
|
||||
StartTime = o.StartTime
|
||||
};
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
if (playfield == null)
|
||||
Add(playfield = new TaikoPlayfield());
|
||||
else
|
||||
playfield.Clear();
|
||||
|
||||
if (objects == null) return;
|
||||
|
||||
foreach (TaikoBaseHit h in objects)
|
||||
{
|
||||
//render stuff!
|
||||
Sprite s = new Sprite(Game.Textures.Get(@"menu-osu"))
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Scale = 0.2f,
|
||||
PositionMode = InheritMode.XY,
|
||||
Position = new Vector2(1.1f, 0.5f)
|
||||
};
|
||||
|
||||
s.Transformations.Add(new TransformPosition(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(1.1f, 0.5f), EndValue = new Vector2(0.1f, 0.5f) });
|
||||
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 TaikoPlayfield : Container
|
||||
{
|
||||
public TaikoPlayfield()
|
||||
{
|
||||
SizeMode = InheritMode.X;
|
||||
Size = new Vector2(1, 100);
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
Add(new Box() { SizeMode = InheritMode.XY, Alpha = 0.5f });
|
||||
|
||||
Add(new Sprite(Game.Textures.Get(@"menu-osu"))
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Scale = 0.2f,
|
||||
PositionMode = InheritMode.XY,
|
||||
Position = new Vector2(0.1f, 0.5f),
|
||||
Colour = Color4.Gray
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -76,6 +76,7 @@
|
||||
<Compile Include="GameModes\Play\HitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Osu\OsuHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\PlayTest.cs" />
|
||||
<Compile Include="GameModes\Play\Taiko\TaikoHitRenderer.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuComponent.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuGameMode.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuLargeComponent.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user