Skip to content

Commit

Permalink
Merge branch 'master' into ImproveArrowFlip
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Nov 10, 2020
2 parents 12d1279 + e967e55 commit f148072
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>
<ItemGroup Label="Package References">
<PackageReference Include="Appveyor.TestLogger" Version="2.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="NUnit3TestAdapter" Version="3.17.0" />
</ItemGroup>
Expand Down
100 changes: 100 additions & 0 deletions osu.Game.Rulesets.Hishigata/UI/Components/EffectsContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using System;
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osuTK;
using osuTK.Graphics;

namespace osu.Game.Rulesets.Hishigata.UI.Components
{
public class EffectContainer : BeatSyncedContainer
{
public EffectContainer()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.None;
Rotation = 45;
}

protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
int MainBeatInterval = Math.Max((int)(timingPoint.BPM / 80), 1);

if (effectPoint.KiaiMode)
{
if ((beatIndex % MainBeatInterval) == 0)
Add(new Effect(timingPoint.BeatLength, MainBeatInterval));

Add(new LineEffect(timingPoint.BeatLength));
}
}

public class LineEffect : CompositeDrawable
{
private readonly double animDuration;

public override bool RemoveWhenNotAlive => base.RemoveWhenNotAlive;

public LineEffect(double duration)
{
animDuration = duration;
Size = new Vector2(450);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Masking = true;
BorderThickness = 5;
BorderColour = Color4.White;
RelativeSizeAxes = Axes.None;
Alpha = .8f;
Colour = new Color4(RNG.NextSingle(.5f), RNG.NextSingle(.5f), RNG.NextSingle(.5f), 1);
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
AlwaysPresent = true,
Alpha = 0,
};
}

protected override void LoadComplete()
{
this.ScaleTo(6, animDuration * 2).FadeOut(animDuration * 2).Expire(true);
}
}

public class Effect : CompositeDrawable
{
private readonly double animDuration;
private readonly double durationMultiplier;

public override bool RemoveWhenNotAlive => base.RemoveWhenNotAlive;

public Effect(double duration, double multiplier)
{
animDuration = duration;
durationMultiplier = multiplier;

Size = new Vector2(450);
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.None;
Alpha = .4f;
Colour = new Color4(RNG.NextSingle(.5f), RNG.NextSingle(.5f), RNG.NextSingle(.5f), 1);
InternalChild = new Box
{
RelativeSizeAxes = Axes.Both,
};
}

protected override void LoadComplete()
{
this.ScaleTo(6 * (float)durationMultiplier, animDuration * 2 * durationMultiplier).FadeOut(animDuration * 2 * durationMultiplier).Expire(true);
}
}
}
}
30 changes: 25 additions & 5 deletions osu.Game.Rulesets.Hishigata/UI/Components/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using osu.Game.Rulesets.Hishigata.Objects.Drawables;
using osuTK;
using osuTK.Graphics;
using System.Collections.Generic;
using System.Linq;

namespace osu.Game.Rulesets.Hishigata.UI.Components
{
Expand Down Expand Up @@ -109,18 +111,36 @@ protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint,
}

private HishigataAction lastAction = HishigataAction.Up;
private BindableList<HishigataAction> registeredActions = new BindableList<HishigataAction>();

protected override void LoadComplete()
{
base.LoadComplete();
registeredActions.BindCollectionChanged((x, y) => rotatePlayer());
}

public bool OnPressed(HishigataAction action)
{
registeredActions.Add(action);
return true;
}
public void OnReleased(HishigataAction action)
{
registeredActions.Remove(action);
}

private void rotatePlayer()
{
if (!registeredActions.Any() || registeredActions.Last() == lastAction) return;

FinishTransforms();
float FacingAngle = action.ToAngle();
float FacingAngle = registeredActions.Last().ToAngle();

this.ScaleTo(new Vector2(1.1f), 50).Then().ScaleTo(1, 50);
rotateToClosestEquivalent(FacingAngle);

lastAction = action;
return true;
rotateToClosestEquivalent(FacingAngle);
lastAction = registeredActions.Last();
}
public void OnReleased(HishigataAction action) { }

private void rotateToClosestEquivalent(float angle, Easing easing = Easing.None)
{
Expand Down
41 changes: 41 additions & 0 deletions osu.Game.Rulesets.Hishigata/UI/Components/Rhombus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using osu.Framework.Audio.Track;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics.Containers;
using osuTK;
using osuTK.Graphics;
using System;

namespace osu.Game.Rulesets.Hishigata.UI.Components
{
public class Rhombus : BeatSyncedContainer
{
public Rhombus()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.None;
Size = new Vector2(450);
Rotation = 45;
Masking = true;
BorderColour = Color4.Gray;
BorderThickness = 10;
Child = new Box
{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Alpha = .8f
};
}

protected override void OnNewBeat(int beatIndex, TimingControlPoint timingPoint, EffectControlPoint effectPoint, ChannelAmplitudes amplitudes)
{
if (amplitudes.Maximum <= .01f) return;
FinishTransforms();
this.ResizeTo(effectPoint.KiaiMode ? 459f : 454.5f, 100).Then().ResizeTo(450, 50);
}
}
}
32 changes: 11 additions & 21 deletions osu.Game.Rulesets.Hishigata/UI/HishigataPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics.Containers;
using osu.Game.Rulesets.Hishigata.Objects.Drawables;
using osu.Game.Rulesets.Hishigata.UI.Components;
using osu.Game.Rulesets.Objects.Drawables;
Expand All @@ -18,32 +19,21 @@ public class HishigataPlayfield : Playfield
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;

private readonly List<Lane> lanes = new List<Lane>();
private readonly Container playfieldContainer;
private readonly PlayerVisual playerObject;
private Container playfieldContainer;
private PlayerVisual playerObject;

public HishigataPlayfield()
{
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
RelativeSizeAxes = Axes.None;
Size = new Vector2(450);
Rotation = 45;
Masking = true;
BorderColour = Color4.Gray;
BorderThickness = 10;
AddRangeInternal(new Drawable[]
AddInternal(new EffectContainer());
AddInternal(new Rhombus().With(x => x.Add(playfieldContainer = new Container
{
new Box{
Colour = Color4.Black,
RelativeSizeAxes = Axes.Both,
Alpha = .8f
},
playfieldContainer = new Container{
Rotation = -45,
Anchor = Anchor.Centre,
Origin= Anchor.Centre,
Child = playerObject = new PlayerVisual()
}
});
Rotation = -45,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Child = playerObject = new PlayerVisual()
})));

for (int i = 0; i < 4; ++i)
{
Expand Down

0 comments on commit f148072

Please sign in to comment.