Make catch plate fruit again

This commit is contained in:
Dean Herbert
2018-01-12 21:46:50 +09:00
parent 4ef23a8ee8
commit 93c4d58b69
7 changed files with 55 additions and 45 deletions

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -12,7 +13,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
private readonly Container bananaContainer;
public DrawableBananaShower(BananaShower s)
public DrawableBananaShower(BananaShower s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation = null)
: base(s)
{
RelativeSizeAxes = Axes.X;
@ -22,7 +23,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
Child = bananaContainer = new Container { RelativeSizeAxes = Axes.Both };
foreach (var b in s.NestedHitObjects.Cast<BananaShower.Banana>())
AddNested(new DrawableFruit(b));
AddNested(getVisualRepresentation?.Invoke(b));
}
protected override void AddNested(DrawableHitObject h)

View File

@ -5,6 +5,7 @@ using System;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using OpenTK;
using osu.Game.Rulesets.Scoring;
@ -13,6 +14,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
public abstract class PalpableCatchHitObject<TObject> : DrawableCatchHitObject<TObject>
where TObject : CatchHitObject
{
public override bool CanBePlated => true;
protected PalpableCatchHitObject(TObject hitObject)
: base(hitObject)
{
@ -36,6 +39,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
public abstract class DrawableCatchHitObject : DrawableHitObject<CatchHitObject>
{
public virtual bool CanBePlated => false;
protected DrawableCatchHitObject(CatchHitObject hitObject)
: base(hitObject)
{
@ -47,8 +52,10 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
protected override void CheckForJudgements(bool userTriggered, double timeOffset)
{
if (CheckPosition == null) return;
if (timeOffset > 0)
AddJudgement(new Judgement { Result = CheckPosition?.Invoke(HitObject) ?? false ? HitResult.Perfect : HitResult.Miss });
AddJudgement(new Judgement { Result = (bool)CheckPosition?.Invoke(HitObject) ? HitResult.Perfect : HitResult.Miss });
}
private const float preempt = 1000;
@ -61,12 +68,19 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
this.FadeIn(200);
}
switch (state)
var endTime = (HitObject as IHasEndTime)?.EndTime ?? HitObject.StartTime;
using (BeginAbsoluteSequence(endTime, true))
{
case ArmedState.Miss:
using (BeginAbsoluteSequence(HitObject.StartTime, true))
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out);
break;
switch (state)
{
case ArmedState.Miss:
this.FadeOut(250).RotateTo(Rotation * 2, 250, Easing.Out).Expire();
break;
case ArmedState.Hit:
this.FadeOut().Expire();
break;
}
}
}
}

View File

@ -1,9 +1,10 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using OpenTK;
using osu.Game.Rulesets.Objects.Drawables;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
@ -12,7 +13,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
private readonly Container dropletContainer;
public DrawableJuiceStream(JuiceStream s)
public DrawableJuiceStream(JuiceStream s, Func<CatchHitObject, DrawableHitObject<CatchHitObject>> getVisualRepresentation = null)
: base(s)
{
RelativeSizeAxes = Axes.Both;
@ -21,21 +22,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawable
Child = dropletContainer = new Container { RelativeSizeAxes = Axes.Both, };
foreach (var tick in s.NestedHitObjects)
{
switch (tick)
{
case TinyDroplet tiny:
AddNested(new DrawableDroplet(tiny) { Scale = new Vector2(0.5f) });
break;
case Droplet droplet:
AddNested(new DrawableDroplet(droplet));
break;
case Fruit fruit:
AddNested(new DrawableFruit(fruit));
break;
}
}
foreach (var o in s.NestedHitObjects.Cast<CatchHitObject>())
AddNested(getVisualRepresentation?.Invoke(o));
}
protected override void AddNested(DrawableHitObject h)

View File

@ -125,10 +125,8 @@ namespace osu.Game.Rulesets.Catch.Objects
X = Curve.PositionAt(reversed ? 0 : 1).X / CatchPlayfield.BASE_WIDTH
});
}
}
public double EndTime => StartTime + RepeatCount * Curve.Distance / Velocity;
public float EndX => Curve.PositionAt(ProgressAt(1)).X / CatchPlayfield.BASE_WIDTH;