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
|
|
|
|
|
|
2016-11-19 18:07:57 +08:00
|
|
|
|
using System;
|
2016-11-26 15:51:51 +08:00
|
|
|
|
using System.ComponentModel;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Transformations;
|
2016-11-14 18:49:29 +08:00
|
|
|
|
using osu.Game.Modes.Objects.Drawables;
|
2016-11-17 16:20:51 +08:00
|
|
|
|
using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
|
2016-11-02 11:22:29 +08:00
|
|
|
|
using OpenTK;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
2016-11-14 17:54:24 +08:00
|
|
|
|
namespace osu.Game.Modes.Osu.Objects.Drawables
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2016-11-26 15:51:51 +08:00
|
|
|
|
public class DrawableHitCircle : DrawableOsuHitObject
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-12-11 17:11:22 +08:00
|
|
|
|
private HitCircle osuObject;
|
2016-11-18 16:36:53 +08:00
|
|
|
|
|
2016-11-19 18:07:57 +08:00
|
|
|
|
public ApproachCircle ApproachCircle;
|
2016-11-17 16:20:51 +08:00
|
|
|
|
private CirclePiece circle;
|
|
|
|
|
private RingPiece ring;
|
|
|
|
|
private FlashPiece flash;
|
|
|
|
|
private ExplodePiece explode;
|
|
|
|
|
private NumberPiece number;
|
|
|
|
|
private GlowPiece glow;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
2016-12-11 17:11:22 +08:00
|
|
|
|
public DrawableHitCircle(HitCircle h) : base(h)
|
2016-10-13 09:10:15 +08:00
|
|
|
|
{
|
2016-11-18 16:36:53 +08:00
|
|
|
|
osuObject = h;
|
2016-10-13 09:10:15 +08:00
|
|
|
|
|
|
|
|
|
Origin = Anchor.Centre;
|
2016-11-18 16:36:53 +08:00
|
|
|
|
Position = osuObject.Position;
|
2016-12-11 17:11:22 +08:00
|
|
|
|
Scale = new Vector2(osuObject.Scale);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-14 17:54:24 +08:00
|
|
|
|
Children = new Drawable[]
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-17 16:20:51 +08:00
|
|
|
|
glow = new GlowPiece
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-18 16:36:53 +08:00
|
|
|
|
Colour = osuObject.Colour
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
2016-11-17 16:20:51 +08:00
|
|
|
|
circle = new CirclePiece
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-18 16:36:53 +08:00
|
|
|
|
Colour = osuObject.Colour,
|
2016-11-26 15:51:51 +08:00
|
|
|
|
Hit = () =>
|
|
|
|
|
{
|
2017-01-08 20:52:19 +08:00
|
|
|
|
if (Judgement.Result.HasValue) return false;
|
|
|
|
|
|
2016-11-26 15:51:51 +08:00
|
|
|
|
((PositionalJudgementInfo)Judgement).PositionOffset = Vector2.Zero; //todo: set to correct value
|
|
|
|
|
UpdateJudgement(true);
|
|
|
|
|
return true;
|
|
|
|
|
},
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
2016-11-17 16:20:51 +08:00
|
|
|
|
number = new NumberPiece(),
|
|
|
|
|
ring = new RingPiece(),
|
|
|
|
|
flash = new FlashPiece(),
|
|
|
|
|
explode = new ExplodePiece
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-18 16:36:53 +08:00
|
|
|
|
Colour = osuObject.Colour,
|
2016-10-19 15:13:53 +08:00
|
|
|
|
},
|
2016-11-19 18:07:57 +08:00
|
|
|
|
ApproachCircle = new ApproachCircle()
|
2016-10-19 15:13:53 +08:00
|
|
|
|
{
|
2016-11-18 16:36:53 +08:00
|
|
|
|
Colour = osuObject.Colour,
|
2016-10-19 15:13:53 +08:00
|
|
|
|
}
|
|
|
|
|
};
|
2016-11-28 11:40:24 +08:00
|
|
|
|
|
|
|
|
|
//may not be so correct
|
|
|
|
|
Size = circle.DrawSize;
|
2016-11-19 18:07:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
2016-11-26 15:51:51 +08:00
|
|
|
|
double hit50 = 150;
|
|
|
|
|
double hit100 = 80;
|
|
|
|
|
double hit300 = 30;
|
|
|
|
|
|
|
|
|
|
protected override void CheckJudgement(bool userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (!userTriggered)
|
|
|
|
|
{
|
|
|
|
|
if (Judgement.TimeOffset > hit50)
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
double hitOffset = Math.Abs(Judgement.TimeOffset);
|
|
|
|
|
|
|
|
|
|
if (hitOffset < hit50)
|
|
|
|
|
{
|
|
|
|
|
Judgement.Result = HitResult.Hit;
|
|
|
|
|
|
|
|
|
|
OsuJudgementInfo osuInfo = Judgement as OsuJudgementInfo;
|
|
|
|
|
|
|
|
|
|
if (hitOffset < hit300)
|
|
|
|
|
osuInfo.Score = OsuScoreResult.Hit300;
|
|
|
|
|
else if (hitOffset < hit100)
|
|
|
|
|
osuInfo.Score = OsuScoreResult.Hit100;
|
|
|
|
|
else if (hitOffset < hit50)
|
|
|
|
|
osuInfo.Score = OsuScoreResult.Hit50;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
Judgement.Result = HitResult.Miss;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-28 17:40:54 +08:00
|
|
|
|
protected override void UpdateInitialState()
|
2016-10-19 18:44:03 +08:00
|
|
|
|
{
|
2016-11-28 17:40:54 +08:00
|
|
|
|
base.UpdateInitialState();
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-02 12:22:23 +08:00
|
|
|
|
//sane defaults
|
2016-11-19 18:07:57 +08:00
|
|
|
|
ring.Alpha = circle.Alpha = number.Alpha = glow.Alpha = 1;
|
|
|
|
|
ApproachCircle.Alpha = 0;
|
2017-02-06 21:17:29 +08:00
|
|
|
|
ApproachCircle.Scale = new Vector2(4);
|
2016-11-02 13:03:03 +08:00
|
|
|
|
explode.Alpha = 0;
|
2016-11-28 17:40:54 +08:00
|
|
|
|
}
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-28 17:40:54 +08:00
|
|
|
|
protected override void UpdatePreemptState()
|
|
|
|
|
{
|
|
|
|
|
base.UpdatePreemptState();
|
2016-11-19 18:07:57 +08:00
|
|
|
|
|
2016-11-28 17:40:54 +08:00
|
|
|
|
ApproachCircle.FadeIn(Math.Min(TIME_FADEIN * 2, TIME_PREEMPT));
|
2017-02-06 21:17:29 +08:00
|
|
|
|
ApproachCircle.ScaleTo(1.1f, TIME_PREEMPT);
|
2016-11-28 17:40:54 +08:00
|
|
|
|
}
|
2016-11-18 16:36:53 +08:00
|
|
|
|
|
2016-11-28 17:40:54 +08:00
|
|
|
|
protected override void UpdateState(ArmedState state)
|
|
|
|
|
{
|
|
|
|
|
if (!IsLoaded) return;
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-28 17:40:54 +08:00
|
|
|
|
base.UpdateState(state);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
2016-11-19 18:07:57 +08:00
|
|
|
|
ApproachCircle.FadeOut();
|
2016-11-02 12:22:23 +08:00
|
|
|
|
glow.FadeOut(400);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
|
|
|
|
|
switch (state)
|
|
|
|
|
{
|
2016-11-25 15:26:50 +08:00
|
|
|
|
case ArmedState.Idle:
|
2016-11-28 17:40:54 +08:00
|
|
|
|
Delay(osuObject.Duration + TIME_PREEMPT);
|
|
|
|
|
FadeOut(TIME_FADEOUT);
|
2016-10-19 15:13:53 +08:00
|
|
|
|
break;
|
2016-11-25 15:26:50 +08:00
|
|
|
|
case ArmedState.Miss:
|
2016-12-07 13:52:34 +08:00
|
|
|
|
FadeOut(TIME_FADEOUT / 5);
|
2016-11-25 15:26:50 +08:00
|
|
|
|
break;
|
|
|
|
|
case ArmedState.Hit:
|
2016-12-15 21:35:12 +08:00
|
|
|
|
const double flash_in = 40;
|
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-10-13 09:10:15 +08:00
|
|
|
|
}
|
|
|
|
|
}
|