mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 16:12:54 +08:00
Set banana combo colour using random seed
This commit is contained in:
parent
beda6961e4
commit
08848e49de
@ -3,11 +3,11 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Utils;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Rulesets.Catch.Judgements;
|
||||
using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osu.Game.Utils;
|
||||
using osuTK.Graphics;
|
||||
|
||||
namespace osu.Game.Rulesets.Catch.Objects
|
||||
@ -28,17 +28,12 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
Samples = samples;
|
||||
}
|
||||
|
||||
private Color4? colour;
|
||||
|
||||
Color4 IHasComboInformation.GetComboColour(IReadOnlyList<Color4> comboColours)
|
||||
{
|
||||
// override any external colour changes with banananana
|
||||
return colour ??= getBananaColour();
|
||||
}
|
||||
// override any external colour changes with banananana
|
||||
Color4 IHasComboInformation.GetComboColour(IReadOnlyList<Color4> comboColours) => getBananaColour();
|
||||
|
||||
private Color4 getBananaColour()
|
||||
{
|
||||
switch (RNG.Next(0, 3))
|
||||
switch (StatelessRNG.NextInt(3, RandomSeed.Value))
|
||||
{
|
||||
default:
|
||||
return new Color4(255, 240, 0, 255);
|
||||
|
@ -97,6 +97,12 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
set => ScaleBindable.Value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The seed value used for visual randomness such as fruit rotation.
|
||||
/// By default, <see cref="HitObject.StartTime"/> truncated to an integer is used.
|
||||
/// </summary>
|
||||
public Bindable<int> RandomSeed = new Bindable<int>();
|
||||
|
||||
protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
|
||||
@ -111,6 +117,10 @@ namespace osu.Game.Rulesets.Catch.Objects
|
||||
protected CatchHitObject()
|
||||
{
|
||||
XBindable.BindValueChanged(x => originalX = x.NewValue - xOffset);
|
||||
StartTimeBindable.BindValueChanged(change =>
|
||||
{
|
||||
RandomSeed.Value = (int)change.NewValue;
|
||||
}, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,11 +3,9 @@
|
||||
|
||||
using System;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Catch.UI;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Utils;
|
||||
|
||||
@ -23,10 +21,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
|
||||
protected override float SamplePlaybackPosition => HitObject.X / CatchPlayfield.WIDTH;
|
||||
|
||||
/// <summary>
|
||||
/// The seed value used for visual randomness such as fruit rotation.
|
||||
/// By default, <see cref="HitObject.StartTime"/> truncated to an integer is used.
|
||||
/// </summary>
|
||||
public Bindable<int> RandomSeed = new Bindable<int>();
|
||||
|
||||
protected DrawableCatchHitObject([CanBeNull] CatchHitObject hitObject)
|
||||
@ -35,15 +29,6 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
Anchor = Anchor.BottomLeft;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
StartTimeBindable.BindValueChanged(change =>
|
||||
{
|
||||
RandomSeed.Value = (int)change.NewValue;
|
||||
}, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a random number in range [0,1) based on seed <see cref="RandomSeed"/>.
|
||||
/// </summary>
|
||||
@ -54,6 +39,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
base.OnApply();
|
||||
|
||||
XBindable.BindTo(HitObject.XBindable);
|
||||
RandomSeed.BindTo(HitObject.RandomSeed);
|
||||
}
|
||||
|
||||
protected override void OnFree()
|
||||
@ -61,6 +47,7 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
||||
base.OnFree();
|
||||
|
||||
XBindable.UnbindFrom(HitObject.XBindable);
|
||||
RandomSeed.UnbindFrom(HitObject.RandomSeed);
|
||||
}
|
||||
|
||||
public Func<CatchHitObject, bool> CheckPosition;
|
||||
|
Loading…
Reference in New Issue
Block a user