mirror of
https://github.com/ppy/osu.git
synced 2024-11-12 00:27:25 +08:00
Merge pull request #97 from peppy/hitcircles-and-more
Hitcircles and more
This commit is contained in:
commit
e26a9de5b5
@ -1 +1 @@
|
||||
Subproject commit 0505cf0d3b317667dbc95346f57b67fdbcdb4dee
|
||||
Subproject commit ca807cf81ae3706972937d4e1009376cfaa0b266
|
65
osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs
Normal file
65
osu.Desktop.VisualTests/Tests/TestCaseHitObjects.cs
Normal file
@ -0,0 +1,65 @@
|
||||
//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;
|
||||
using osu.Framework.GameModes.Testing;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.Beatmaps.Objects.Osu.Drawable;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
|
||||
namespace osu.Desktop.Tests
|
||||
{
|
||||
class TestCaseHitObjects : TestCase
|
||||
{
|
||||
public override string Name => @"Hit Objects";
|
||||
|
||||
IFrameBasedClock ourClock;
|
||||
|
||||
protected override IFrameBasedClock Clock => ourClock;
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
var swClock = new StopwatchClock(true) { Rate = 1 };
|
||||
ourClock = new FramedClock(swClock);
|
||||
}
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
ourClock.ProcessFrame();
|
||||
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
var h = new Circle
|
||||
{
|
||||
StartTime = ourClock.CurrentTime + 1000 + i * 80,
|
||||
Position = new OpenTK.Vector2(i * 14),
|
||||
};
|
||||
|
||||
Add(new DrawableCircle(h)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Depth = -i,
|
||||
State = ArmedState.Armed,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
ourClock.ProcessFrame();
|
||||
}
|
||||
}
|
||||
}
|
62
osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
Normal file
62
osu.Desktop.VisualTests/Tests/TestCasePlayer.cs
Normal file
@ -0,0 +1,62 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Framework.GameModes.Testing;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.GameModes.Play;
|
||||
|
||||
namespace osu.Desktop.Tests
|
||||
{
|
||||
class TestCasePlayer : TestCase
|
||||
{
|
||||
public override string Name => @"Player";
|
||||
|
||||
public override string Description => @"Showing everything to play the game.";
|
||||
|
||||
FramedClock localClock;
|
||||
|
||||
protected override IFrameBasedClock Clock => localClock;
|
||||
|
||||
public override void Reset()
|
||||
{
|
||||
base.Reset();
|
||||
|
||||
//ensure we are at offset 0
|
||||
localClock = new FramedClock();
|
||||
|
||||
var objects = new List<HitObject>();
|
||||
|
||||
int time = 1500;
|
||||
for (int i = 0; i < 50; i++)
|
||||
{
|
||||
objects.Add(new Circle()
|
||||
{
|
||||
StartTime = time,
|
||||
Position = new Vector2(RNG.Next(100, 400), RNG.Next(100, 200))
|
||||
});
|
||||
|
||||
time += 500;
|
||||
}
|
||||
|
||||
Add(new Player()
|
||||
{
|
||||
Beatmap = new Beatmap
|
||||
{
|
||||
HitObjects = objects
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
localClock.ProcessFrame();
|
||||
}
|
||||
}
|
||||
}
|
@ -14,8 +14,6 @@ namespace osu.Framework.VisualTests
|
||||
base.Load(game);
|
||||
|
||||
Add(new TestBrowser());
|
||||
|
||||
ShowPerformanceOverlay = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -139,7 +139,9 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Tests\TestCaseChatDisplay.cs" />
|
||||
<Compile Include="Tests\TestCasePlayer.cs" />
|
||||
<Compile Include="Tests\TestCaseGamefield.cs" />
|
||||
<Compile Include="Tests\TestCaseHitObjects.cs" />
|
||||
<Compile Include="Tests\TestCaseKeyCounter.cs" />
|
||||
<Compile Include="Tests\TestCaseMenuButtonSystem.cs" />
|
||||
<Compile Include="Tests\TestCaseScoreCounter.cs" />
|
||||
|
71
osu.Game/Beatmaps/Objects/DrawableHitObject.cs
Normal file
71
osu.Game/Beatmaps/Objects/DrawableHitObject.cs
Normal file
@ -0,0 +1,71 @@
|
||||
//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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.Objects.Osu.Drawable;
|
||||
|
||||
namespace osu.Game.Beatmaps.Objects
|
||||
{
|
||||
public abstract class DrawableHitObject : Container, IStateful<ArmedState>
|
||||
{
|
||||
public Action<DrawableHitObject> OnHit;
|
||||
public Action<DrawableHitObject> OnMiss;
|
||||
|
||||
public HitObject HitObject;
|
||||
|
||||
public DrawableHitObject(HitObject hitObject)
|
||||
{
|
||||
HitObject = hitObject;
|
||||
}
|
||||
|
||||
private ArmedState state;
|
||||
public ArmedState State
|
||||
{
|
||||
get { return state; }
|
||||
|
||||
set
|
||||
{
|
||||
state = value;
|
||||
|
||||
UpdateState(state);
|
||||
}
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
UpdateState(state);
|
||||
}
|
||||
|
||||
private bool counted;
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
if (Time >= HitObject.EndTime && !counted)
|
||||
{
|
||||
counted = true;
|
||||
if (state == ArmedState.Armed)
|
||||
OnHit?.Invoke(this);
|
||||
else
|
||||
OnMiss?.Invoke(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void UpdateState(ArmedState state);
|
||||
}
|
||||
|
||||
public enum ArmedState
|
||||
{
|
||||
Disarmed,
|
||||
Armed
|
||||
}
|
||||
}
|
@ -13,9 +13,9 @@ namespace osu.Game.Beatmaps.Objects
|
||||
public abstract class HitObject
|
||||
{
|
||||
public double StartTime;
|
||||
public double? EndTime;
|
||||
public virtual double EndTime => StartTime;
|
||||
|
||||
public double Duration => (EndTime ?? StartTime) - StartTime;
|
||||
public double Duration => EndTime - StartTime;
|
||||
|
||||
public HitSampleInfo Sample;
|
||||
|
||||
|
@ -1,9 +1,12 @@
|
||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.Beatmaps.Objects.Osu
|
||||
{
|
||||
public class Circle : OsuBaseHit
|
||||
{
|
||||
public Color4 Colour = new Color4(17, 136, 170, 255);
|
||||
}
|
||||
}
|
||||
|
@ -2,41 +2,349 @@
|
||||
//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;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.Textures;
|
||||
using osu.Framework.Graphics.Transformations;
|
||||
using OpenTK;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.MathUtils;
|
||||
|
||||
namespace osu.Game.Beatmaps.Objects.Osu.Drawable
|
||||
{
|
||||
class DrawableCircle : Sprite
|
||||
public class DrawableCircle : DrawableHitObject
|
||||
{
|
||||
private Sprite approachCircle;
|
||||
private CirclePart circle;
|
||||
private RingPart ring;
|
||||
private FlashPart flash;
|
||||
private ExplodePart explode;
|
||||
private NumberPart number;
|
||||
private GlowPart glow;
|
||||
private OsuBaseHit h;
|
||||
|
||||
public DrawableCircle(OsuBaseHit h)
|
||||
public DrawableCircle(Circle h) : base(h)
|
||||
{
|
||||
this.h = h;
|
||||
|
||||
Origin = Anchor.Centre;
|
||||
Scale = new Vector2(0.1f);
|
||||
Alpha = 0;
|
||||
Position = h.Position;
|
||||
Scale = new Vector2(0.4f);
|
||||
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
glow = new GlowPart()
|
||||
{
|
||||
Colour = h.Colour,
|
||||
},
|
||||
circle = new CirclePart()
|
||||
{
|
||||
Colour = h.Colour,
|
||||
Hit = delegate { State = ArmedState.Armed; }
|
||||
},
|
||||
number = new NumberPart(),
|
||||
ring = new RingPart(),
|
||||
flash = new FlashPart(),
|
||||
explode = new ExplodePart()
|
||||
{
|
||||
Colour = h.Colour
|
||||
},
|
||||
approachCircle = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Colour = h.Colour
|
||||
}
|
||||
};
|
||||
|
||||
Size = new Vector2(100);
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
Texture = game.Textures.Get(@"Menu/logo");
|
||||
approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x");
|
||||
}
|
||||
|
||||
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = 0, EndValue = 1 });
|
||||
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
||||
Expire(true);
|
||||
protected override void UpdateState(ArmedState state)
|
||||
{
|
||||
if (!IsLoaded) return;
|
||||
|
||||
Flush(); //move to DrawableHitObject
|
||||
|
||||
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime - 1000, EndTime = h.StartTime - 800, StartValue = 0, EndValue = 1 });
|
||||
|
||||
approachCircle.Transforms.Add(new TransformScale(Clock) { StartTime = h.StartTime - 1000, EndTime = h.StartTime, StartValue = new Vector2(2f), EndValue = new Vector2(0.6f) });
|
||||
approachCircle.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime, EndTime = h.StartTime, StartValue = 1, EndValue = 0 });
|
||||
|
||||
glow.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime, EndTime = h.StartTime + 400, StartValue = glow.Alpha, EndValue = 0 });
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case ArmedState.Disarmed:
|
||||
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + h.Duration + 200, EndTime = h.StartTime + h.Duration + 400, StartValue = 1, EndValue = 0 });
|
||||
break;
|
||||
case ArmedState.Armed:
|
||||
const float flashIn = 30;
|
||||
const float fadeOut = 800;
|
||||
|
||||
//Transforms.Add(new TransformScale(Clock) { StartTime = h.StartTime, EndTime = h.StartTime + 400, StartValue = Scale, EndValue = Scale * 1.1f });
|
||||
|
||||
ring.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + flashIn, EndTime = h.StartTime + flashIn, StartValue = 0, EndValue = 0 });
|
||||
circle.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + flashIn, EndTime = h.StartTime + flashIn, StartValue = 0, EndValue = 0 });
|
||||
number.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + flashIn, EndTime = h.StartTime + flashIn, StartValue = 0, EndValue = 0 });
|
||||
|
||||
flash.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime, EndTime = h.StartTime + flashIn, StartValue = 0, EndValue = 0.8f });
|
||||
flash.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + flashIn, EndTime = h.StartTime + flashIn + 100, StartValue = 0.8f, EndValue = 0 });
|
||||
|
||||
explode.Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime, EndTime = h.StartTime + flashIn, StartValue = 0, EndValue = 1 });
|
||||
|
||||
Transforms.Add(new TransformAlpha(Clock) { StartTime = h.StartTime + flashIn, EndTime = h.StartTime + flashIn + fadeOut, StartValue = 1, EndValue = 0 });
|
||||
|
||||
Transforms.Add(new TransformScale(Clock) { StartTime = h.StartTime + h.Duration, EndTime = h.StartTime + h.Duration + 400, StartValue = Scale, EndValue = Scale * 1.5f, Easing = EasingTypes.OutQuad });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
class NumberPart : Container
|
||||
{
|
||||
private Sprite number;
|
||||
|
||||
public NumberPart()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
number = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Alpha = 1,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
number.Texture = game.Textures.Get(@"Play/osu/number@2x");
|
||||
}
|
||||
}
|
||||
|
||||
class GlowPart : Container
|
||||
{
|
||||
private Sprite layer3;
|
||||
|
||||
public GlowPart()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new[]
|
||||
{
|
||||
layer3 = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Additive = true,
|
||||
Alpha = 0.5f,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
layer3.Texture = game.Textures.Get(@"Play/osu/ring-glow@2x");
|
||||
}
|
||||
}
|
||||
|
||||
class RingPart : Container
|
||||
{
|
||||
private Sprite ring;
|
||||
|
||||
public RingPart()
|
||||
{
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
ring = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
ring.Texture = game.Textures.Get(@"Play/osu/ring@2x");
|
||||
}
|
||||
}
|
||||
|
||||
class FlashPart : Container
|
||||
{
|
||||
public FlashPart()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
Masking = true;
|
||||
CornerRadius = Size.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Additive = true;
|
||||
Alpha = 0;
|
||||
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
class ExplodePart : Container
|
||||
{
|
||||
public ExplodePart()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Additive = true;
|
||||
Alpha = 0;
|
||||
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
new Triangles
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
class Triangles : Container
|
||||
{
|
||||
private Texture tex;
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
tex = game.Textures.Get(@"Play/osu/triangle@2x");
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Add(new Sprite
|
||||
{
|
||||
Texture = tex,
|
||||
Origin = Anchor.Centre,
|
||||
Position = new Vector2(RNG.NextSingle() * DrawSize.X, RNG.NextSingle() * DrawSize.Y),
|
||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
||||
Alpha = RNG.NextSingle() * 0.3f,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
foreach (Framework.Graphics.Drawable d in Children)
|
||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (Clock.ElapsedFrameTime / 20)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CirclePart : Container
|
||||
{
|
||||
|
||||
private Sprite disc;
|
||||
private Triangles triangles;
|
||||
|
||||
public Action Hit;
|
||||
|
||||
public CirclePart()
|
||||
{
|
||||
Size = new Vector2(144);
|
||||
Masking = true;
|
||||
CornerRadius = DrawSize.X / 2;
|
||||
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
|
||||
Children = new Framework.Graphics.Drawable[]
|
||||
{
|
||||
disc = new Sprite
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
},
|
||||
triangles = new Triangles
|
||||
{
|
||||
Additive = true,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
disc.Texture = game.Textures.Get(@"Play/osu/disc@2x");
|
||||
}
|
||||
|
||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||
{
|
||||
Hit?.Invoke();
|
||||
return true;
|
||||
}
|
||||
|
||||
class Triangles : Container
|
||||
{
|
||||
private Texture tex;
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
tex = game.Textures.Get(@"Play/osu/triangle@2x");
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
Add(new Sprite
|
||||
{
|
||||
Texture = tex,
|
||||
Origin = Anchor.Centre,
|
||||
Position = new Vector2(RNG.NextSingle() * DrawSize.X, RNG.NextSingle() * DrawSize.Y),
|
||||
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
||||
Alpha = RNG.NextSingle() * 0.3f,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
foreach (Framework.Graphics.Drawable d in Children)
|
||||
d.Position -= new Vector2(0, (float)(d.Scale.X * (Clock.ElapsedFrameTime / 20)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace osu.Game.GameModes.Play.Catch
|
||||
|
||||
protected override Playfield CreatePlayfield() => new CatchPlayfield();
|
||||
|
||||
protected override Drawable GetVisualRepresentation(CatchBaseHit h) => new DrawableFruit(h);
|
||||
protected override DrawableHitObject GetVisualRepresentation(CatchBaseHit h) => null;// new DrawableFruit(h);
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public abstract class ComboCounter : Container
|
||||
public abstract class ComboCounter : AutoSizeContainer
|
||||
{
|
||||
public bool IsRolling
|
||||
{
|
||||
@ -78,9 +78,14 @@ namespace osu.Game.GameModes.Play
|
||||
}
|
||||
}
|
||||
|
||||
public void Increment(ulong amount = 1)
|
||||
{
|
||||
Count = Count + amount;
|
||||
}
|
||||
|
||||
protected SpriteText DisplayedCountSpriteText;
|
||||
|
||||
private float textSize = 20.0f;
|
||||
private float textSize;
|
||||
public float TextSize
|
||||
{
|
||||
get { return textSize; }
|
||||
@ -108,6 +113,8 @@ namespace osu.Game.GameModes.Play
|
||||
Alpha = 0,
|
||||
}
|
||||
};
|
||||
|
||||
TextSize = 80;
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
|
@ -34,6 +34,11 @@ namespace osu.Game.GameModes.Play
|
||||
return $@"{count}x";
|
||||
}
|
||||
|
||||
public override void Increment(ulong amount)
|
||||
{
|
||||
Count = Count + amount;
|
||||
}
|
||||
|
||||
protected class TransformComboResult : Transform<ulong>
|
||||
{
|
||||
public override ulong CurrentValue
|
||||
|
@ -6,10 +6,17 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Framework;
|
||||
using System;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public abstract class HitRenderer<T> : Container
|
||||
public abstract class HitRenderer : Container
|
||||
{
|
||||
public Action<HitObject> OnHit;
|
||||
public Action<HitObject> OnMiss;
|
||||
}
|
||||
|
||||
public abstract class HitRenderer<T> : HitRenderer
|
||||
where T : HitObject
|
||||
{
|
||||
private List<T> objects;
|
||||
@ -50,9 +57,28 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
if (objects == null) return;
|
||||
foreach (T h in objects)
|
||||
playfield.Add(GetVisualRepresentation(h));
|
||||
{
|
||||
var drawableObject = GetVisualRepresentation(h);
|
||||
|
||||
if (drawableObject == null) continue;
|
||||
|
||||
drawableObject.OnHit = onHit;
|
||||
drawableObject.OnMiss = onMiss;
|
||||
|
||||
playfield.Add(drawableObject);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract Drawable GetVisualRepresentation(T h);
|
||||
private void onMiss(DrawableHitObject obj)
|
||||
{
|
||||
OnMiss?.Invoke(obj.HitObject);
|
||||
}
|
||||
|
||||
private void onHit(DrawableHitObject obj)
|
||||
{
|
||||
OnHit?.Invoke(obj.HitObject);
|
||||
}
|
||||
|
||||
protected abstract DrawableHitObject GetVisualRepresentation(T h);
|
||||
}
|
||||
}
|
||||
|
@ -22,13 +22,14 @@ namespace osu.Game.GameModes.Play.Mania
|
||||
|
||||
protected override Playfield CreatePlayfield() => new ManiaPlayfield(columns);
|
||||
|
||||
protected override Drawable GetVisualRepresentation(ManiaBaseHit h)
|
||||
protected override DrawableHitObject GetVisualRepresentation(ManiaBaseHit h)
|
||||
{
|
||||
return new DrawableNote(h)
|
||||
{
|
||||
Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f),
|
||||
RelativePositionAxes = Axes.Both
|
||||
};
|
||||
return null;
|
||||
//return new DrawableNote(h)
|
||||
//{
|
||||
// Position = new Vector2((float)(h.Column + 0.5) / columns, -0.1f),
|
||||
// RelativePositionAxes = Axes.Both
|
||||
//};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
|
||||
protected override Playfield CreatePlayfield() => new OsuPlayfield();
|
||||
|
||||
protected override Drawable GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h);
|
||||
protected override DrawableHitObject GetVisualRepresentation(OsuBaseHit h) => new DrawableCircle(h as Circle);
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using OpenTK;
|
||||
using osu.Framework;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using OpenTK.Graphics;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Osu
|
||||
{
|
||||
@ -13,8 +14,8 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
{
|
||||
public OsuPlayfield()
|
||||
{
|
||||
RelativeSizeAxes = Axes.None;
|
||||
Size = new Vector2(512, 384);
|
||||
Scale = new Vector2(1.6f);
|
||||
Anchor = Anchor.Centre;
|
||||
Origin = Anchor.Centre;
|
||||
}
|
||||
@ -28,6 +29,7 @@ namespace osu.Game.GameModes.Play.Osu
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.Black,
|
||||
Alpha = 0.5f
|
||||
});
|
||||
}
|
||||
|
55
osu.Game/GameModes/Play/Osu/ScoreOverlayOsu.cs
Normal file
55
osu.Game/GameModes/Play/Osu/ScoreOverlayOsu.cs
Normal file
@ -0,0 +1,55 @@
|
||||
//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;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
|
||||
namespace osu.Game.GameModes.Play.Osu
|
||||
{
|
||||
class ScoreOverlayOsu : ScoreOverlay
|
||||
{
|
||||
protected override PercentageCounter CreateAccuracyCounter() => new PercentageCounter()
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
Position = new Vector2(0, 45)
|
||||
};
|
||||
|
||||
protected override ScoreCounter CreateScoreCounter() => new ScoreCounter()
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
Origin = Anchor.TopRight,
|
||||
TextSize = 60
|
||||
};
|
||||
|
||||
protected override ComboCounter CreateComboCounter() => new OsuComboCounter()
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
};
|
||||
|
||||
protected override KeyCounterCollection CreateKeyCounter() => new KeyCounterCollection
|
||||
{
|
||||
IsCounting = true,
|
||||
FadeTime = 50,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Position = new Vector2(10),
|
||||
Counters = new KeyCounter[]
|
||||
{
|
||||
new KeyCounterKeyboard(@"Z", Key.Z),
|
||||
new KeyCounterKeyboard(@"X", Key.X),
|
||||
new KeyCounterMouse(@"M1", MouseButton.Left),
|
||||
new KeyCounterMouse(@"M2", MouseButton.Right),
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
@ -1,113 +1,91 @@
|
||||
//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;
|
||||
using osu.Framework.MathUtils;
|
||||
using osu.Framework.Timing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Beatmaps.Objects.Osu;
|
||||
using osu.Game.GameModes.Backgrounds;
|
||||
using osu.Game.GameModes.Play.Catch;
|
||||
using osu.Game.GameModes.Play.Mania;
|
||||
using osu.Game.GameModes.Play.Osu;
|
||||
using osu.Game.GameModes.Play.Taiko;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using OpenTK;
|
||||
using OpenTK.Input;
|
||||
using osu.Framework;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
class Player : GameModeWhiteBox
|
||||
public class Player : OsuGameMode
|
||||
{
|
||||
protected override BackgroundMode CreateBackground() => new BackgroundModeCustom(@"Backgrounds/bg4");
|
||||
|
||||
protected override IEnumerable<Type> PossibleChildren => new[] {
|
||||
typeof(Results)
|
||||
};
|
||||
public Beatmap Beatmap;
|
||||
|
||||
public PlayMode PlayMode;
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
List<HitObject> objects = new List<HitObject>();
|
||||
|
||||
double time = Time + 1000;
|
||||
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 = objects
|
||||
HitObjects = Beatmap?.HitObjects ?? new List<HitObject>()
|
||||
};
|
||||
|
||||
OsuGame osu = game as OsuGame;
|
||||
HitRenderer hitRenderer;
|
||||
ScoreOverlay scoreOverlay;
|
||||
|
||||
switch (osu.PlayMode.Value)
|
||||
switch (PlayMode)
|
||||
{
|
||||
case PlayMode.Osu:
|
||||
Add(new OsuHitRenderer
|
||||
default:
|
||||
scoreOverlay = new ScoreOverlayOsu();
|
||||
|
||||
hitRenderer = new OsuHitRenderer
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
});
|
||||
};
|
||||
break;
|
||||
case PlayMode.Taiko:
|
||||
Add(new TaikoHitRenderer
|
||||
scoreOverlay = null;
|
||||
|
||||
hitRenderer = new TaikoHitRenderer
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
});
|
||||
};
|
||||
break;
|
||||
case PlayMode.Catch:
|
||||
Add(new CatchHitRenderer
|
||||
scoreOverlay = null;
|
||||
|
||||
hitRenderer = new CatchHitRenderer
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
});
|
||||
};
|
||||
break;
|
||||
case PlayMode.Mania:
|
||||
Add(new ManiaHitRenderer
|
||||
scoreOverlay = null;
|
||||
|
||||
hitRenderer = new ManiaHitRenderer
|
||||
{
|
||||
Objects = beatmap.HitObjects,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre
|
||||
});
|
||||
};
|
||||
break;
|
||||
}
|
||||
|
||||
Add(new KeyCounterCollection
|
||||
hitRenderer.OnHit += delegate (HitObject h) { scoreOverlay.OnHit(h); };
|
||||
hitRenderer.OnMiss += delegate (HitObject h) { scoreOverlay.OnMiss(h); };
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
IsCounting = true,
|
||||
FadeTime = 50,
|
||||
Anchor = Anchor.BottomRight,
|
||||
Origin = Anchor.BottomRight,
|
||||
Position = new Vector2(10, 50),
|
||||
Counters = new KeyCounter[]
|
||||
{
|
||||
new KeyCounterKeyboard(@"Z", Key.Z),
|
||||
new KeyCounterKeyboard(@"X", Key.X),
|
||||
new KeyCounterMouse(@"M1", MouseButton.Left),
|
||||
new KeyCounterMouse(@"M2", MouseButton.Right),
|
||||
}
|
||||
});
|
||||
hitRenderer,
|
||||
scoreOverlay,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -8,11 +8,5 @@ namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public class Playfield : Container
|
||||
{
|
||||
public override void Load(BaseGame game)
|
||||
{
|
||||
base.Load(game);
|
||||
|
||||
Masking = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
53
osu.Game/GameModes/Play/ScoreOverlay.cs
Normal file
53
osu.Game/GameModes/Play/ScoreOverlay.cs
Normal file
@ -0,0 +1,53 @@
|
||||
//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;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps.Objects;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
||||
namespace osu.Game.GameModes.Play
|
||||
{
|
||||
public abstract class ScoreOverlay : Container
|
||||
{
|
||||
public KeyCounterCollection KeyCounter;
|
||||
public ComboCounter ComboCounter;
|
||||
public ScoreCounter ScoreCounter;
|
||||
public PercentageCounter AccuracyCounter;
|
||||
|
||||
protected abstract KeyCounterCollection CreateKeyCounter();
|
||||
protected abstract ComboCounter CreateComboCounter();
|
||||
protected abstract PercentageCounter CreateAccuracyCounter();
|
||||
protected abstract ScoreCounter CreateScoreCounter();
|
||||
|
||||
public virtual void OnHit(HitObject h)
|
||||
{
|
||||
ComboCounter?.Increment();
|
||||
ScoreCounter?.Increment(300);
|
||||
AccuracyCounter?.Set(Math.Min(1, AccuracyCounter.Count + 0.01f));
|
||||
}
|
||||
|
||||
public virtual void OnMiss(HitObject h)
|
||||
{
|
||||
ComboCounter?.Roll();
|
||||
AccuracyCounter?.Set(AccuracyCounter.Count - 0.01f);
|
||||
}
|
||||
|
||||
public ScoreOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
Children = new Drawable[] {
|
||||
KeyCounter = CreateKeyCounter(),
|
||||
ComboCounter = CreateComboCounter(),
|
||||
ScoreCounter = CreateScoreCounter(),
|
||||
AccuracyCounter = CreateAccuracyCounter(),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,6 @@ namespace osu.Game.GameModes.Play.Taiko
|
||||
|
||||
protected override Playfield CreatePlayfield() => new TaikoPlayfield();
|
||||
|
||||
protected override Drawable GetVisualRepresentation(TaikoBaseHit h) => new DrawableTaikoHit(h);
|
||||
protected override DrawableHitObject GetVisualRepresentation(TaikoBaseHit h) => null;// new DrawableTaikoHit(h);
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return Math.Abs(currentValue - newValue) * RollingDuration * 100.0f;
|
||||
}
|
||||
|
||||
public override void Increment(float amount)
|
||||
{
|
||||
Count = Count + amount;
|
||||
}
|
||||
|
||||
protected class TransformAccuracy : TransformFloat
|
||||
{
|
||||
public override void Apply(Drawable d)
|
||||
|
@ -86,7 +86,14 @@ namespace osu.Game.Graphics.UserInterface
|
||||
}
|
||||
}
|
||||
|
||||
protected float textSize = 20.0f;
|
||||
public void Set(T value)
|
||||
{
|
||||
Count = value;
|
||||
}
|
||||
|
||||
public abstract void Increment(T amount);
|
||||
|
||||
protected float textSize;
|
||||
|
||||
public float TextSize
|
||||
{
|
||||
@ -107,6 +114,8 @@ namespace osu.Game.Graphics.UserInterface
|
||||
{
|
||||
DisplayedCountSpriteText = new SpriteText(),
|
||||
};
|
||||
|
||||
TextSize = 40;
|
||||
}
|
||||
|
||||
public override void Load(BaseGame game)
|
||||
|
@ -49,6 +49,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
return count.ToString("D" + LeadingZeroes);
|
||||
}
|
||||
|
||||
public override void Increment(ulong amount)
|
||||
{
|
||||
Count = Count + amount;
|
||||
}
|
||||
|
||||
protected class TransformScore : Transform<ulong>
|
||||
{
|
||||
public override ulong CurrentValue
|
||||
|
@ -63,6 +63,7 @@
|
||||
<Compile Include="Beatmaps\Beatmap.cs" />
|
||||
<Compile Include="Beatmaps\Objects\Catch\CatchConverter.cs" />
|
||||
<Compile Include="Beatmaps\Objects\Catch\Drawable\DrawableFruit.cs" />
|
||||
<Compile Include="Beatmaps\Objects\DrawableHitObject.cs" />
|
||||
<Compile Include="Beatmaps\Objects\HitObject.cs" />
|
||||
<Compile Include="Beatmaps\Objects\Catch\CatchBaseHit.cs" />
|
||||
<Compile Include="Beatmaps\Objects\Catch\Droplet.cs" />
|
||||
@ -111,6 +112,7 @@
|
||||
<Compile Include="GameModes\Multiplayer\MatchSongSelect.cs" />
|
||||
<Compile Include="GameModes\OsuGameMode.cs" />
|
||||
<Compile Include="GameModes\Play\ModSelect.cs" />
|
||||
<Compile Include="GameModes\Play\Osu\ScoreOverlayOsu.cs" />
|
||||
<Compile Include="GameModes\Play\Player.cs" />
|
||||
<Compile Include="GameModes\Charts\ChartListing.cs" />
|
||||
<Compile Include="GameModes\Play\PlayMode.cs" />
|
||||
@ -125,6 +127,7 @@
|
||||
<Compile Include="GameModes\Play\Osu\OsuHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Osu\OsuPlayfield.cs" />
|
||||
<Compile Include="GameModes\Play\Playfield.cs" />
|
||||
<Compile Include="GameModes\Play\ScoreOverlay.cs" />
|
||||
<Compile Include="GameModes\Play\Taiko\TaikoHitRenderer.cs" />
|
||||
<Compile Include="GameModes\Play\Taiko\TaikoPlayfield.cs" />
|
||||
<Compile Include="GameModes\Edit\EditSongSelect.cs" />
|
||||
@ -209,4 +212,4 @@
|
||||
<Target Name="AfterBuild">
|
||||
</Target>
|
||||
-->
|
||||
</Project>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user