Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions osu.Game.Rulesets.Touhosu/Mods/TouhosuModRelax.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using osu.Framework.Graphics;
using osu.Framework.Input.Bindings;
using osu.Framework.Input;
using osu.Framework.Localisation;
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Touhosu.Objects;
using osu.Game.Rulesets.Touhosu.UI;
using osu.Game.Rulesets.UI;
using osu.Game.Screens.Play;
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Touhosu.UI.Objects;
using osuTK;

namespace osu.Game.Rulesets.Touhosu.Mods
{
public class TouhosuModRelax : ModRelax, IApplicableToDrawableRuleset<TouhosuHitObject>, IApplicableToPlayer
{
public override LocalisableString Description => "Use your mouse to dodge!";
private DrawableRuleset drawableRuleset;

public void ApplyToDrawableRuleset(DrawableRuleset<TouhosuHitObject> drawableRuleset)
{
this.drawableRuleset = drawableRuleset;
}

public void ApplyToPlayer(Player player)
{
if (!drawableRuleset.HasReplayLoaded.Value)
{
var touhosuPlayfield = (TouhosuPlayfield)drawableRuleset.Playfield;
touhosuPlayfield.TouhosuArea.Add(new MouseInputHelper(touhosuPlayfield.Player));
}
}
}

public partial class MouseInputHelper : Drawable, IKeyBindingHandler<TouhosuAction>, IRequireHighFrequencyMousePosition
{
private readonly TouhosuPlayer player;

public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;

public MouseInputHelper(TouhosuPlayer player)
{
this.player = player;
RelativeSizeAxes = Axes.Both;
}

// disable keyboard controls
public bool OnPressed(KeyBindingPressEvent<TouhosuAction> e) => true;

public void OnReleased(KeyBindingReleaseEvent<TouhosuAction> e)
{
}

protected override bool OnMouseMove(MouseMoveEvent e)
{
player.SetPosition(e.MousePosition);
return base.OnMouseMove(e);
}
}
}
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Touhosu/TouhosuRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
case ModType.Automation:
return new Mod[]
{
new TouhosuModAutoplay()
new TouhosuModAutoplay(),
new TouhosuModRelax()
};

case ModType.Fun:
Expand Down
7 changes: 7 additions & 0 deletions osu.Game.Rulesets.Touhosu/UI/Objects/TouhosuPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,13 @@ private void move(double elapsedTime, int horizontalDirection, int verticalDirec
}
}

public void SetPosition(Vector2 position)
{
var posX = Math.Clamp(position.X, animationContainer.Width / 2, TouhosuPlayfield.PLAYFIELD_SIZE.X - animationContainer.Width / 2);
var posY = Math.Clamp(position.Y, animationContainer.Height / 2, TouhosuPlayfield.PLAYFIELD_SIZE.Y - animationContainer.Height / 2);
Player.Position = new Vector2(posX, posY);
}

public List<Card> GetCards() => cardsController.GetCards();

private bool isFocused;
Expand Down
4 changes: 2 additions & 2 deletions osu.Game.Rulesets.Touhosu/UI/TouhosuPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public double SpeedMultiplier
private Sample grazeSample;

public TouhosuPlayer Player;

public Container TouhosuArea;
public TouhosuPlayfield()
{
InternalChildren = new Drawable[]
Expand All @@ -58,7 +58,7 @@ public TouhosuPlayfield()
AlwaysPresent = true
}
},
new Container
TouhosuArea = new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(1),
Expand Down