mirror of
https://github.com/ppy/osu
synced 2024-12-26 00:32:52 +00:00
Add remaining HitRenderers.
Many general improvements.
This commit is contained in:
parent
97d101310d
commit
9e76feb159
87
osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs
Normal file
87
osu.Game/GameModes/Play/Catch/CatchHitRenderer.cs
Normal file
@ -0,0 +1,87 @@
|
||||
//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.Transformations;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.Beatmaps.Objects.Catch;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Catch
|
||||
{
|
||||
public class CatchHitRenderer : HitRenderer
|
||||
{
|
||||
List<CatchBaseHit> objects;
|
||||
private CatchPlayfield playfield;
|
||||
|
||||
public override List<BaseHit> Objects
|
||||
{
|
||||
get
|
||||
{
|
||||
return objects.ConvertAll(o => (BaseHit)o);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
//osu! mode requires all objects to be of CatchBaseHit type.
|
||||
objects = value.ConvertAll(convertForCatch);
|
||||
|
||||
if (Parent != null)
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
private CatchBaseHit convertForCatch(BaseHit input)
|
||||
{
|
||||
CatchBaseHit h = input as CatchBaseHit;
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuBaseHit o = input as OsuBaseHit;
|
||||
|
||||
if (o == null) throw new Exception(@"Can't convert!");
|
||||
|
||||
h = new Fruit()
|
||||
{
|
||||
StartTime = o.StartTime,
|
||||
Position = o.Position.X
|
||||
};
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
if (playfield == null)
|
||||
Add(playfield = new CatchPlayfield());
|
||||
else
|
||||
playfield.Clear();
|
||||
|
||||
if (objects == null) return;
|
||||
|
||||
foreach (CatchBaseHit h in objects)
|
||||
{
|
||||
//render stuff!
|
||||
Sprite s = new Sprite(Game.Textures.Get(@"menu-osu"))
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Scale = 0.1f,
|
||||
PositionMode = InheritMode.Y,
|
||||
Position = new Vector2(h.Position, -0.1f)
|
||||
};
|
||||
|
||||
s.Transformations.Add(new TransformPosition(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
30
osu.Game/GameModes/Play/Catch/CatchPlayfield.cs
Normal file
30
osu.Game/GameModes/Play/Catch/CatchPlayfield.cs
Normal file
@ -0,0 +1,30 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Catch
|
||||
{
|
||||
public class CatchPlayfield : Playfield
|
||||
{
|
||||
public CatchPlayfield()
|
||||
{
|
||||
SizeMode = InheritMode.Y;
|
||||
Size = new Vector2(512, 0.9f);
|
||||
Anchor = Anchor.BottomCentre;
|
||||
Origin = Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
Add(new Box() { SizeMode = InheritMode.XY, Alpha = 0.5f });
|
||||
}
|
||||
}
|
||||
}
|
@ -2,7 +2,10 @@
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Batches;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
@ -10,5 +13,12 @@ namespace osu.Game.GameModes.Play
|
||||
public abstract class HitRenderer : LargeContainer
|
||||
{
|
||||
public abstract List<BaseHit> Objects { get; set; }
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
Add(new Box() { SizeMode = InheritMode.XY, Alpha = 0.1f, Scale = 0.99f });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
93
osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs
Normal file
93
osu.Game/GameModes/Play/Mania/ManiaHitRenderer.cs
Normal file
@ -0,0 +1,93 @@
|
||||
//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.Transformations;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.Beatmaps.Objects.Mania;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Mania
|
||||
{
|
||||
public class ManiaHitRenderer : HitRenderer
|
||||
{
|
||||
private readonly int columns;
|
||||
List<ManiaBaseHit> objects;
|
||||
private ManiaPlayfield playfield;
|
||||
|
||||
public ManiaHitRenderer(int columns = 5)
|
||||
{
|
||||
this.columns = columns;
|
||||
}
|
||||
|
||||
public override List<BaseHit> Objects
|
||||
{
|
||||
get
|
||||
{
|
||||
return objects.ConvertAll(o => (BaseHit)o);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
//osu! mode requires all objects to be of ManiaBaseHit type.
|
||||
objects = value.ConvertAll(convertForMania);
|
||||
|
||||
if (Parent != null)
|
||||
Load();
|
||||
}
|
||||
}
|
||||
|
||||
private ManiaBaseHit convertForMania(BaseHit input)
|
||||
{
|
||||
ManiaBaseHit h = input as ManiaBaseHit;
|
||||
|
||||
if (h == null)
|
||||
{
|
||||
OsuBaseHit o = input as OsuBaseHit;
|
||||
|
||||
if (o == null) throw new Exception(@"Can't convert!");
|
||||
|
||||
h = new Note()
|
||||
{
|
||||
StartTime = o.StartTime,
|
||||
Column = (int)Math.Round(o.Position.X / 512 * columns)
|
||||
};
|
||||
}
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
if (playfield == null)
|
||||
Add(playfield = new ManiaPlayfield(columns));
|
||||
else
|
||||
playfield.Clear();
|
||||
|
||||
if (objects == null) return;
|
||||
|
||||
foreach (ManiaBaseHit h in objects)
|
||||
{
|
||||
//render stuff!
|
||||
Sprite s = new Sprite(Game.Textures.Get(@"menu-osu"))
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Scale = 0.1f,
|
||||
PositionMode = InheritMode.XY,
|
||||
Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f)
|
||||
};
|
||||
|
||||
s.Transformations.Add(new TransformPositionY(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = -0.1f, EndValue = 0.9f });
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
44
osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs
Normal file
44
osu.Game/GameModes/Play/Mania/ManiaPlayfield.cs
Normal file
@ -0,0 +1,44 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Drawables;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Mania
|
||||
{
|
||||
public class ManiaPlayfield : Playfield
|
||||
{
|
||||
private readonly int columns;
|
||||
|
||||
public ManiaPlayfield(int columns)
|
||||
{
|
||||
this.columns = columns;
|
||||
SizeMode = InheritMode.XY;
|
||||
Size = new Vector2(columns / 20f, 1f);
|
||||
Anchor = Anchor.BottomCentre;
|
||||
Origin = Anchor.BottomCentre;
|
||||
}
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
base.Load();
|
||||
|
||||
Add(new Box() { SizeMode = InheritMode.XY, Alpha = 0.5f });
|
||||
|
||||
for (int i = 0; i < columns; i++)
|
||||
Add(new Box()
|
||||
{
|
||||
SizeMode = InheritMode.Y,
|
||||
Size = new Vector2(2, 1),
|
||||
PositionMode = InheritMode.XY,
|
||||
Position = new Vector2((float)i / columns, 0),
|
||||
Alpha = 0.5f,
|
||||
Colour = Color4.Black
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,7 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
Sprite s = new Sprite(Game.Textures.Get(@"menu-osu"))
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Scale = 0.2f,
|
||||
Scale = 0.1f,
|
||||
Alpha = 0,
|
||||
Position = h.Position
|
||||
};
|
||||
|
@ -8,7 +8,7 @@ using OpenTK;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Osu
|
||||
{
|
||||
public class OsuPlayfield : Container
|
||||
public class OsuPlayfield : Playfield
|
||||
{
|
||||
public OsuPlayfield()
|
||||
{
|
||||
|
@ -3,11 +3,15 @@
|
||||
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.GameModes;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.GameModes.Play.Catch;
|
||||
using osu.Game.GameModes.Play.Osu;
|
||||
using osu.Game.GameModes.Play.Taiko;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.GameModes.Play.Mania;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
@ -18,35 +22,56 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
base.Load();
|
||||
|
||||
List<BaseHit> objects = new List<BaseHit>();
|
||||
|
||||
int time = 0;
|
||||
for (int i = 0; i < 100; i++)
|
||||
{
|
||||
objects.Add(new Circle()
|
||||
{
|
||||
StartTime = time,
|
||||
Position = new Vector2(RNG.Next(0, 512), RNG.Next(0, 384))
|
||||
});
|
||||
|
||||
time += RNG.Next(50, 500);
|
||||
}
|
||||
|
||||
Beatmap beatmap = new Beatmap
|
||||
{
|
||||
HitObjects = new List<BaseHit>()
|
||||
{
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 1500,
|
||||
Position = new Vector2(0, 0)
|
||||
},
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 2000,
|
||||
Position = new Vector2(512, 0)
|
||||
},
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 2500,
|
||||
Position = new Vector2(512, 384)
|
||||
},
|
||||
new Circle()
|
||||
{
|
||||
StartTime = 3000,
|
||||
Position = new Vector2(0, 384)
|
||||
},
|
||||
}
|
||||
HitObjects = objects
|
||||
};
|
||||
|
||||
Add(new OsuHitRenderer() { Objects = beatmap.HitObjects });
|
||||
Add(new TaikoHitRenderer() { Objects = beatmap.HitObjects });
|
||||
Add(new OsuHitRenderer()
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Scale = 0.5f,
|
||||
Anchor = Anchor.TopLeft,
|
||||
Origin = Anchor.TopLeft
|
||||
});
|
||||
|
||||
Add(new TaikoHitRenderer()
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Scale = 0.5f,
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight
|
||||
});
|
||||
|
||||
Add(new CatchHitRenderer()
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Scale = 0.5f,
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft
|
||||
});
|
||||
|
||||
Add(new ManiaHitRenderer()
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Scale = 0.5f,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
osu.Game/GameModes/Play/Playfield.cs
Normal file
16
osu.Game/GameModes/Play/Playfield.cs
Normal file
@ -0,0 +1,16 @@
|
||||
//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 System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public class Playfield : MaskingContainer
|
||||
{
|
||||
}
|
||||
}
|
@ -76,7 +76,7 @@ namespace osu.Game.GameModes.Play.Taiko
|
||||
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 TransformPositionX(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 1.1f, EndValue = 0.1f });
|
||||
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);
|
||||
|
@ -10,7 +10,7 @@ using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Taiko
|
||||
{
|
||||
public class TaikoPlayfield : Container
|
||||
public class TaikoPlayfield : Playfield
|
||||
{
|
||||
public TaikoPlayfield()
|
||||
{
|
||||
|
@ -73,10 +73,15 @@
|
||||
<Compile Include="GameModes\Menu\ButtonSystem.cs" />
|
||||
<Compile Include="GameModes\Menu\MainMenu.cs" />
|
||||
<Compile Include="GameModes\FieldTest.cs" />
|
||||
<Compile Include="GameModes\Play\Mania\ManiaHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Mania\ManiaPlayfield.cs" />
|
||||
<Compile Include="GameModes\Play\HitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Osu\OsuHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Osu\OsuPlayfield.cs" />
|
||||
<Compile Include="GameModes\Play\Playfield.cs" />
|
||||
<Compile Include="GameModes\Play\PlayTest.cs" />
|
||||
<Compile Include="GameModes\Play\Catch\CatchHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Catch\CatchPlayfield.cs" />
|
||||
<Compile Include="GameModes\Play\Taiko\TaikoHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Taiko\TaikoPlayfield.cs" />
|
||||
<Compile Include="Graphics\Containers\OsuComponent.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user