mirror of
https://github.com/RHeavenStudioPlus/HeavenStudioPlus.git
synced 2024-11-14 13:45:10 +00:00
ebeea121ed
I just moved everything that was in start to awake. There are a few other changes I made, like using init functions rather than awake in scripts that depended on something that was initialized in another script's awake (to make sure things always happen in the right order), as well as some other stuff in some specific minigames
57 lines
No EOL
1.3 KiB
C#
57 lines
No EOL
1.3 KiB
C#
using UnityEngine;
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
namespace HeavenStudio.Games.Scripts_TapTrial
|
|
{
|
|
public class TapTrialPlayer : MonoBehaviour
|
|
{
|
|
[Header("References")]
|
|
[System.NonSerialized] public Animator anim;
|
|
|
|
public float nextBeat;
|
|
public int tripleOffset = 0;
|
|
|
|
private void Awake()
|
|
{
|
|
anim = GetComponent<Animator>();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
float normalizedBeat = Conductor.instance.GetPositionFromMargin(nextBeat, 1f);
|
|
|
|
|
|
if (PlayerInput.Pressed())
|
|
{
|
|
Tap(false, 0);
|
|
}
|
|
}
|
|
|
|
public void Tap(bool hit, int type)
|
|
{
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
} |