2018-01-05 20:21:19 +09:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 13:59:30 +09:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-13 10:10:15 +09:00
|
|
|
|
|
2016-11-19 19:07:57 +09:00
|
|
|
|
using System;
|
2016-10-13 10:10:15 +09:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-04-18 16:05:58 +09:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
2016-11-02 12:22:29 +09:00
|
|
|
|
using OpenTK;
|
2017-09-06 17:02:13 +09:00
|
|
|
|
using osu.Game.Rulesets.Osu.Judgements;
|
2017-12-30 21:23:18 +01:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2016-10-13 10:10:15 +09:00
|
|
|
|
|
2017-04-18 16:05:58 +09:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2016-10-13 10:10:15 +09:00
|
|
|
|
{
|
2017-02-14 10:22:28 +09:00
|
|
|
|
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
|
2016-10-19 16:13:53 +09:00
|
|
|
|
{
|
2016-11-19 19:07:57 +09:00
|
|
|
|
public ApproachCircle ApproachCircle;
|
2017-03-23 13:41:50 +09:00
|
|
|
|
private readonly CirclePiece circle;
|
|
|
|
|
private readonly RingPiece ring;
|
|
|
|
|
private readonly FlashPiece flash;
|
|
|
|
|
private readonly ExplodePiece explode;
|
|
|
|
|
private readonly NumberPiece number;
|
|
|
|
|
private readonly GlowPiece glow;
|
2016-10-13 10:10:15 +09:00
|
|
|
|
|
2017-12-30 14:15:42 +09:00
|
|
|
|
public DrawableHitCircle(HitCircle h) : base(h)
|
2016-10-13 10:10:15 +09:00
|
|
|
|
{
|
2017-02-14 18:55:54 +09:00
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2017-03-23 15:37:16 +09:00
|
|
|
|
Position = HitObject.StackedPosition;
|
2018-01-01 11:55:24 +01:00
|
|
|
|
Scale = new Vector2(h.Scale);
|
2016-10-19 16:13:53 +09:00
|
|
|
|
|
2016-11-14 18:54:24 +09:00
|
|
|
|
Children = new Drawable[]
|
2016-10-19 16:13:53 +09:00
|
|
|
|
{
|
2016-11-17 17:20:51 +09:00
|
|
|
|
glow = new GlowPiece
|
2016-10-19 16:13:53 +09:00
|
|
|
|
{
|
2017-03-23 15:37:16 +09:00
|
|
|
|
Colour = AccentColour
|
2016-10-19 16:13:53 +09:00
|
|
|
|
},
|
2016-11-17 17:20:51 +09:00
|
|
|
|
circle = new CirclePiece
|
2016-10-19 16:13:53 +09:00
|
|
|
|
{
|
2017-03-23 15:37:16 +09:00
|
|
|
|
Colour = AccentColour,
|
2016-11-26 16:51:51 +09:00
|
|
|
|
Hit = () =>
|
|
|
|
|
{
|
2017-09-06 17:02:13 +09:00
|
|
|
|
if (AllJudged)
|
|
|
|
|
return false;
|
2017-01-08 20:52:19 +08:00
|
|
|
|
|
2016-11-26 16:51:51 +09:00
|
|
|
|
UpdateJudgement(true);
|
|
|
|
|
return true;
|
|
|
|
|
},
|
2016-10-19 16:13:53 +09:00
|
|
|
|
},
|
2017-03-07 10:59:19 +09:00
|
|
|
|
number = new NumberPiece
|
2017-02-15 23:23:55 +09:00
|
|
|
|
{
|
2018-01-03 15:12:27 +09:00
|
|
|
|
Text = (HitObject.IndexInCurrentCombo + 1).ToString(),
|
2017-02-15 23:23:55 +09:00
|
|
|
|
},
|
2016-11-17 17:20:51 +09:00
|
|
|
|
ring = new RingPiece(),
|
|
|
|
|
flash = new FlashPiece(),
|
|
|
|
|
explode = new ExplodePiece
|
2016-10-19 16:13:53 +09:00
|
|
|
|
{
|
2017-03-23 15:37:16 +09:00
|
|
|
|
Colour = AccentColour,
|
2016-10-19 16:13:53 +09:00
|
|
|
|
},
|
2017-03-07 10:59:19 +09:00
|
|
|
|
ApproachCircle = new ApproachCircle
|
2016-10-19 16:13:53 +09:00
|
|
|
|
{
|
2017-11-09 14:04:59 +09:00
|
|
|
|
Alpha = 0,
|
|
|
|
|
Scale = new Vector2(4),
|
2017-03-23 15:37:16 +09:00
|
|
|
|
Colour = AccentColour,
|
2016-10-19 16:13:53 +09:00
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-28 12:40:24 +09:00
|
|
|
|
|
|
|
|
|
//may not be so correct
|
|
|
|
|
Size = circle.DrawSize;
|
2016-11-19 19:07:57 +09:00
|
|
|
|
}
|
|
|
|
|
|
2017-09-06 17:02:13 +09:00
|
|
|
|
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
|
2016-11-26 16:51:51 +09:00
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
2018-02-02 20:31:39 +09:00
|
|
|
|
if (!HitObject.HitWindows.CanBeHit(timeOffset))
|
2017-09-06 17:02:13 +09:00
|
|
|
|
AddJudgement(new OsuJudgement { Result = HitResult.Miss });
|
2016-11-26 16:51:51 +09:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2018-02-02 20:31:39 +09:00
|
|
|
|
var result = HitObject.HitWindows.ResultFor(timeOffset);
|
2018-02-08 14:25:59 +09:00
|
|
|
|
if (result == HitResult.None)
|
2018-02-02 20:31:39 +09:00
|
|
|
|
return;
|
|
|
|
|
|
2017-09-06 17:02:13 +09:00
|
|
|
|
AddJudgement(new OsuJudgement
|
|
|
|
|
{
|
2018-02-08 14:25:59 +09:00
|
|
|
|
Result = result,
|
2017-09-06 17:02:13 +09:00
|
|
|
|
PositionOffset = Vector2.Zero //todo: set to correct value
|
|
|
|
|
});
|
2016-11-26 16:51:51 +09:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 18:40:54 +09:00
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
base.UpdatePreemptState();
|
2016-11-19 19:07:57 +09:00
|
|
|
|
|
2017-12-31 11:30:58 -05:00
|
|
|
|
ApproachCircle.FadeIn(Math.Min(HitObject.TimeFadein * 2, HitObject.TimePreempt));
|
2017-12-31 11:15:14 -05:00
|
|
|
|
ApproachCircle.ScaleTo(1.1f, HitObject.TimePreempt);
|
2016-11-28 18:40:54 +09:00
|
|
|
|
}
|
2016-11-18 17:36:53 +09:00
|
|
|
|
|
2017-04-27 17:37:38 +09:00
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
2016-11-28 18:40:54 +09:00
|
|
|
|
{
|
2017-12-26 17:25:18 +01:00
|
|
|
|
glow.FadeOut(400);
|
2016-10-19 16:13:53 +09:00
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2016-11-25 16:26:50 +09:00
|
|
|
|
case ArmedState.Idle:
|
2017-12-31 11:15:14 -05:00
|
|
|
|
this.Delay(HitObject.TimePreempt).FadeOut(500);
|
2017-12-29 18:51:14 +09:00
|
|
|
|
|
2017-03-17 15:30:19 +09:00
|
|
|
|
Expire(true);
|
2017-12-29 18:51:14 +09:00
|
|
|
|
|
|
|
|
|
// override lifetime end as FadeIn may have been changed externally, causing out expiration to be too early.
|
2018-02-02 20:31:39 +09:00
|
|
|
|
LifetimeEnd = HitObject.StartTime + HitObject.HitWindows.HalfWindowFor(HitResult.Miss);
|
2016-10-19 16:13:53 +09:00
|
|
|
|
break;
|
2016-11-25 16:26:50 +09:00
|
|
|
|
case ArmedState.Miss:
|
2017-07-10 07:01:25 +09:00
|
|
|
|
ApproachCircle.FadeOut(50);
|
2017-12-26 17:25:18 +01:00
|
|
|
|
this.FadeOut(100);
|
2017-03-17 15:30:19 +09:00
|
|
|
|
Expire();
|
2016-11-25 16:26:50 +09:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2017-07-10 07:01:25 +09:00
|
|
|
|
ApproachCircle.FadeOut(50);
|
|
|
|
|
|
2016-12-15 22:35:12 +09:00
|
|
|
|
const double flash_in = 40;
|
2017-07-16 18:28:20 +03:00
|
|
|
|
flash.FadeTo(0.8f, flash_in)
|
|
|
|
|
.Then()
|
|
|
|
|
.FadeOut(100);
|
|
|
|
|
|
2016-11-02 13:22:23 +09:00
|
|
|
|
explode.FadeIn(flash_in);
|
2016-10-19 16:13:53 +09:00
|
|
|
|
|
2017-07-16 18:28:20 +03:00
|
|
|
|
using (BeginDelayedSequence(flash_in, true))
|
|
|
|
|
{
|
|
|
|
|
//after the flash, we can hide some elements that were behind it
|
|
|
|
|
ring.FadeOut();
|
|
|
|
|
circle.FadeOut();
|
|
|
|
|
number.FadeOut();
|
|
|
|
|
|
|
|
|
|
this.FadeOut(800)
|
2017-07-22 20:50:25 +02:00
|
|
|
|
.ScaleTo(Scale * 1.5f, 400, Easing.OutQuad);
|
2017-07-16 18:28:20 +03:00
|
|
|
|
}
|
2016-10-19 16:13:53 +09:00
|
|
|
|
|
2017-03-17 15:30:19 +09:00
|
|
|
|
Expire();
|
2016-10-19 16:13:53 +09:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-14 10:22:28 +09:00
|
|
|
|
|
|
|
|
|
public Drawable ProxiedLayer => ApproachCircle;
|
2016-10-13 10:10:15 +09:00
|
|
|
|
}
|
|
|
|
|
}
|