1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 19:17:25 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Mods/OsuMod.cs

212 lines
8.5 KiB
C#
Raw Normal View History

2017-03-02 08:57:33 +08:00
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
2017-03-13 20:05:09 +08:00
using osu.Game.Beatmaps;
using osu.Game.Graphics;
2017-04-29 00:21:33 +08:00
using osu.Game.Rulesets.Osu.Replays;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Osu.Objects;
using System;
2017-08-23 14:35:31 +08:00
using System.Collections.Generic;
using System.Linq;
2017-08-23 15:54:06 +08:00
using osu.Game.Rulesets.Osu.UI;
2017-04-18 15:05:58 +08:00
using osu.Game.Rulesets.Scoring;
2017-08-23 14:35:31 +08:00
using OpenTK;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Types;
2017-03-02 08:57:33 +08:00
2017-04-18 15:05:58 +08:00
namespace osu.Game.Rulesets.Osu.Mods
2017-03-02 08:57:33 +08:00
{
public class OsuModNoFail : ModNoFail
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
2017-03-02 08:57:33 +08:00
}
public class OsuModEasy : ModEasy
{
}
public class OsuModHidden : ModHidden, IApplicableToDrawableHitObjects
2017-03-02 08:57:33 +08:00
{
public override string Description => @"Play with no approach circles and fading notes for a slight score advantage.";
public override double ScoreMultiplier => 1.06;
private const double fade_in_speed_multiplier = 0.6;
private const double fade_out_speed_multiplier = 0.3;
private float preEmpt => DrawableOsuHitObject.TIME_PREEMPT;
public void ApplyToDrawableHitObjects(IEnumerable<DrawableHitObject> drawables)
{
foreach (var d in drawables.OfType<DrawableOsuHitObject>())
2017-12-29 15:22:06 +08:00
d.ApplyCustomUpdateState += ApplyHiddenState;
}
2017-12-29 15:22:06 +08:00
protected void ApplyHiddenState(DrawableHitObject drawable, ArmedState state)
{
if (!(drawable is DrawableOsuHitObject d))
return;
var fadeInTime = d.HitObject.StartTime - preEmpt;
var fadeIn = d.HitObject.StartTime - preEmpt * fade_in_speed_multiplier - fadeInTime;
var fadeOutTime = fadeInTime + fadeIn;
var fadeOut = d.HitObject.StartTime - preEmpt * fade_out_speed_multiplier - fadeOutTime;
// new duration from completed fade in to end (before fading out)
var newDuration = ((d.HitObject as IHasEndTime)?.EndTime ?? d.HitObject.StartTime) - fadeOutTime;
d.FadeIn = fadeIn;
using (drawable.BeginAbsoluteSequence(fadeInTime, true))
{
switch (drawable)
{
case DrawableHitCircle circle:
circle.ApproachCircle.FadeOut();
// prolong the hitcircle long enough so misses are still possible
circle.LifetimeEnd = circle.HitObject.StartTime + Math.Max(fadeOut, circle.HitObject.HitWindowFor(HitResult.Miss));
circle.FadeIn(fadeIn).Then().FadeOut(fadeOut); // override fade in as it somehow gets cut otherwise
break;
case DrawableSlider slider:
using (slider.BeginAbsoluteSequence(fadeOutTime, true))
{
slider.Body.FadeOut(newDuration, Easing.Out);
// delay a bit less to let the sliderball fade out peacefully instead of having a hard cut
using (slider.BeginDelayedSequence(newDuration - fadeOut, true))
{
slider.Ball.FadeOut(fadeOut);
slider.Delay(fadeOut).Expire();
}
}
break;
case DrawableSpinner spinner:
spinner.Disc.FadeOut();
spinner.Ticks.FadeOut();
spinner.Background.FadeOut();
using (spinner.BeginAbsoluteSequence(fadeOutTime, true))
{
var sequence = spinner.Delay(newDuration).FadeOut(fadeOut);
// speed up the end sequence accordingly
switch (state)
{
case ArmedState.Hit:
sequence.ScaleTo(spinner.Scale * 1.2f, fadeOut * 2, Easing.Out);
break;
case ArmedState.Miss:
sequence.ScaleTo(spinner.Scale * 0.8f, fadeOut * 2, Easing.Out);
break;
}
sequence.Expire();
}
break;
}
}
}
2017-03-02 08:57:33 +08:00
}
public class OsuModHardRock : ModHardRock, IApplicableToHitObject<OsuHitObject>
2017-03-02 08:57:33 +08:00
{
public override double ScoreMultiplier => 1.06;
public override bool Ranked => true;
2017-08-23 14:35:31 +08:00
public void ApplyToHitObject(OsuHitObject hitObject)
2017-08-23 14:35:31 +08:00
{
hitObject.Position = new Vector2(hitObject.Position.X, OsuPlayfield.BASE_SIZE.Y - hitObject.Y);
var slider = hitObject as Slider;
if (slider == null)
return;
var newControlPoints = new List<Vector2>();
slider.ControlPoints.ForEach(c => newControlPoints.Add(new Vector2(c.X, OsuPlayfield.BASE_SIZE.Y - c.Y)));
slider.ControlPoints = newControlPoints;
slider.Curve?.Calculate(); // Recalculate the slider curve
}
2017-03-02 08:57:33 +08:00
}
public class OsuModSuddenDeath : ModSuddenDeath
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
2017-03-02 08:57:33 +08:00
}
2017-05-31 00:49:06 +08:00
public class OsuModDaycore : ModDaycore
{
public override double ScoreMultiplier => 0.5;
}
2017-03-02 08:57:33 +08:00
public class OsuModDoubleTime : ModDoubleTime
{
public override double ScoreMultiplier => 1.12;
}
public class OsuModRelax : ModRelax
{
public override string Description => "You don't need to click.\nGive your clicking/tapping finger a break from the heat of things.";
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot) }).ToArray();
2017-03-02 08:57:33 +08:00
}
public class OsuModHalfTime : ModHalfTime
{
public override double ScoreMultiplier => 0.5;
}
public class OsuModNightcore : ModNightcore
{
public override double ScoreMultiplier => 1.12;
}
public class OsuModFlashlight : ModFlashlight
{
public override double ScoreMultiplier => 1.12;
}
public class OsuModPerfect : ModPerfect
{
}
2017-03-02 08:57:33 +08:00
public class OsuModSpunOut : Mod
{
public override string Name => "Spun Out";
public override string ShortenedName => "SO";
2017-03-02 08:57:33 +08:00
public override FontAwesome Icon => FontAwesome.fa_osu_mod_spunout;
public override string Description => @"Spinners will be automatically completed";
public override double ScoreMultiplier => 0.9;
public override bool Ranked => true;
public override Type[] IncompatibleMods => new[] { typeof(ModAutoplay), typeof(OsuModAutopilot) };
2017-03-02 08:57:33 +08:00
}
public class OsuModAutopilot : Mod
{
public override string Name => "Autopilot";
public override string ShortenedName => "AP";
2017-03-02 08:57:33 +08:00
public override FontAwesome Icon => FontAwesome.fa_osu_mod_autopilot;
public override string Description => @"Automatic cursor movement - just follow the rhythm.";
public override double ScoreMultiplier => 0;
public override bool Ranked => false;
public override Type[] IncompatibleMods => new[] { typeof(OsuModSpunOut), typeof(ModRelax), typeof(ModSuddenDeath), typeof(ModNoFail), typeof(ModAutoplay) };
}
2017-03-13 20:05:09 +08:00
public class OsuModAutoplay : ModAutoplay<OsuHitObject>
{
public override Type[] IncompatibleMods => base.IncompatibleMods.Concat(new[] { typeof(OsuModAutopilot), typeof(OsuModSpunOut) }).ToArray();
2017-03-13 20:05:09 +08:00
protected override Score CreateReplayScore(Beatmap<OsuHitObject> beatmap) => new Score
{
Replay = new OsuAutoGenerator(beatmap).Generate()
2017-03-13 20:05:09 +08:00
};
2017-03-02 08:57:33 +08:00
}
public class OsuModTarget : Mod
{
public override string Name => "Target";
public override string ShortenedName => "TP";
2017-03-02 08:57:33 +08:00
public override FontAwesome Icon => FontAwesome.fa_osu_mod_target;
public override string Description => @"";
public override double ScoreMultiplier => 1;
}
}