2022-02-19 21:03:45 +00:00
|
|
|
using UnityEngine;
|
2023-07-13 00:35:47 +00:00
|
|
|
using System;
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Util;
|
2023-07-13 00:35:47 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
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
|
|
|
|
{
|
2023-07-13 00:35:47 +00:00
|
|
|
private enum TapState
|
|
|
|
{
|
|
|
|
Tap,
|
|
|
|
DoubleTap,
|
|
|
|
TripleTap,
|
|
|
|
Jumping
|
|
|
|
}
|
|
|
|
private TapState state = TapState.Tap;
|
|
|
|
private int tripleTaps = 0;
|
|
|
|
private Animator anim;
|
|
|
|
[SerializeField] private ParticleSystem tapEffectLeft;
|
|
|
|
[SerializeField] private ParticleSystem tapEffectRight;
|
2022-02-19 21:03:45 +00:00
|
|
|
|
2023-07-13 00:35:47 +00:00
|
|
|
private TapTrial game;
|
2022-02-28 17:17:50 +00:00
|
|
|
|
2022-03-26 02:08:46 +00:00
|
|
|
private void Awake()
|
2022-02-19 21:03:45 +00:00
|
|
|
{
|
|
|
|
anim = GetComponent<Animator>();
|
2023-07-13 00:35:47 +00:00
|
|
|
game = TapTrial.instance;
|
2022-02-19 21:03:45 +00:00
|
|
|
}
|
2022-02-28 07:05:57 +00:00
|
|
|
|
|
|
|
private void Update()
|
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
if (PlayerInput.GetIsAction(TapTrial.InputAction_BasicPress) && !game.IsExpectingInputNow(TapTrial.InputAction_BasicPress))
|
2022-02-28 07:05:57 +00:00
|
|
|
{
|
2023-07-13 00:35:47 +00:00
|
|
|
WhiffTap();
|
2022-02-28 07:05:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-13 00:35:47 +00:00
|
|
|
public void Bop()
|
2022-02-28 07:05:57 +00:00
|
|
|
{
|
2023-07-13 00:35:47 +00:00
|
|
|
anim.DoScaledAnimationAsync("Bop", 0.5f);
|
|
|
|
}
|
2022-02-28 17:17:50 +00:00
|
|
|
|
2023-07-13 00:35:47 +00:00
|
|
|
private void WhiffTap()
|
|
|
|
{
|
|
|
|
switch (state)
|
2022-02-28 17:17:50 +00:00
|
|
|
{
|
2023-07-13 00:35:47 +00:00
|
|
|
case TapState.Tap:
|
|
|
|
game.ScoreMiss();
|
|
|
|
game.ResetScroll();
|
|
|
|
Tap(false, false);
|
2022-02-28 17:17:50 +00:00
|
|
|
break;
|
2023-07-13 00:35:47 +00:00
|
|
|
case TapState.DoubleTap:
|
|
|
|
game.ScoreMiss();
|
|
|
|
game.ResetScroll();
|
|
|
|
Tap(false, true);
|
2022-02-28 17:17:50 +00:00
|
|
|
break;
|
2023-07-13 00:35:47 +00:00
|
|
|
case TapState.TripleTap:
|
|
|
|
game.ScoreMiss();
|
|
|
|
game.ResetScroll();
|
2022-02-28 17:17:50 +00:00
|
|
|
break;
|
2023-07-13 00:35:47 +00:00
|
|
|
case TapState.Jumping:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PrepareJump()
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync("JumpPrepare", 0.5f);
|
|
|
|
state = TapState.Jumping;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Jump(bool final)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync(final ? "FinalJump" : "JumpTap", 0.5f);
|
|
|
|
state = TapState.Jumping;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void JumpTap(bool ace, bool final)
|
|
|
|
{
|
|
|
|
if (ace)
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShotGame("tapTrial/tap");
|
|
|
|
SpawnTapEffect(true);
|
|
|
|
SpawnTapEffect(false);
|
2022-02-28 17:17:50 +00:00
|
|
|
}
|
2023-07-13 00:35:47 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("nearMiss");
|
|
|
|
game.ResetScroll();
|
|
|
|
}
|
|
|
|
anim.DoScaledAnimationAsync(final ? "FinalJump_Tap" : "JumpTap_Success", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void JumpTapMiss(bool final)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync(final ? "FinalJump_Miss" : "JumpTap_Miss", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PrepareTap(bool doubleTap = false)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync(doubleTap ? "DoubleTapPrepare" : "TapPrepare", 0.5f);
|
|
|
|
state = doubleTap ? TapState.DoubleTap : TapState.Tap;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Tap(bool ace, bool doubleTap = false)
|
|
|
|
{
|
|
|
|
if (ace)
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShotGame("tapTrial/tap");
|
|
|
|
SpawnTapEffect(!doubleTap);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("nearMiss");
|
|
|
|
game.ResetScroll();
|
|
|
|
}
|
|
|
|
anim.DoScaledAnimationAsync(doubleTap ? "DoubleTap" : "Tap", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void PrepareTripleTap(double beat)
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync("PosePrepare_1", 0.5f);
|
|
|
|
state = TapState.TripleTap;
|
|
|
|
tripleTaps = 0;
|
2023-09-11 22:28:04 +00:00
|
|
|
BeatAction.New(this, new List<BeatAction.Action>()
|
2023-07-13 00:35:47 +00:00
|
|
|
{
|
|
|
|
new BeatAction.Action(beat + 0.5, delegate
|
|
|
|
{
|
|
|
|
anim.DoScaledAnimationAsync("PosePrepare_2", 0.5f);
|
|
|
|
})
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public void TripleTap(bool ace)
|
|
|
|
{
|
|
|
|
bool tapLeft = tripleTaps % 2 == 0;
|
|
|
|
tripleTaps++;
|
|
|
|
|
|
|
|
if (ace)
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShotGame("tapTrial/tap");
|
|
|
|
SpawnTapEffect(tapLeft);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SoundByte.PlayOneShot("nearMiss");
|
|
|
|
game.ResetScroll();
|
|
|
|
}
|
|
|
|
|
|
|
|
anim.DoScaledAnimationAsync(tapLeft ? "PoseTap_L" : "PoseTap_R", 0.5f);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SpawnTapEffect(bool left)
|
|
|
|
{
|
|
|
|
ParticleSystem spawnedTap = Instantiate(left ? tapEffectLeft : tapEffectRight, game.transform);
|
|
|
|
spawnedTap.Play();
|
2022-02-28 07:05:57 +00:00
|
|
|
}
|
2022-02-19 21:03:45 +00:00
|
|
|
}
|
|
|
|
}
|