2017-02-07 04:59:30 +00:00
|
|
|
|
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-10-13 01:10:15 +00:00
|
|
|
|
|
2016-11-19 10:07:57 +00:00
|
|
|
|
using System;
|
2016-10-13 01:10:15 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
|
2016-11-02 03:22:29 +00:00
|
|
|
|
using OpenTK;
|
2017-04-18 07:05:58 +00:00
|
|
|
|
using osu.Game.Rulesets.Objects.Types;
|
2016-10-13 01:10:15 +00:00
|
|
|
|
|
2017-04-18 07:05:58 +00:00
|
|
|
|
namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
2016-10-13 01:10:15 +00:00
|
|
|
|
{
|
2017-02-14 01:22:28 +00:00
|
|
|
|
public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithProxiedApproach
|
2016-10-19 07:13:53 +00:00
|
|
|
|
{
|
2016-11-19 10:07:57 +00:00
|
|
|
|
public ApproachCircle ApproachCircle;
|
2017-03-23 04:41:50 +00: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 01:10:15 +00:00
|
|
|
|
|
2017-02-14 09:55:54 +00:00
|
|
|
|
public DrawableHitCircle(OsuHitObject h) : base(h)
|
2016-10-13 01:10:15 +00:00
|
|
|
|
{
|
2017-02-14 09:55:54 +00:00
|
|
|
|
Origin = Anchor.Centre;
|
|
|
|
|
|
2017-03-23 06:37:16 +00:00
|
|
|
|
Position = HitObject.StackedPosition;
|
|
|
|
|
Scale = new Vector2(HitObject.Scale);
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-14 09:54:24 +00:00
|
|
|
|
Children = new Drawable[]
|
2016-10-19 07:13:53 +00:00
|
|
|
|
{
|
2016-11-17 08:20:51 +00:00
|
|
|
|
glow = new GlowPiece
|
2016-10-19 07:13:53 +00:00
|
|
|
|
{
|
2017-03-23 06:37:16 +00:00
|
|
|
|
Colour = AccentColour
|
2016-10-19 07:13:53 +00:00
|
|
|
|
},
|
2016-11-17 08:20:51 +00:00
|
|
|
|
circle = new CirclePiece
|
2016-10-19 07:13:53 +00:00
|
|
|
|
{
|
2017-03-23 06:37:16 +00:00
|
|
|
|
Colour = AccentColour,
|
2016-11-26 07:51:51 +00:00
|
|
|
|
Hit = () =>
|
|
|
|
|
{
|
2017-03-29 08:57:36 +00:00
|
|
|
|
if (Judgement.Result != HitResult.None) return false;
|
2017-01-08 12:52:19 +00:00
|
|
|
|
|
2017-03-15 09:58:41 +00:00
|
|
|
|
Judgement.PositionOffset = Vector2.Zero; //todo: set to correct value
|
2016-11-26 07:51:51 +00:00
|
|
|
|
UpdateJudgement(true);
|
|
|
|
|
return true;
|
|
|
|
|
},
|
2016-10-19 07:13:53 +00:00
|
|
|
|
},
|
2017-03-07 01:59:19 +00:00
|
|
|
|
number = new NumberPiece
|
2017-02-15 14:23:55 +00:00
|
|
|
|
{
|
|
|
|
|
Text = h is Spinner ? "S" : (HitObject.ComboIndex + 1).ToString(),
|
|
|
|
|
},
|
2016-11-17 08:20:51 +00:00
|
|
|
|
ring = new RingPiece(),
|
|
|
|
|
flash = new FlashPiece(),
|
|
|
|
|
explode = new ExplodePiece
|
2016-10-19 07:13:53 +00:00
|
|
|
|
{
|
2017-03-23 06:37:16 +00:00
|
|
|
|
Colour = AccentColour,
|
2016-10-19 07:13:53 +00:00
|
|
|
|
},
|
2017-03-07 01:59:19 +00:00
|
|
|
|
ApproachCircle = new ApproachCircle
|
2016-10-19 07:13:53 +00:00
|
|
|
|
{
|
2017-03-23 06:37:16 +00:00
|
|
|
|
Colour = AccentColour,
|
2016-10-19 07:13:53 +00:00
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-28 03:40:24 +00:00
|
|
|
|
|
|
|
|
|
//may not be so correct
|
|
|
|
|
Size = circle.DrawSize;
|
2016-11-19 10:07:57 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-26 07:51:51 +00:00
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
2017-03-06 14:26:57 +00:00
|
|
|
|
if (Judgement.TimeOffset > HitObject.HitWindowFor(OsuScoreResult.Hit50))
|
2016-11-26 07:51:51 +00:00
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double hitOffset = Math.Abs(Judgement.TimeOffset);
|
|
|
|
|
|
2017-03-06 14:26:57 +00:00
|
|
|
|
if (hitOffset < HitObject.HitWindowFor(OsuScoreResult.Hit50))
|
2016-11-26 07:51:51 +00:00
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
2017-03-15 09:58:41 +00:00
|
|
|
|
Judgement.Score = HitObject.ScoreResultForOffset(hitOffset);
|
2016-11-26 07:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 09:40:54 +00:00
|
|
|
|
protected override void UpdateInitialState()
|
2016-10-19 10:44:03 +00:00
|
|
|
|
{
|
2016-11-28 09:40:54 +00:00
|
|
|
|
base.UpdateInitialState();
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-02 04:22:23 +00:00
|
|
|
|
//sane defaults
|
2016-11-19 10:07:57 +00:00
|
|
|
|
ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1;
|
|
|
|
|
ApproachCircle.Alpha = 0;
|
2017-02-06 13:17:29 +00:00
|
|
|
|
ApproachCircle.Scale = new Vector2(4);
|
2016-11-02 05:03:03 +00:00
|
|
|
|
explode.Alpha = 0;
|
2016-11-28 09:40:54 +00:00
|
|
|
|
}
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-28 09:40:54 +00:00
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
base.UpdatePreemptState();
|
2016-11-19 10:07:57 +00:00
|
|
|
|
|
2016-11-28 09:40:54 +00:00
|
|
|
|
ApproachCircle.FadeIn(Math.Min(TIME_FADEIN * 2, TIME_PREEMPT));
|
2017-02-06 13:17:29 +00:00
|
|
|
|
ApproachCircle.ScaleTo(1.1f, TIME_PREEMPT);
|
2016-11-28 09:40:54 +00:00
|
|
|
|
}
|
2016-11-18 08:36:53 +00:00
|
|
|
|
|
2017-04-27 08:37:38 +00:00
|
|
|
|
protected override void UpdateCurrentState(ArmedState state)
|
2016-11-28 09:40:54 +00:00
|
|
|
|
{
|
2016-11-19 10:07:57 +00:00
|
|
|
|
ApproachCircle.FadeOut();
|
2017-02-15 12:05:46 +00:00
|
|
|
|
|
2017-03-23 06:37:16 +00:00
|
|
|
|
double endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
|
|
|
|
|
double duration = endTime - HitObject.StartTime;
|
2017-03-13 10:15:25 +00:00
|
|
|
|
|
|
|
|
|
glow.Delay(duration);
|
2016-11-02 04:22:23 +00:00
|
|
|
|
glow.FadeOut(400);
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2016-11-25 07:26:50 +00:00
|
|
|
|
case ArmedState.Idle:
|
2017-03-13 10:15:25 +00:00
|
|
|
|
Delay(duration + TIME_PREEMPT);
|
2016-11-28 09:40:54 +00:00
|
|
|
|
FadeOut(TIME_FADEOUT);
|
2017-03-17 06:30:19 +00:00
|
|
|
|
Expire(true);
|
2016-10-19 07:13:53 +00:00
|
|
|
|
break;
|
2016-11-25 07:26:50 +00:00
|
|
|
|
case ArmedState.Miss:
|
2016-12-07 05:52:34 +00:00
|
|
|
|
FadeOut(TIME_FADEOUT / 5);
|
2017-03-17 06:30:19 +00:00
|
|
|
|
Expire();
|
2016-11-25 07:26:50 +00:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2016-12-15 13:35:12 +00:00
|
|
|
|
const double flash_in = 40;
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-02 04:22:23 +00:00
|
|
|
|
flash.FadeTo(0.8f, flash_in);
|
|
|
|
|
flash.Delay(flash_in);
|
|
|
|
|
flash.FadeOut(100);
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-02 04:22:23 +00:00
|
|
|
|
explode.FadeIn(flash_in);
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-02 04:22:23 +00:00
|
|
|
|
Delay(flash_in, true);
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-02 04:22:23 +00:00
|
|
|
|
//after the flash, we can hide some elements that were behind it
|
|
|
|
|
ring.FadeOut();
|
|
|
|
|
circle.FadeOut();
|
|
|
|
|
number.FadeOut();
|
2016-10-19 07:13:53 +00:00
|
|
|
|
|
2016-11-02 04:22:23 +00:00
|
|
|
|
FadeOut(800);
|
|
|
|
|
ScaleTo(Scale * 1.5f, 400, EasingTypes.OutQuad);
|
2017-03-17 06:30:19 +00:00
|
|
|
|
Expire();
|
2016-10-19 07:13:53 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-02-14 01:22:28 +00:00
|
|
|
|
|
|
|
|
|
public Drawable ProxiedLayer => ApproachCircle;
|
2016-10-13 01:10:15 +00:00
|
|
|
|
}
|
|
|
|
|
}
|