1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 20:47:25 +08:00
osu-lazer/osu.Game.Mode.Osu/Objects/Drawables/DrawableHitCircle.cs

136 lines
4.3 KiB
C#
Raw Normal View History

//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;
2016-11-14 17:03:20 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Transformations;
using osu.Framework.IO.Stores;
2016-11-14 18:49:29 +08:00
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
2016-11-02 11:22:29 +08:00
using OpenTK;
2016-11-14 17:54:24 +08:00
namespace osu.Game.Modes.Osu.Objects.Drawables
{
2016-11-16 15:20:58 +08:00
public class DrawableHitCircle : DrawableHitObject
{
private Sprite approachCircle;
private CirclePiece circle;
private RingPiece ring;
private FlashPiece flash;
private ExplodePiece explode;
private NumberPiece number;
private GlowPiece glow;
private OsuBaseHit h;
private HitExplosion explosion;
2016-11-16 15:20:58 +08:00
public DrawableHitCircle(HitCircle h) : base(h)
{
this.h = h;
Origin = Anchor.Centre;
2016-11-17 20:29:35 +08:00
Position = h.Position;
2016-11-14 17:54:24 +08:00
Children = new Drawable[]
{
glow = new GlowPiece
{
2016-11-02 11:22:29 +08:00
Colour = h.Colour
},
circle = new CirclePiece
{
Colour = h.Colour,
Hit = Hit,
},
number = new NumberPiece(),
ring = new RingPiece(),
flash = new FlashPiece(),
explode = new ExplodePiece
{
2016-11-02 13:03:03 +08:00
Colour = h.Colour,
},
approachCircle = new Sprite
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = h.Colour
}
};
2016-11-02 17:12:12 +08:00
//may not be so correct
Size = circle.DrawSize;
}
[BackgroundDependencyLoader]
private void load(BaseGame game)
{
approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x");
}
protected override void LoadComplete()
{
base.LoadComplete();
//force application of the state that was set before we loaded.
UpdateState(State);
}
protected override void UpdateState(ArmedState state)
{
if (!IsLoaded) return;
Flush(true); //move to DrawableHitObject
double t = HitTime ?? h.StartTime;
//sane defaults
ring.Alpha = circle.Alpha = number.Alpha = approachCircle.Alpha = glow.Alpha = 1;
2016-11-02 13:03:03 +08:00
explode.Alpha = 0;
2016-11-02 16:08:34 +08:00
Scale = Vector2.One;
//always-present transforms
Transforms.Add(new TransformAlpha { StartTime = t - 1000, EndTime = t - 800, StartValue = 0, EndValue = 1 });
approachCircle.Transforms.Add(new TransformScale { StartTime = t - 1000, EndTime = t, StartValue = new Vector2(2f), EndValue = new Vector2(0.6f) });
//set transform delay to t==hitTime
Delay(t - Time.Current, true);
approachCircle.FadeOut();
glow.FadeOut(400);
switch (state)
{
case ArmedState.Disarmed:
Delay(h.Duration + 200);
FadeOut(200);
explosion?.Expire();
explosion = null;
break;
case ArmedState.Armed:
const double flash_in = 30;
flash.FadeTo(0.8f, flash_in);
flash.Delay(flash_in);
flash.FadeOut(100);
explode.FadeIn(flash_in);
Delay(flash_in, true);
//after the flash, we can hide some elements that were behind it
ring.FadeOut();
circle.FadeOut();
number.FadeOut();
FadeOut(800);
ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad);
Schedule(() => Add(explosion = new HitExplosion(Judgement.Hit300)));
break;
}
}
}
}