2018-01-05 19:21:19 +08:00
|
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
2017-02-07 12:59:30 +08:00
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
2016-11-09 18:49:05 +08:00
|
|
|
|
|
2018-01-15 16:43:45 +08:00
|
|
|
|
using System;
|
2017-03-10 14:08:53 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2017-04-18 15:05:58 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
2017-03-10 14:08:53 +08:00
|
|
|
|
using System.Collections.Generic;
|
2018-01-15 16:43:45 +08:00
|
|
|
|
using System.Linq;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2017-08-23 11:49:50 +08:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2017-08-03 13:36:21 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2016-11-09 18:49:05 +08:00
|
|
|
|
|
2017-04-18 15:05:58 +08:00
|
|
|
|
namespace osu.Game.Rulesets.Mania
|
2016-11-09 18:49:05 +08:00
|
|
|
|
{
|
2016-11-14 21:03:39 +08:00
|
|
|
|
public class ManiaRuleset : Ruleset
|
2016-11-09 18:49:05 +08:00
|
|
|
|
{
|
2017-08-09 12:28:29 +08:00
|
|
|
|
public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new ManiaRulesetContainer(this, beatmap, isForCurrentRuleset);
|
2016-11-14 21:03:39 +08:00
|
|
|
|
|
2017-03-02 13:07:28 +08:00
|
|
|
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
switch (type)
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
case ModType.DifficultyReduction:
|
|
|
|
|
return new Mod[]
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new ManiaModEasy(),
|
|
|
|
|
new ManiaModNoFail(),
|
2017-05-31 00:49:06 +08:00
|
|
|
|
new MultiMod
|
|
|
|
|
{
|
|
|
|
|
Mods = new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModHalfTime(),
|
|
|
|
|
new ManiaModDaycore(),
|
|
|
|
|
},
|
|
|
|
|
},
|
2017-03-02 13:07:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case ModType.DifficultyIncrease:
|
|
|
|
|
return new Mod[]
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new ManiaModHardRock(),
|
|
|
|
|
new MultiMod
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
Mods = new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModSuddenDeath(),
|
2017-03-02 19:27:13 +08:00
|
|
|
|
new ManiaModPerfect(),
|
2017-03-02 13:07:28 +08:00
|
|
|
|
},
|
2017-03-02 10:05:52 +08:00
|
|
|
|
},
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new MultiMod
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
Mods = new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModDoubleTime(),
|
|
|
|
|
new ManiaModNightcore(),
|
|
|
|
|
},
|
2017-03-02 10:05:52 +08:00
|
|
|
|
},
|
2017-03-07 20:05:50 +08:00
|
|
|
|
new MultiMod
|
|
|
|
|
{
|
|
|
|
|
Mods = new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModFadeIn(),
|
|
|
|
|
new ManiaModHidden(),
|
|
|
|
|
}
|
|
|
|
|
},
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new ManiaModFlashlight(),
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
case ModType.Special:
|
|
|
|
|
return new Mod[]
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new MultiMod
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
Mods = new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModKey4(),
|
|
|
|
|
new ManiaModKey5(),
|
|
|
|
|
new ManiaModKey6(),
|
|
|
|
|
new ManiaModKey7(),
|
|
|
|
|
new ManiaModKey8(),
|
|
|
|
|
new ManiaModKey9(),
|
|
|
|
|
new ManiaModKey1(),
|
|
|
|
|
new ManiaModKey2(),
|
|
|
|
|
new ManiaModKey3(),
|
|
|
|
|
},
|
2017-03-02 10:05:52 +08:00
|
|
|
|
},
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new ManiaModRandom(),
|
2018-01-22 14:11:15 +08:00
|
|
|
|
new ManiaModDualStages(),
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new MultiMod
|
2017-03-02 10:05:52 +08:00
|
|
|
|
{
|
2017-03-02 13:07:28 +08:00
|
|
|
|
Mods = new Mod[]
|
|
|
|
|
{
|
2017-09-12 14:52:18 +08:00
|
|
|
|
new ManiaModAutoplay(),
|
2017-03-02 13:07:28 +08:00
|
|
|
|
new ModCinema(),
|
|
|
|
|
},
|
2017-03-02 10:05:52 +08:00
|
|
|
|
},
|
2017-03-02 13:07:28 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
return new Mod[] { };
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-02 10:05:52 +08:00
|
|
|
|
|
2017-03-10 04:37:03 +08:00
|
|
|
|
public override string Description => "osu!mania";
|
|
|
|
|
|
2017-12-08 17:55:25 +08:00
|
|
|
|
public override string ShortName => "mania";
|
|
|
|
|
|
2017-08-03 13:36:21 +08:00
|
|
|
|
public override Drawable CreateIcon() => new SpriteIcon { Icon = FontAwesome.fa_osu_mania_o };
|
2017-01-30 12:35:40 +08:00
|
|
|
|
|
2017-11-16 19:06:32 +08:00
|
|
|
|
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap, Mod[] mods = null) => new ManiaDifficultyCalculator(beatmap);
|
2017-03-16 12:13:45 +08:00
|
|
|
|
|
2017-04-17 16:43:48 +08:00
|
|
|
|
public override int LegacyID => 3;
|
2017-08-09 12:04:11 +08:00
|
|
|
|
|
2018-01-10 15:58:10 +08:00
|
|
|
|
public ManiaRuleset(RulesetInfo rulesetInfo = null)
|
2017-08-09 12:04:11 +08:00
|
|
|
|
: base(rulesetInfo)
|
|
|
|
|
{
|
|
|
|
|
}
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
2018-01-15 16:43:45 +08:00
|
|
|
|
public override IEnumerable<int> AvailableVariants
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
for (int i = 1; i <= 9; i++)
|
2018-01-22 13:59:17 +08:00
|
|
|
|
yield return (int)PlayfieldType.Single + i;
|
2018-01-22 14:47:31 +08:00
|
|
|
|
for (int i = 2; i <= 18; i += 2)
|
2018-01-22 13:59:17 +08:00
|
|
|
|
yield return (int)PlayfieldType.Dual + i;
|
2018-01-15 16:43:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
|
|
|
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0)
|
|
|
|
|
{
|
2018-01-22 14:18:11 +08:00
|
|
|
|
switch (getPlayfieldType(variant))
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
2018-01-22 13:59:17 +08:00
|
|
|
|
case PlayfieldType.Single:
|
2018-01-15 16:43:45 +08:00
|
|
|
|
return new VariantMappingGenerator
|
|
|
|
|
{
|
|
|
|
|
LeftKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.A,
|
|
|
|
|
InputKey.S,
|
|
|
|
|
InputKey.D,
|
|
|
|
|
InputKey.F
|
|
|
|
|
},
|
|
|
|
|
RightKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.J,
|
|
|
|
|
InputKey.K,
|
|
|
|
|
InputKey.L,
|
|
|
|
|
InputKey.Semicolon
|
|
|
|
|
},
|
|
|
|
|
SpecialKey = InputKey.Space,
|
2018-01-15 16:58:04 +08:00
|
|
|
|
SpecialAction = ManiaAction.Special1,
|
2018-01-15 16:43:45 +08:00
|
|
|
|
NormalActionStart = ManiaAction.Key1,
|
2018-01-22 13:38:41 +08:00
|
|
|
|
}.GenerateKeyBindingsFor(variant, out _);
|
2018-01-22 13:59:17 +08:00
|
|
|
|
case PlayfieldType.Dual:
|
2018-01-22 14:18:39 +08:00
|
|
|
|
int keys = getDualStageKeyCount(variant);
|
2018-01-15 16:43:45 +08:00
|
|
|
|
|
2018-01-22 13:54:47 +08:00
|
|
|
|
var stage1Bindings = new VariantMappingGenerator
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
|
|
|
|
LeftKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.Number1,
|
|
|
|
|
InputKey.Number2,
|
|
|
|
|
InputKey.Number3,
|
|
|
|
|
InputKey.Number4,
|
|
|
|
|
},
|
|
|
|
|
RightKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.Z,
|
|
|
|
|
InputKey.X,
|
|
|
|
|
InputKey.C,
|
|
|
|
|
InputKey.V
|
|
|
|
|
},
|
|
|
|
|
SpecialKey = InputKey.Tilde,
|
2018-01-15 16:58:04 +08:00
|
|
|
|
SpecialAction = ManiaAction.Special1,
|
2018-01-15 16:43:45 +08:00
|
|
|
|
NormalActionStart = ManiaAction.Key1
|
2018-01-22 14:18:39 +08:00
|
|
|
|
}.GenerateKeyBindingsFor(keys, out var nextNormal);
|
2018-01-15 16:43:45 +08:00
|
|
|
|
|
2018-01-22 13:54:47 +08:00
|
|
|
|
var stage2Bindings = new VariantMappingGenerator
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
|
|
|
|
LeftKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.Number7,
|
|
|
|
|
InputKey.Number8,
|
|
|
|
|
InputKey.Number9,
|
|
|
|
|
InputKey.Number0
|
|
|
|
|
},
|
|
|
|
|
RightKeys = new[]
|
|
|
|
|
{
|
|
|
|
|
InputKey.O,
|
|
|
|
|
InputKey.P,
|
|
|
|
|
InputKey.BracketLeft,
|
|
|
|
|
InputKey.BracketRight
|
|
|
|
|
},
|
|
|
|
|
SpecialKey = InputKey.BackSlash,
|
|
|
|
|
SpecialAction = ManiaAction.Special2,
|
2018-01-22 13:38:41 +08:00
|
|
|
|
NormalActionStart = nextNormal
|
2018-01-22 14:18:39 +08:00
|
|
|
|
}.GenerateKeyBindingsFor(keys, out _);
|
2018-01-15 16:43:45 +08:00
|
|
|
|
|
2018-01-22 13:54:47 +08:00
|
|
|
|
return stage1Bindings.Concat(stage2Bindings);
|
2018-01-15 16:43:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new KeyBinding[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetVariantName(int variant)
|
|
|
|
|
{
|
2018-01-22 14:18:11 +08:00
|
|
|
|
switch (getPlayfieldType(variant))
|
2017-08-23 11:49:50 +08:00
|
|
|
|
{
|
2018-01-15 16:43:45 +08:00
|
|
|
|
default:
|
|
|
|
|
return $"{variant}K";
|
2018-01-22 13:59:17 +08:00
|
|
|
|
case PlayfieldType.Dual:
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
2018-01-22 14:18:39 +08:00
|
|
|
|
var keys = getDualStageKeyCount(variant);
|
|
|
|
|
return $"{keys}K + {keys}K";
|
2018-01-15 16:43:45 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-01-22 13:59:17 +08:00
|
|
|
|
/// Finds the number of keys for each stage in a <see cref="PlayfieldType.Dual"/> variant.
|
2018-01-15 16:43:45 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="variant">The variant.</param>
|
2018-01-22 14:18:39 +08:00
|
|
|
|
private int getDualStageKeyCount(int variant) => (variant - (int)PlayfieldType.Dual) / 2;
|
2018-01-15 16:43:45 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
2018-01-22 13:59:17 +08:00
|
|
|
|
/// Finds the <see cref="PlayfieldType"/> that corresponds to a variant value.
|
2018-01-15 16:43:45 +08:00
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="variant">The variant value.</param>
|
2018-01-22 13:59:17 +08:00
|
|
|
|
/// <returns>The <see cref="PlayfieldType"/> that corresponds to <paramref name="variant"/>.</returns>
|
2018-01-22 14:18:11 +08:00
|
|
|
|
private PlayfieldType getPlayfieldType(int variant)
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
2018-01-22 13:59:17 +08:00
|
|
|
|
return (PlayfieldType)Enum.GetValues(typeof(PlayfieldType)).Cast<int>().OrderByDescending(i => i).First(v => variant >= v);
|
2018-01-15 16:43:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-01-22 14:03:05 +08:00
|
|
|
|
private class VariantMappingGenerator
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
2018-01-22 14:03:05 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// All the <see cref="InputKey"/>s available to the left hand.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public InputKey[] LeftKeys;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// All the <see cref="InputKey"/>s available to the right hand.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public InputKey[] RightKeys;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="InputKey"/> for the special key.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public InputKey SpecialKey;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="ManiaAction"/> at which the normal columns should begin.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ManiaAction NormalActionStart;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The <see cref="ManiaAction"/> for the special column.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ManiaAction SpecialAction;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Generates a list of <see cref="KeyBinding"/>s for a specific number of columns.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="columns">The number of columns that need to be bound.</param>
|
|
|
|
|
/// <param name="nextNormalAction">The next <see cref="ManiaAction"/> to use for normal columns.</param>
|
|
|
|
|
/// <returns>The keybindings.</returns>
|
|
|
|
|
public IEnumerable<KeyBinding> GenerateKeyBindingsFor(int columns, out ManiaAction nextNormalAction)
|
|
|
|
|
{
|
|
|
|
|
ManiaAction currentNormalAction = NormalActionStart;
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
2018-01-22 14:03:05 +08:00
|
|
|
|
var bindings = new List<KeyBinding>();
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
2018-01-22 14:03:05 +08:00
|
|
|
|
for (int i = LeftKeys.Length - columns / 2; i < LeftKeys.Length; i++)
|
|
|
|
|
bindings.Add(new KeyBinding(LeftKeys[i], currentNormalAction++));
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
2018-01-22 14:03:05 +08:00
|
|
|
|
for (int i = 0; i < columns / 2; i++)
|
|
|
|
|
bindings.Add(new KeyBinding(RightKeys[i], currentNormalAction++));
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
2018-01-22 14:03:05 +08:00
|
|
|
|
if (columns % 2 == 1)
|
|
|
|
|
bindings.Add(new KeyBinding(SpecialKey, SpecialAction));
|
2017-08-23 11:49:50 +08:00
|
|
|
|
|
2018-01-22 14:03:05 +08:00
|
|
|
|
nextNormalAction = currentNormalAction;
|
|
|
|
|
return bindings;
|
|
|
|
|
}
|
2017-08-23 11:49:50 +08:00
|
|
|
|
}
|
2018-01-15 16:43:45 +08:00
|
|
|
|
}
|
2017-08-23 13:19:14 +08:00
|
|
|
|
|
2018-01-22 13:59:17 +08:00
|
|
|
|
public enum PlayfieldType
|
2018-01-15 16:43:45 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
2018-01-22 15:11:26 +08:00
|
|
|
|
/// Columns are grouped into a single stage.
|
2018-01-22 13:57:25 +08:00
|
|
|
|
/// Number of columns in this stage lies at (item - Single).
|
2018-01-15 16:43:45 +08:00
|
|
|
|
/// </summary>
|
2018-01-22 13:57:25 +08:00
|
|
|
|
Single = 0,
|
2018-01-15 16:43:45 +08:00
|
|
|
|
/// <summary>
|
2018-01-22 15:11:26 +08:00
|
|
|
|
/// Columns are grouped into two stages.
|
2018-01-22 13:57:25 +08:00
|
|
|
|
/// Overall number of columns lies at (item - Dual), further computation is required for
|
|
|
|
|
/// number of columns in each individual stage.
|
2018-01-15 16:43:45 +08:00
|
|
|
|
/// </summary>
|
2018-01-22 13:57:25 +08:00
|
|
|
|
Dual = 1000,
|
2016-11-09 18:49:05 +08:00
|
|
|
|
}
|
|
|
|
|
}
|