Skip to content

Commit

Permalink
Merge pull request #516 from smoogipooo/taiko_bash_drawable
Browse files Browse the repository at this point in the history
Drawable Bash Implementation (Input only)
  • Loading branch information
peppy authored Mar 27, 2017
2 parents 806d8bf + e81040c commit d6d19d7
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 14 deletions.
2 changes: 1 addition & 1 deletion osu.Game.Modes.Taiko/Beatmaps/TaikoBeatmapConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ private TaikoHitObject convertHitObject(HitObject original)
if (endTimeData != null)
{
// We compute the end time manually to add in the Bash convert factor
return new Bash
return new Swell
{
StartTime = original.StartTime,
Sample = original.Sample,
Expand Down
75 changes: 75 additions & 0 deletions osu.Game.Modes.Taiko/Objects/Drawable/DrawableSwell.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE

using OpenTK.Input;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using System;

namespace osu.Game.Modes.Taiko.Objects.Drawable
{
public class DrawableSwell : DrawableTaikoHitObject
{
/// <summary>
/// The amount of times the user has hit this swell.
/// </summary>
private int userHits;

private readonly Swell swell;

public DrawableSwell(Swell swell)
: base(swell)
{
this.swell = swell;
}

protected override void CheckJudgement(bool userTriggered)
{
if (userTriggered)
{
if (Time.Current < HitObject.StartTime)
return;

userHits++;

if (userHits == swell.RequiredHits)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = TaikoHitResult.Great;
}
}
else
{
if (Judgement.TimeOffset < 0)
return;

if (userHits > swell.RequiredHits / 2)
{
Judgement.Result = HitResult.Hit;
Judgement.TaikoResult = TaikoHitResult.Good;
}
else
Judgement.Result = HitResult.Miss;
}
}

protected override void UpdateState(ArmedState state)
{
}

protected override void UpdateScrollPosition(double time)
{
base.UpdateScrollPosition(Math.Min(time, HitObject.StartTime));
}

protected override bool HandleKeyPress(Key key)
{
if (Judgement.Result.HasValue)
return false;

UpdateJudgement(true);

return true;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using osu.Framework.Graphics;
using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Taiko.Judgements;
using osu.Game.Modes.Taiko.Objects.Drawable.Pieces;
using System.Collections.Generic;
using osu.Framework.Input;

Expand All @@ -26,11 +25,6 @@ protected DrawableTaikoHitObject(TaikoHitObject hitObject)
Origin = Anchor.Centre;

RelativePositionAxes = Axes.X;

Children = new[]
{
CreateCircle()
};
}

protected override void LoadComplete()
Expand Down Expand Up @@ -73,7 +67,5 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
// Handle it!
return HandleKeyPress(args.Key);
}

protected abstract CirclePiece CreateCircle();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

namespace osu.Game.Modes.Taiko.Objects
{
public class Bash : TaikoHitObject, IHasEndTime
public class Swell : TaikoHitObject, IHasEndTime
{
public double EndTime { get; set; }

public double Duration => EndTime - StartTime;

/// <summary>
/// The number of hits required to complete the bash successfully.
/// The number of hits required to complete the swell successfully.
/// </summary>
public int RequiredHits { get; protected set; }

Expand Down
2 changes: 1 addition & 1 deletion osu.Game.Modes.Taiko/Scoring/TaikoScoreProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ protected override void ComputeTargets(Beatmap<TaikoHitObject> beatmap)
SecondHit = obj.Accented
});
}
else if (obj is Bash)
else if (obj is Swell)
{
AddJudgement(new TaikoJudgement
{
Expand Down
5 changes: 3 additions & 2 deletions osu.Game.Modes.Taiko/osu.Game.Modes.Taiko.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,13 @@
<Compile Include="Judgements\TaikoHitResult.cs" />
<Compile Include="Objects\Drawable\DrawableHit.cs" />
<Compile Include="Objects\Drawable\DrawableAccentedHit.cs" />
<Compile Include="Objects\Drawable\DrawableTaikoHitObject.cs" />
<Compile Include="Objects\Bash.cs" />
<Compile Include="Objects\Drawable\Pieces\AccentedCirclePiece.cs" />
<Compile Include="Objects\Drawable\DrawableSwell.cs" />
<Compile Include="Objects\Drawable\DrawableTaikoHitObject.cs" />
<Compile Include="Objects\DrumRoll.cs" />
<Compile Include="Objects\DrumRollTick.cs" />
<Compile Include="Objects\Hit.cs" />
<Compile Include="Objects\Swell.cs" />
<Compile Include="Objects\Drawable\Pieces\CirclePiece.cs" />
<Compile Include="TaikoDifficultyCalculator.cs" />
<Compile Include="Objects\TaikoHitObject.cs" />
Expand Down

0 comments on commit d6d19d7

Please sign in to comment.