1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 07:53:38 +08:00
osu-lazer/osu.Game.Rulesets.Catch/Objects/Banana.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

74 lines
2.4 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using System;
2020-07-30 16:58:49 +08:00
using System.Collections.Generic;
using osu.Game.Audio;
using osu.Game.Rulesets.Catch.Judgements;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Skinning;
2020-12-02 14:22:45 +08:00
using osu.Game.Utils;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Catch.Objects
{
2020-12-07 13:10:17 +08:00
public class Banana : PalpableCatchHitObject, IHasComboInformation
{
2020-07-30 16:58:49 +08:00
/// <summary>
/// Index of banana in current shower.
/// </summary>
public int BananaIndex;
2018-08-06 10:50:18 +08:00
public override Judgement CreateJudgement() => new CatchBananaJudgement();
2020-07-30 16:58:49 +08:00
private static readonly List<HitSampleInfo> samples = new List<HitSampleInfo> { new BananaHitSampleInfo() };
public Banana()
{
Samples = samples;
}
// override any external colour changes with banananana
Color4 IHasComboInformation.GetComboColour(ISkin skin) => getBananaColour();
private Color4 getBananaColour()
{
switch (StatelessRNG.NextInt(3, RandomSeed))
{
default:
return new Color4(255, 240, 0, 255);
case 1:
return new Color4(255, 192, 0, 255);
case 2:
return new Color4(214, 221, 28, 255);
}
}
private class BananaHitSampleInfo : HitSampleInfo, IEquatable<BananaHitSampleInfo>
2020-07-30 16:58:49 +08:00
{
2020-12-02 14:22:45 +08:00
private static readonly string[] lookup_names = { "Gameplay/metronomelow", "Gameplay/catch-banana" };
2020-07-30 16:58:49 +08:00
public override IEnumerable<string> LookupNames => lookup_names;
2020-12-01 14:37:51 +08:00
2020-12-02 14:22:45 +08:00
public BananaHitSampleInfo(int volume = 0)
: base(string.Empty, volume: volume)
2020-12-01 14:37:51 +08:00
{
}
2020-12-02 14:22:45 +08:00
public sealed override HitSampleInfo With(Optional<string> newName = default, Optional<string?> newBank = default, Optional<string?> newSuffix = default, Optional<int> newVolume = default)
=> new BananaHitSampleInfo(newVolume.GetOr(Volume));
public bool Equals(BananaHitSampleInfo? other)
=> other != null;
2020-12-02 14:22:45 +08:00
public override bool Equals(object? obj)
=> obj is BananaHitSampleInfo other && Equals(other);
public override int GetHashCode() => lookup_names.GetHashCode();
2020-07-30 16:58:49 +08:00
}
}
}