2016-10-13 09:10:15 +08:00
|
|
|
|
//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 osu.Framework;
|
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
using osu.Framework.Graphics.Textures;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
using osu.Framework.Input;
|
|
|
|
|
using osu.Framework.MathUtils;
|
2016-11-02 11:22:29 +08:00
|
|
|
|
using OpenTK;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Beatmaps.Objects.Osu.Drawable
|
|
|
|
|
{
|
2016-10-19 18:44:03 +08:00
|
|
|
|
public class DrawableCircle : DrawableHitObject
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
private Sprite approachCircle;
|
2016-11-02 11:22:29 +08:00
|
|
|
|
private CircleLayer circle;
|
|
|
|
|
private RingLayer ring;
|
|
|
|
|
private FlashLayer flash;
|
|
|
|
|
private ExplodeLayer explode;
|
|
|
|
|
private NumberLayer number;
|
|
|
|
|
private GlowLayer glow;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
private OsuBaseHit h;
|
|
|
|
|
|
2016-10-19 18:44:03 +08:00
|
|
|
|
public DrawableCircle(Circle h) : base(h)
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
|
|
|
|
this.h = h;
|
|
|
|
|
|
|
|
|
|
Origin = Anchor.Centre;
|
2016-11-02 14:37:45 +08:00
|
|
|
|
RelativePositionAxes = Axes.Both;
|
|
|
|
|
Position = new Vector2(h.Position.X / 512, h.Position.Y / 384);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
2016-11-02 11:22:29 +08:00
|
|
|
|
glow = new GlowLayer
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-02 11:22:29 +08:00
|
|
|
|
Colour = h.Colour
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
2016-11-02 11:22:29 +08:00
|
|
|
|
circle = new CircleLayer
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
Colour = h.Colour,
|
2016-11-02 11:57:43 +08:00
|
|
|
|
Hit = Hit,
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
2016-11-02 11:22:29 +08:00
|
|
|
|
number = new NumberLayer(),
|
|
|
|
|
ring = new RingLayer(),
|
|
|
|
|
flash = new FlashLayer(),
|
|
|
|
|
explode = new ExplodeLayer
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-02 13:03:03 +08:00
|
|
|
|
Colour = h.Colour,
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
|
|
|
|
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;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
protected override void Load(BaseGame game)
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
|
|
|
|
|
2016-10-19 15:13:53 +08:00
|
|
|
|
approachCircle.Texture = game.Textures.Get(@"Play/osu/approachcircle@2x");
|
2016-10-19 18:44:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-02 11:31:51 +08:00
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
|
|
//force application of the state that was set before we loaded.
|
|
|
|
|
UpdateState(State);
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-19 18:44:03 +08:00
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
if (!IsLoaded) return;
|
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
Flush(true); //move to DrawableHitObject
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
double t = HitTime ?? h.StartTime;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
//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;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
//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) });
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
//set transform delay to t==hitTime
|
2016-11-06 18:13:52 +08:00
|
|
|
|
Delay(t - Time.Current, true);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
approachCircle.FadeOut();
|
|
|
|
|
glow.FadeOut(400);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2016-10-19 18:44:03 +08:00
|
|
|
|
case ArmedState.Disarmed:
|
2016-11-02 12:22:23 +08:00
|
|
|
|
Delay(h.Duration + 200);
|
|
|
|
|
FadeOut(200);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
break;
|
2016-10-19 18:44:03 +08:00
|
|
|
|
case ArmedState.Armed:
|
2016-11-02 12:22:23 +08:00
|
|
|
|
const double flash_in = 30;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
flash.FadeTo(0.8f, flash_in);
|
|
|
|
|
flash.Delay(flash_in);
|
|
|
|
|
flash.FadeOut(100);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
explode.FadeIn(flash_in);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
Delay(flash_in, true);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
//after the flash, we can hide some elements that were behind it
|
|
|
|
|
ring.FadeOut();
|
|
|
|
|
circle.FadeOut();
|
|
|
|
|
number.FadeOut();
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
FadeOut(800);
|
|
|
|
|
ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class NumberLayer : Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
private Sprite number;
|
|
|
|
|
|
2016-11-02 11:22:29 +08:00
|
|
|
|
public NumberLayer()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2016-11-05 20:51:52 +08:00
|
|
|
|
number = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Alpha = 1
|
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
protected override void Load(BaseGame game)
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
|
|
|
|
number.Texture = game.Textures.Get(@"Play/osu/number@2x");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class GlowLayer : Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-05 20:51:52 +08:00
|
|
|
|
private Sprite layer;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 11:22:29 +08:00
|
|
|
|
public GlowLayer()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2016-11-05 20:51:52 +08:00
|
|
|
|
layer = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
|
|
|
|
Alpha = 0.5f
|
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
protected override void Load(BaseGame game)
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
2016-11-05 20:51:52 +08:00
|
|
|
|
layer.Texture = game.Textures.Get(@"Play/osu/ring-glow@2x");
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class RingLayer : Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
private Sprite ring;
|
|
|
|
|
|
2016-11-02 11:22:29 +08:00
|
|
|
|
public RingLayer()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
ring = new Sprite
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.Centre,
|
2016-11-02 11:22:29 +08:00
|
|
|
|
Origin = Anchor.Centre
|
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
protected override void Load(BaseGame game)
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
|
|
|
|
ring.Texture = game.Textures.Get(@"Play/osu/ring@2x");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class FlashLayer : Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-02 11:22:29 +08:00
|
|
|
|
public FlashLayer()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(144);
|
2016-11-04 15:08:04 +08:00
|
|
|
|
|
2016-10-19 15:13:53 +08:00
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = Size.X / 2;
|
|
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2016-11-05 17:15:37 +08:00
|
|
|
|
BlendingMode = BlendingMode.Additive;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
Alpha = 0;
|
|
|
|
|
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
2016-11-02 11:22:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class ExplodeLayer : Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-02 11:22:29 +08:00
|
|
|
|
public ExplodeLayer()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
Size = new Vector2(144);
|
|
|
|
|
|
|
|
|
|
Anchor = Anchor.Centre;
|
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2016-11-05 17:15:37 +08:00
|
|
|
|
BlendingMode = BlendingMode.Additive;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
Alpha = 0;
|
|
|
|
|
|
|
|
|
|
Children = new Framework.Graphics.Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Triangles
|
|
|
|
|
{
|
2016-11-02 11:22:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class CircleLayer : Container
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
private Sprite disc;
|
|
|
|
|
private Triangles triangles;
|
|
|
|
|
|
2016-11-02 11:57:43 +08:00
|
|
|
|
public Func<bool> Hit;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 11:22:29 +08:00
|
|
|
|
public CircleLayer()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
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,
|
2016-11-02 11:22:29 +08:00
|
|
|
|
Origin = Anchor.Centre
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
|
|
|
|
triangles = new Triangles
|
|
|
|
|
{
|
2016-11-05 17:15:37 +08:00
|
|
|
|
BlendingMode = BlendingMode.Additive,
|
2016-11-02 11:22:29 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both
|
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-01 22:24:14 +08:00
|
|
|
|
protected override void Load(BaseGame game)
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
|
|
|
|
disc.Texture = game.Textures.Get(@"Play/osu/disc@2x");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
|
|
|
|
{
|
|
|
|
|
Hit?.Invoke();
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2016-11-04 15:11:22 +08:00
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-04 15:12:35 +08:00
|
|
|
|
private class Triangles : Container
|
2016-11-04 15:11:22 +08:00
|
|
|
|
{
|
|
|
|
|
private Texture tex;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-04 15:11:22 +08:00
|
|
|
|
protected override void Load(BaseGame game)
|
|
|
|
|
{
|
|
|
|
|
base.Load(game);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-04 15:11:22 +08:00
|
|
|
|
tex = game.Textures.Get(@"Play/osu/triangle@2x");
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-04 15:11:22 +08:00
|
|
|
|
for (int i = 0; i < 10; i++)
|
|
|
|
|
{
|
|
|
|
|
Add(new Sprite
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-04 15:11:22 +08:00
|
|
|
|
Texture = tex,
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
RelativePositionAxes = Axes.Both,
|
|
|
|
|
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
|
|
|
|
|
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
|
|
|
|
|
Alpha = RNG.NextSingle() * 0.3f
|
|
|
|
|
});
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
2016-11-04 15:11:22 +08:00
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-04 15:11:22 +08:00
|
|
|
|
protected override void Update()
|
|
|
|
|
{
|
|
|
|
|
base.Update();
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-04 15:11:22 +08:00
|
|
|
|
foreach (Framework.Graphics.Drawable d in Children)
|
2016-11-06 17:08:24 +08:00
|
|
|
|
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 2880)));
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|