1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 18:33:22 +08:00

Merge pull request #1088 from peppy/catch-catcher

osu!catch: Catcher and basic structure
This commit is contained in:
Dan Balasescu 2017-08-09 14:00:33 +09:00 committed by GitHub
commit 50b7fdce1c
10 changed files with 304 additions and 23 deletions

@ -1 +1 @@
Subproject commit 107c5517670ca88dbe8c83a97e37e99ac5742ee6
Subproject commit d29abdf0d042d832f0849c013d14762db04730e7

@ -1 +1 @@
Subproject commit 76656c51f281e7934159e9ed4414378fef24d130
Subproject commit f6042e1cb37cfad6c879d0e1245f7880c7fcd5f5

View File

@ -0,0 +1,29 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Game.Rulesets.Catch.UI;
using OpenTK;
namespace osu.Desktop.Tests.Visual
{
internal class TestCaseCatcher : OsuTestCase
{
protected override void LoadComplete()
{
base.LoadComplete();
Children = new Drawable[]
{
new CatcherArea
{
RelativePositionAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
Origin = Anchor.BottomLeft,
Size = new Vector2(1, 0.2f),
}
};
}
}
}

View File

@ -71,6 +71,7 @@
<Compile Include="Visual\TestCaseBeatmapOptionsOverlay.cs" />
<Compile Include="Visual\TestCaseBeatSyncedContainer.cs" />
<Compile Include="Visual\TestCaseBreadcrumbs.cs" />
<Compile Include="Visual\TestCaseCatcher.cs" />
<Compile Include="Visual\TestCaseChatDisplay.cs" />
<Compile Include="Visual\TestCaseContextMenu.cs" />
<Compile Include="Visual\TestCaseDialogOverlay.cs" />

View File

@ -8,6 +8,7 @@ using System;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Osu.UI;
namespace osu.Game.Rulesets.Catch.Beatmaps
{
@ -15,9 +16,16 @@ namespace osu.Game.Rulesets.Catch.Beatmaps
{
protected override IEnumerable<Type> ValidConversionTypes { get; } = new[] { typeof(IHasXPosition) };
protected override IEnumerable<CatchBaseHit> ConvertHitObject(HitObject original, Beatmap beatmap)
protected override IEnumerable<CatchBaseHit> ConvertHitObject(HitObject obj, Beatmap beatmap)
{
yield return null;
if (!(obj is IHasXPosition))
yield break;
yield return new Fruit
{
StartTime = obj.StartTime,
Position = ((IHasXPosition)obj).X / OsuPlayfield.BASE_SIZE.X
};
}
}
}

View File

@ -2,34 +2,114 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.MathUtils;
using osu.Game.Graphics;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using OpenTK;
using OpenTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects.Drawable
{
internal class DrawableFruit : Sprite
internal class DrawableFruit : DrawableHitObject<CatchBaseHit, CatchJudgement>
{
//private readonly CatchBaseHit h;
public DrawableFruit(CatchBaseHit h)
private class Pulp : Circle, IHasAccentColour
{
//this.h = h;
public Pulp()
{
EdgeEffect = new EdgeEffectParameters
{
Type = EdgeEffectType.Glow,
Radius = 5,
Colour = AccentColour.Opacity(0.5f),
};
}
public Color4 AccentColour { get; set; } = Color4.White;
}
public DrawableFruit(CatchBaseHit h) : base(h)
{
Origin = Anchor.Centre;
Scale = new Vector2(0.1f);
RelativePositionAxes = Axes.Y;
Size = new Vector2(50);
RelativePositionAxes = Axes.Both;
Position = new Vector2(h.Position, -0.1f);
Rotation = (float)(RNG.NextDouble() - 0.5f) * 40;
Alpha = 0;
}
[BackgroundDependencyLoader]
private void load(TextureStore textures)
private void load()
{
Texture = textures.Get(@"Menu/logo");
Children = new Framework.Graphics.Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4.Red,
},
new Pulp
{
RelativePositionAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Scale = new Vector2(0.12f),
Y = 0.08f,
},
new Pulp
{
RelativePositionAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Scale = new Vector2(0.32f),
Position = new Vector2(-0.16f, 0.3f),
},
new Pulp
{
RelativePositionAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Scale = new Vector2(0.32f),
Position = new Vector2(0.16f, 0.3f),
},
new Pulp
{
RelativePositionAxes = Axes.Both,
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Scale = new Vector2(0.32f),
Position = new Vector2(0, 0.6f),
},
};
Alpha = 0;
}
protected override CatchJudgement CreateJudgement() => new CatchJudgement();
private const float preempt = 1000;
protected override void UpdateState(ArmedState state)
{
using (BeginAbsoluteSequence(HitObject.StartTime - preempt))
{
// default state
this.MoveToY(-0.1f).FadeOut();
// animation
this.FadeIn(200).MoveToY(1, preempt);
}
//Transforms.Add(new TransformPosition { StartTime = h.StartTime - 200, EndTime = h.StartTime, StartValue = new Vector2(h.Position, -0.1f), EndValue = new Vector2(h.Position, 0.9f) });
//Transforms.Add(new TransformAlpha { StartTime = h.StartTime + duration + 200, EndTime = h.StartTime + duration + 400, StartValue = 1, EndValue = 0 });
Expire(true);
}
}

View File

@ -6,6 +6,7 @@ using osu.Game.Rulesets.Beatmaps;
using osu.Game.Rulesets.Catch.Beatmaps;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Catch.Objects.Drawable;
using osu.Game.Rulesets.Catch.Scoring;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
@ -26,6 +27,12 @@ namespace osu.Game.Rulesets.Catch.UI
protected override Playfield<CatchBaseHit, CatchJudgement> CreatePlayfield() => new CatchPlayfield();
protected override DrawableHitObject<CatchBaseHit, CatchJudgement> GetVisualRepresentation(CatchBaseHit h) => null;
protected override DrawableHitObject<CatchBaseHit, CatchJudgement> GetVisualRepresentation(CatchBaseHit h)
{
if (h is Fruit)
return new DrawableFruit(h);
return null;
}
}
}

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.UI;
using OpenTK;
@ -14,11 +13,21 @@ namespace osu.Game.Rulesets.Catch.UI
{
public CatchPlayfield()
{
Size = new Vector2(1, 0.9f);
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
Size = new Vector2(1);
Add(new Box { RelativeSizeAxes = Axes.Both, Alpha = 0.5f });
Anchor = Anchor.TopCentre;
Origin = Anchor.TopCentre;
Children = new Drawable[]
{
new CatcherArea
{
RelativeSizeAxes = Axes.Both,
Anchor = Anchor.BottomLeft,
Origin = Anchor.TopLeft,
Height = 0.3f
}
};
}
}
}

View File

@ -0,0 +1,146 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using OpenTK;
using OpenTK.Input;
namespace osu.Game.Rulesets.Catch.UI
{
public class CatcherArea : Container
{
public override bool HandleInput => true;
private Sprite catcher;
private Drawable createAdditiveFrame() => new Sprite
{
RelativePositionAxes = Axes.Both,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
Texture = catcher.Texture,
BlendingMode = BlendingMode.Additive,
Position = catcher.Position,
Scale = catcher.Scale,
};
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
Children = new Drawable[]
{
catcher = new Sprite
{
RelativePositionAxes = Axes.Both,
Anchor = Anchor.TopLeft,
Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.Both,
FillMode = FillMode.Fit,
X = 0.5f,
Texture = textures.Get(@"Play/Catch/fruit-catcher-idle"),
},
};
}
private bool leftPressed;
private bool rightPressed;
private int currentDirection;
private bool dashing;
protected bool Dashing
{
get
{
return dashing;
}
set
{
if (value == dashing) return;
dashing = value;
if (dashing)
Schedule(addAdditiveSprite);
}
}
private void addAdditiveSprite()
{
if (!dashing) return;
var additive = createAdditiveFrame();
Add(additive);
additive.FadeTo(0.4f).FadeOut(800, Easing.OutQuint).Expire();
Scheduler.AddDelayed(addAdditiveSprite, 50);
}
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
{
if (args.Repeat) return true;
switch (args.Key)
{
case Key.Left:
currentDirection = -1;
leftPressed = true;
return true;
case Key.Right:
currentDirection = 1;
rightPressed = true;
return true;
case Key.ShiftLeft:
Dashing = true;
return true;
}
return base.OnKeyDown(state, args);
}
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args)
{
switch (args.Key)
{
case Key.Left:
currentDirection = rightPressed ? 1 : 0;
leftPressed = false;
return true;
case Key.Right:
currentDirection = leftPressed ? -1 : 0;
rightPressed = false;
return true;
case Key.ShiftLeft:
Dashing = false;
return true;
}
return base.OnKeyUp(state, args);
}
protected override void Update()
{
base.Update();
if (currentDirection == 0) return;
float speed = Dashing ? 1.5f : 1;
catcher.Scale = new Vector2(Math.Sign(currentDirection), 1);
catcher.X = (float)MathHelper.Clamp(catcher.X + currentDirection * Clock.ElapsedFrameTime / 1800 * speed, 0, 1);
}
}
}

View File

@ -57,6 +57,7 @@
<Compile Include="Objects\Droplet.cs" />
<Compile Include="Objects\Fruit.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="UI\CatcherArea.cs" />
<Compile Include="UI\CatchHitRenderer.cs" />
<Compile Include="UI\CatchPlayfield.cs" />
<Compile Include="CatchRuleset.cs" />