Skip to content

Commit

Permalink
Fixed the touch feedback staying in place when the player touches the…
Browse files Browse the repository at this point in the history
… "auto play" toggle in practice mode.
  • Loading branch information
macmillan333 committed Jul 2, 2021
1 parent 82f4f93 commit 9996793
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
5 changes: 5 additions & 0 deletions TECHMANIA/Assets/Scripts/Components/Game Scene/Game.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1773,6 +1773,11 @@ private void OnFingerDown(int finger, Vector2 screenPosition)

private void OnFingerMove(int finger, Vector2 screenPosition)
{
if (!fingerInLane.ContainsKey(finger))
{
OnFingerDown(finger, screenPosition);
return;
}
List<RaycastResult> results = Raycast(screenPosition);
int lane = RaycastResultToLane(results);
if (fingerInLane[finger] != lane)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,14 @@ void Start()
// Update is called once per frame
void Update()
{
if (Game.autoPlay) return;
if (Game.autoPlay)
{
if (fingerToFeedback.Count > 0)
{
DestroyAllFeedback();
}
return;
}
switch (GameSetup.pattern.patternMetadata.controlScheme)
{
case ControlScheme.Touch:
Expand Down Expand Up @@ -92,17 +99,33 @@ private void SpawnFeedback(int fingerId, Vector2 position)

private void MoveFeedback(int fingerId, Vector2 position)
{
if (!fingerToFeedback.ContainsKey(fingerId))
{
SpawnFeedback(fingerId, position);
return;
}
fingerToFeedback[fingerId].GetComponent<RectTransform>()
.anchoredPosition =
TouchPositionToAnchoredPosition(position);
}

private void DestroyFeedback(int fingerId)
{
if (!fingerToFeedback.ContainsKey(fingerId)) return;
Destroy(fingerToFeedback[fingerId]);
fingerToFeedback.Remove(fingerId);
}

private void DestroyAllFeedback()
{
if (fingerToFeedback == null) return;
foreach (GameObject o in fingerToFeedback.Values)
{
Destroy(o);
}
fingerToFeedback.Clear();
}

private void OnDisable()
{
foreach (GameObject o in fingerToFeedback.Values)
Expand Down

0 comments on commit 9996793

Please sign in to comment.