Skip to content

Commit

Permalink
commit everything until now, includes:
Browse files Browse the repository at this point in the history
pippidon solution
pippidon.Game project
osu.Game.Rulesets.Pippidon project
everything needed for the ruleset and co.
converts...?
autoplay and replays
  • Loading branch information
jorolf committed Aug 20, 2017
1 parent ce78d07 commit 34c5a5e
Show file tree
Hide file tree
Showing 29 changed files with 1,375 additions and 1 deletion.
52 changes: 52 additions & 0 deletions osu.Game.Rulesets.Pippidon/Beatmaps/PippidonBeatmapConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Beatmaps;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Pippidon.Objects;
using osu.Game.Rulesets.Objects.Types;

namespace osu.Game.Rulesets.Pippidon.Beatmaps
{
public class PippidonBeatmapConverter : BeatmapConverter<PippidonObject>
{
protected override IEnumerable<Type> ValidConversionTypes => new[] { typeof(IHasXPosition) , typeof(IHasYPosition) };

private Dictionary<Beatmap, FloatRange> floatRanges = new Dictionary<Beatmap, FloatRange>();

protected override IEnumerable<PippidonObject> ConvertHitObject(HitObject original, Beatmap beatmap)
{
float pos = (original as IHasYPosition)?.Y ?? (original as IHasXPosition).X;

if (!floatRanges.ContainsKey(beatmap))
calcRange(beatmap);

yield return new PippidonObject
{
Samples = original.Samples,
StartTime = original.StartTime,
Lane = (int)((pos - floatRanges[beatmap].Min) / floatRanges[beatmap].Range * 3) - 1
};
}

private void calcRange(Beatmap beatmap)
{
List<float> positions = beatmap.HitObjects.OfType<IHasYPosition>().Select(hitObject => hitObject.Y).ToList();
if(!positions.Any())
positions = beatmap.HitObjects.OfType<IHasXPosition>().Select(hitObject => hitObject.X).ToList();

floatRanges[beatmap] = new FloatRange
{
Min = positions.Min(),
Max = positions.Max() + 1, //So we exclude ones later
};
}

private class FloatRange
{
public float Max, Min;
public float Range => Max - Min;
}
}
}
12 changes: 12 additions & 0 deletions osu.Game.Rulesets.Pippidon/Judgements/PippidonJudgement.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;

namespace osu.Game.Rulesets.Pippidon.Judgements
{
public class PippidonJudgement : Judgement
{
public override string ResultString => "";

public override string MaxResultString => "";
}
}
18 changes: 18 additions & 0 deletions osu.Game.Rulesets.Pippidon/Mods/PippidonMods.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Pippidon.Objects;
using osu.Game.Rulesets.Scoring;
using osu.Game.Users;
using osu.Game.Rulesets.Pippidon.Replays;

namespace osu.Game.Rulesets.Pippidon.Mods
{
public class PippidonModAutoplay : ModAutoplay<PippidonObject>
{
protected override Score CreateReplayScore(Beatmap<PippidonObject> beatmap) => new Score
{
User = new User { Username = "pippidon" },
Replay = new PippidonAutoGenerator(beatmap).Generate(),
};
}
}
54 changes: 54 additions & 0 deletions osu.Game.Rulesets.Pippidon/Objects/Drawables/Coin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Pippidon.Judgements;
using OpenTK;
using System;

namespace osu.Game.Rulesets.Pippidon.Objects.Drawables
{
public class Coin : DrawableScrollingHitObject<PippidonObject, PippidonJudgement>
{
private readonly Func<int, bool> touchingPippi;

public Coin(PippidonObject hitObject, TextureStore textures, Func<int, bool> touchingPippi) : base(hitObject)
{
Size = new Vector2(40);
Y = hitObject.Lane * 79;

this.touchingPippi = touchingPippi;

Add(new Sprite
{
RelativeSizeAxes = Axes.Both,
Texture = textures.Get("coin"),
});
}

protected override void Update()
{
base.Update();

if (HitObject.StartTime < Time.Current)
UpdateJudgement(true);
}

protected override void CheckJudgement(bool userTriggered)
{
if (HitObject.StartTime < Time.Current)
{
Judgement.Result = touchingPippi(HitObject.Lane) ? HitResult.Hit : HitResult.Miss;
Judgement.TimeOffset = Time.Current - HitObject.StartTime;
}
}

protected override PippidonJudgement CreateJudgement() => new PippidonJudgement();

protected override void UpdateState(ArmedState state)
{
if (state == ArmedState.Hit)
this.ScaleTo(5, 1500, Easing.OutQuint).FadeOut(1500, Easing.OutQuint).Expire();
}
}
}
12 changes: 12 additions & 0 deletions osu.Game.Rulesets.Pippidon/Objects/PippidonObject.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using osu.Game.Rulesets.Objects;

namespace osu.Game.Rulesets.Pippidon.Objects
{
public class PippidonObject : HitObject
{
/// <summary>
/// Range = [-1,1]
/// </summary>
public int Lane;
}
}
13 changes: 13 additions & 0 deletions osu.Game.Rulesets.Pippidon/PippidonDifficultyCalculator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using System.Collections.Generic;
using osu.Game.Beatmaps;

namespace osu.Game.Rulesets.Pippidon
{
public class PippidonDifficultyCalculator : DifficultyCalculator
{
protected override double CalculateInternal(Dictionary<string, string> categoryDifficulty)
{
return 0;
}
}
}
24 changes: 24 additions & 0 deletions osu.Game.Rulesets.Pippidon/PippidonInputManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
using System.ComponentModel;

namespace osu.Game.Rulesets.Pippidon
{
public class PippidonInputManager : DatabasedKeyBindingInputManager<PippidonAction>
{
public PippidonInputManager(RulesetInfo ruleset) : base(ruleset, 0, SimultaneousBindingMode.Unique)
{
}
}


public enum PippidonAction
{
[Description("Move up")]
MoveUp,
[Description("Move down")]
MoveDown,
[Description("Boost")]
Boost
}
}
71 changes: 71 additions & 0 deletions osu.Game.Rulesets.Pippidon/PippidonRuleset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Collections.Generic;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osu.Game.Rulesets.Pippidon.UI;
using OpenTK.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Rulesets.Pippidon.Scoring;
using osu.Framework.IO.Stores;
using osu.Framework.Graphics.Textures;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites;
using osu.Game.Rulesets.Pippidon.Mods;

namespace osu.Game.Rulesets.Pippidon
{
public class PippidonRuleset : Ruleset
{
public ResourceStore<byte[]> ResourceStore;
public TextureStore TextureStore;

public PippidonRuleset(RulesetInfo rulesetInfo) : base(rulesetInfo)
{
ResourceStore = new NamespacedResourceStore<byte[]>(new DllResourceStore("osu.Game.Rulesets.Pippidon.dll"), "Resources");
TextureStore = new TextureStore(new RawTextureLoaderStore(new NamespacedResourceStore<byte[]>(ResourceStore, @"Textures")));
}

public override string Description => "pippipidoooooon";

public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new PippidonDifficultyCalculator();

public override IEnumerable<KeyCounter> CreateGameplayKeys() => new[]
{
new KeyCounterKeyboard(Key.W),
new KeyCounterKeyboard(Key.S),
new KeyCounterKeyboard(Key.D),
};

public override RulesetContainer CreateRulesetContainerWith(WorkingBeatmap beatmap, bool isForCurrentRuleset) => new PippidonRulesetContainer(this, beatmap, isForCurrentRuleset);

public override ScoreProcessor CreateScoreProcessor() => new PippidonScoreProcessor();

public override Mod GetAutoplayMod() => new ModAutoplay();

public override IEnumerable<Mod> GetModsFor(ModType type)
{
switch (type)
{
case ModType.Special:
return new[] { new PippidonModAutoplay() };
default:
return new Mod[] { null };
}
}

public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0) => new[]
{
new KeyBinding(InputKey.W, PippidonAction.MoveUp),
new KeyBinding(InputKey.S, PippidonAction.MoveDown),
new KeyBinding(InputKey.D, PippidonAction.Boost),
};

public override Drawable CreateIcon() => new Sprite
{
Margin = new MarginPadding { Top = 3 },
Texture = TextureStore.Get("coin"),
};
}
}
35 changes: 35 additions & 0 deletions osu.Game.Rulesets.Pippidon/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("osu.Game.Rulesets.Pippidon")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("osu.Game.Rulesets.Pippidon")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("5ae1f0f1-dafa-46e7-959c-da233b7c87e9")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
65 changes: 65 additions & 0 deletions osu.Game.Rulesets.Pippidon/Replays/PippidonAutoGenerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Pippidon.Objects;
using osu.Game.Rulesets.Replays;
using osu.Game.Users;
using System.Collections.Generic;
using System;

namespace osu.Game.Rulesets.Pippidon.Replays
{
public class PippidonAutoGenerator : AutoGenerator<PippidonObject>
{
protected Replay Replay;
protected List<ReplayFrame> Frames => Replay.Frames;

public PippidonAutoGenerator(Beatmap<PippidonObject> beatmap) : base(beatmap)
{
Replay = new Replay
{
User = new User
{
Username = @"Autoplay",
}
};
}

public override Replay Generate()
{
Frames.Add(new ReplayFrame(-100000, null, null, ReplayButtonState.None));
Frames.Add(new ReplayFrame(Beatmap.HitObjects[0].StartTime - 1000, null, null, ReplayButtonState.None));

double lastTime = Beatmap.HitObjects[0].StartTime - 1000;
int lastLane = 0;
foreach(PippidonObject hitObject in Beatmap.HitObjects)
{
double time = (lastTime + hitObject.StartTime) / 2;
lastTime = hitObject.StartTime;

if (lastLane == hitObject.Lane)
continue;

ReplayButtonState button; //Left = Up, Right = Down
switch (lastLane)
{
case -1:
button = hitObject.Lane == 0 ? ReplayButtonState.Right1 : ReplayButtonState.Left1;
break;
case 0:
button = hitObject.Lane == 1 ? ReplayButtonState.Right1 : ReplayButtonState.Left1;
break;
case 1:
button = hitObject.Lane == -1 ? ReplayButtonState.Right1 : ReplayButtonState.Left1;
break;
default:
throw new Exception("Unknown lane");
}

Frames.Add(new ReplayFrame(time, null, null, button));
Frames.Add(new ReplayFrame(time + KEY_UP_DELAY, null, null, ReplayButtonState.None));
lastLane = hitObject.Lane;
}

return Replay;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using osu.Game.Rulesets.Replays;
using System.Collections.Generic;
using osu.Framework.Input;
using OpenTK.Input;

namespace osu.Game.Rulesets.Pippidon.Replays
{
public class PippidonFramedReplayInputHandler : FramedReplayInputHandler
{
public PippidonFramedReplayInputHandler(Replay replay) : base(replay)
{
}

public override List<InputState> GetPendingStates()
{
var keys = new List<Key>();

if (CurrentFrame?.MouseRight1 == true)
keys.Add(Key.S);
if (CurrentFrame?.MouseLeft1 == true)
keys.Add(Key.W);

return new List<InputState>
{
new InputState { Keyboard = new ReplayKeyboardState(keys) }
};
}
}
}
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 34c5a5e

Please sign in to comment.