Skip to content

Commit

Permalink
Hurt the player if in the same lane as a missed hitobject
Browse files Browse the repository at this point in the history
  • Loading branch information
swoolcock committed Jun 2, 2020
1 parent 751932d commit b512eda
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 1 deletion.
2 changes: 1 addition & 1 deletion osu.Game.Rulesets.Rush/RushRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace osu.Game.Rulesets.Rush
{
public class RushRuleset : Ruleset
{
public override string Description => "rush";
public override string Description => "Rush!";

public override string PlayingVerb => "Punching doods";

Expand Down
42 changes: 42 additions & 0 deletions osu.Game.Rulesets.Rush/Scoring/RushHealthProcessor.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,53 @@
// Copyright (c) Shane Woolcock. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Allocation;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Rush.Objects;
using osu.Game.Rulesets.Rush.UI;
using osu.Game.Rulesets.Scoring;

namespace osu.Game.Rulesets.Rush.Scoring
{
public class RushHealthProcessor : HealthProcessor
{
private const float sawblade_points = -20f;
private const float minion_points = -10f;
private const float orb_points = -10f;
private const float miniboss_points = -10f;
private const float heart_points = 50f;

public double PlayerHealthPercentage { get; }

private double healthForPoints(double points) => points / PlayerHealthPercentage;

[Resolved]
private DrawableRushRuleset drawableRushRuleset { get; set; }

public RushHealthProcessor(double playerHealthPercentage = 100f)
{
PlayerHealthPercentage = playerHealthPercentage;
}

protected override double GetHealthIncreaseFor(JudgementResult result)
{
if (result.IsHit)
{
// TODO: handle hearts
return 0;
}

return result.HitObject switch
{
Sawblade _ => healthForPoints(sawblade_points),
Minion _ when collidesWith(result.HitObject) => healthForPoints(minion_points),
Orb _ when collidesWith(result.HitObject) => healthForPoints(orb_points),
MiniBoss _ => healthForPoints(miniboss_points),
_ => 0
};
}

private bool collidesWith(HitObject hitObject) => drawableRushRuleset.Playfield.PlayerSprite.CollidesWith(hitObject);
}
}
2 changes: 2 additions & 0 deletions osu.Game.Rulesets.Rush/UI/DrawableRushRuleset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public DrawableRushRuleset(RushRuleset ruleset, IBeatmap beatmap, IReadOnlyList<

protected override ReplayInputHandler CreateReplayInputHandler(Replay replay) => new RushFramedReplayInputHandler(replay);

public new RushPlayfield Playfield => (RushPlayfield)base.Playfield;

public override DrawableHitObject<RushHitObject> CreateDrawableRepresentation(RushHitObject h)
{
switch (h)
Expand Down
19 changes: 19 additions & 0 deletions osu.Game.Rulesets.Rush/UI/RushPlayerSprite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using osu.Framework.Graphics.Textures;
using osu.Framework.Utils;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Rush.Objects;
using osu.Game.Rulesets.Rush.Objects.Drawables;
using osuTK;
Expand Down Expand Up @@ -201,6 +202,24 @@ public void HandleResult(DrawableRushHitObject judgedObject, JudgementResult res
break;
}
}

public bool CollidesWith(HitObject hitObject)
{
const float hitbox_range = 50f;

switch (hitObject)
{
case MiniBoss _:
return true;

case LanedHit lanedHit:
// sawblades appear on the opposite side
var lane = lanedHit is Sawblade ? lanedHit.Lane.Opposite() : lanedHit.Lane;
return Math.Abs(Y - (lane == LanedHitLane.Air ? airY : groundY)) < hitbox_range;
}

return false;
}
}

[Flags]
Expand Down

0 comments on commit b512eda

Please sign in to comment.