diff --git a/osu.Game.Rulesets.Rush/RushRuleset.cs b/osu.Game.Rulesets.Rush/RushRuleset.cs index 369946b..94e524d 100644 --- a/osu.Game.Rulesets.Rush/RushRuleset.cs +++ b/osu.Game.Rulesets.Rush/RushRuleset.cs @@ -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"; diff --git a/osu.Game.Rulesets.Rush/Scoring/RushHealthProcessor.cs b/osu.Game.Rulesets.Rush/Scoring/RushHealthProcessor.cs index 4c6006a..9245bd6 100644 --- a/osu.Game.Rulesets.Rush/Scoring/RushHealthProcessor.cs +++ b/osu.Game.Rulesets.Rush/Scoring/RushHealthProcessor.cs @@ -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); } } diff --git a/osu.Game.Rulesets.Rush/UI/DrawableRushRuleset.cs b/osu.Game.Rulesets.Rush/UI/DrawableRushRuleset.cs index e40a0e1..518dd7f 100644 --- a/osu.Game.Rulesets.Rush/UI/DrawableRushRuleset.cs +++ b/osu.Game.Rulesets.Rush/UI/DrawableRushRuleset.cs @@ -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 CreateDrawableRepresentation(RushHitObject h) { switch (h) diff --git a/osu.Game.Rulesets.Rush/UI/RushPlayerSprite.cs b/osu.Game.Rulesets.Rush/UI/RushPlayerSprite.cs index 3310eca..f4e09f5 100644 --- a/osu.Game.Rulesets.Rush/UI/RushPlayerSprite.cs +++ b/osu.Game.Rulesets.Rush/UI/RushPlayerSprite.cs @@ -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; @@ -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]