2022-02-19 21:03:45 +00:00
|
|
|
using UnityEngine;
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Util;
|
2022-02-28 07:05:57 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games.Scripts_TapTrial
|
2022-02-19 21:03:45 +00:00
|
|
|
{
|
|
|
|
public class TapTrialPlayer : MonoBehaviour
|
|
|
|
{
|
|
|
|
[Header("References")]
|
|
|
|
[System.NonSerialized] public Animator anim;
|
|
|
|
|
2022-02-28 17:17:50 +00:00
|
|
|
public float nextBeat;
|
|
|
|
public int tripleOffset = 0;
|
|
|
|
|
2022-03-26 02:08:46 +00:00
|
|
|
private void Awake()
|
2022-02-19 21:03:45 +00:00
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
|
|
|
}
|
2022-02-28 07:05:57 +00:00
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-02-28 17:17:50 +00:00
|
|
|
float normalizedBeat = Conductor.instance.GetPositionFromMargin(nextBeat, 1f);
|
|
|
|
|
|
|
|
|
2022-02-28 07:05:57 +00:00
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
2022-02-28 17:17:50 +00:00
|
|
|
Tap(false, 0);
|
2022-02-28 07:05:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-28 17:17:50 +00:00
|
|
|
public void Tap(bool hit, int type)
|
2022-02-28 07:05:57 +00:00
|
|
|
{
|
2022-02-28 17:17:50 +00:00
|
|
|
if (hit)
|
|
|
|
Jukebox.PlayOneShotGame("tapTrial/tap");
|
|
|
|
else
|
|
|
|
Jukebox.PlayOneShotGame("tapTrial/tonk");
|
|
|
|
|
|
|
|
|
|
|
|
switch (type)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
anim.Play("Tap", 0, 0);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
anim.Play("DoubleTap", 0, 0);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if(tripleOffset % 2 == 0)
|
|
|
|
anim.Play("DoubleTap", 0, 0);
|
|
|
|
else
|
|
|
|
anim.Play("Tap", 0, 0);
|
|
|
|
tripleOffset++;
|
|
|
|
break;
|
|
|
|
}
|
2022-02-28 07:05:57 +00:00
|
|
|
}
|
2022-02-19 21:03:45 +00:00
|
|
|
}
|
|
|
|
}
|