Skip to content

Commit

Permalink
Gameplay: Fix rekka bug (?)
Browse files Browse the repository at this point in the history
  • Loading branch information
0thElement committed Aug 19, 2024
1 parent 70a7cdc commit 8a0e65f
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 13 deletions.
29 changes: 28 additions & 1 deletion Assets/Scripts/Gameplay/Data/Events/Arc.Judgement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ namespace ArcCreate.Gameplay.Data
/// <summary>
/// Partial class for judgement.
/// </summary>
public partial class Arc : LongNote, ILongNote, IArcJudgementReceiver
public partial class Arc : LongNote, ILongNote, IArcJudgementReceiver, IArcTapJudgementReceiver
{
private int numJudgementRequestsSent = 0;
private bool sentTapBlockingJudgement = false;
private bool highlightRequestSent = false;
private bool spawnedParticleThisFrame = false;

Expand All @@ -24,6 +25,7 @@ public void ResetJudgeTo(int timing)
highlightRequestSent = false;
arcGroupAlpha = 1;
hasBeenHitOnce = hasBeenHitOnce && timing >= Timing && timing <= EndTiming;
sentTapBlockingJudgement = timing >= Timing;
for (int i = 0; i < segments.Count; i++)
{
ArcSegmentData segment = segments[i];
Expand Down Expand Up @@ -81,6 +83,12 @@ public void UpdateJudgement(int currentTiming, GroupProperties groupProperties)
highlightRequestSent = true;
}

if (!IsTrace && currentTiming >= Timing - Values.MissJudgeWindow && !sentTapBlockingJudgement)
{
RequestTapBlockingJudgement(groupProperties);
sentTapBlockingJudgement = true;
}

spawnedParticleThisFrame = false;
}

Expand Down Expand Up @@ -132,6 +140,10 @@ public void ProcessArcJudgement(bool isExpired, bool isJudgement, GroupPropertie
}
}

public void ProcessArcTapJudgement(int offset, GroupProperties properties)
{
}

private void RequestJudgement(GroupProperties props)
{
for (int t = numJudgementRequestsSent; t < TotalCombo; t++)
Expand All @@ -152,6 +164,21 @@ private void RequestJudgement(GroupProperties props)
numJudgementRequestsSent = TotalCombo;
}

private void RequestTapBlockingJudgement(GroupProperties props)
{
Services.Judgement.Request(new ArcTapJudgementRequest()
{
ExpireAtTiming = Timing,
AutoAtTiming = Timing,
IsBlocker = true,
Width = 1,
X = WorldXAt(0),
Y = WorldYAt(0),
Receiver = this,
Properties = props,
});
}

private void RequestHighlight(int timing, GroupProperties props)
{
Services.Judgement.Request(new ArcJudgementRequest()
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/Gameplay/Data/Events/ArcTap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ private void RequestJudgement(GroupProperties props)
X = WorldX,
Y = WorldY,
Width = Width,
IsBlocker = false,
Receiver = this,
Properties = props,
});
Expand Down
39 changes: 27 additions & 12 deletions Assets/Scripts/Gameplay/Judgement/Input/TouchInputHandler.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using ArcCreate.Gameplay.Data;
using ArcCreate.Utility;
Expand Down Expand Up @@ -82,26 +83,40 @@ public void HandleTapRequests(
{
ArcTapJudgementRequest req = arcTapRequests[i];
int timingDifference = req.AutoAtTiming - currentTiming;
if (timingDifference > minTimingDifference)
{
continue;
}

Vector2 judgementSize = req.Properties.CurrentJudgementSize;
Vector3 judgementOffset = req.Properties.CurrentJudgementOffset;
Vector3 worldPosition = new Vector3(req.X, req.Y, 0) + judgementOffset;
Vector3 screenPosition = Services.Camera.GameplayCamera.WorldToScreenPoint(worldPosition);
Vector3 deltaToNote = screenPosition - input.ScreenPos;
float distanceToNote = deltaToNote.sqrMagnitude;

if (ArcTapCollide(input, screenPosition, worldPosition, req.Width, judgementSize)
&& (timingDifference < minTimingDifference || distanceToNote <= minPositionDifference))
if (ArcTapCollide(input, screenPosition, worldPosition, req.Width, judgementSize))
{
minTimingDifference = timingDifference;
minPositionDifference = distanceToNote;
applicableArcTapRequestExists = true;
applicableArcTapRequest = req;
applicableArcTapRequestIndex = i;
if (timingDifference < minTimingDifference || distanceToNote <= minPositionDifference)
{
if (req.IsBlocker &&
(minTimingDifference - timingDifference <= Values.MaxJudgeWindow
|| currentTiming >= req.AutoAtTiming))
{
continue;
}

minTimingDifference = timingDifference;
minPositionDifference = distanceToNote;
applicableArcTapRequestExists = true;
applicableArcTapRequest = req;
applicableArcTapRequestIndex = i;
}
else if (timingDifference <= minTimingDifference + Values.MaxJudgeWindow
&& applicableArcTapRequestExists && applicableArcTapRequest.IsBlocker
&& !req.IsBlocker)
{
minTimingDifference = timingDifference;
minPositionDifference = distanceToNote;
applicableArcTapRequestExists = true;
applicableArcTapRequest = req;
applicableArcTapRequestIndex = i;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public struct ArcTapJudgementRequest
public float X;
public float Y;
public float Width;
public bool IsBlocker;
public IArcTapJudgementReceiver Receiver;
public GroupProperties Properties;
}
Expand Down

0 comments on commit 8a0e65f

Please sign in to comment.