2021-12-24 00:58:48 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
using HeavenStudio.Util;
|
2021-12-24 00:58:48 +00:00
|
|
|
|
2022-03-14 14:21:05 +00:00
|
|
|
namespace HeavenStudio.Games.Scripts_ClappyTrio
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
public class ClappyTrioPlayer : MonoBehaviour
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
ClappyTrio game;
|
2023-06-10 19:13:29 +00:00
|
|
|
private double lastClapBeat;
|
2021-12-25 02:37:03 +00:00
|
|
|
private float lastClapLength;
|
2021-12-24 00:58:48 +00:00
|
|
|
|
2021-12-24 03:36:16 +00:00
|
|
|
public bool clapStarted = false;
|
|
|
|
public bool canHit;
|
|
|
|
|
|
|
|
private GameObject clapEffect;
|
|
|
|
|
2022-03-26 02:08:46 +00:00
|
|
|
private void Awake()
|
2021-12-24 03:36:16 +00:00
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
game = ClappyTrio.instance;
|
2021-12-24 03:36:16 +00:00
|
|
|
clapEffect = transform.GetChild(4).GetChild(3).gameObject;
|
|
|
|
}
|
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
private void Update()
|
2022-01-25 03:49:40 +00:00
|
|
|
{
|
2023-10-29 19:44:47 +00:00
|
|
|
if (PlayerInput.GetIsAction(ClappyTrio.InputAction_BasicPress) && !game.IsExpectingInputNow(ClappyTrio.InputAction_BasicPress.inputLockCategory))
|
2022-01-26 05:38:12 +00:00
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
Clap(false);
|
2023-01-25 03:54:19 +00:00
|
|
|
game.ScoreMiss();
|
2022-01-26 05:38:12 +00:00
|
|
|
}
|
2022-01-25 03:49:40 +00:00
|
|
|
}
|
|
|
|
|
2023-06-10 19:13:29 +00:00
|
|
|
public void QueueClap(double startBeat, float length)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2023-01-15 04:33:37 +00:00
|
|
|
lastClapBeat = startBeat;
|
|
|
|
lastClapLength = length;
|
2021-12-24 00:58:48 +00:00
|
|
|
|
2023-10-29 19:44:47 +00:00
|
|
|
game.ScheduleInput(startBeat, length, ClappyTrio.InputAction_BasicPress, Just, Miss, Out);
|
2023-01-15 04:33:37 +00:00
|
|
|
}
|
2022-01-25 03:49:40 +00:00
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
private void Just(PlayerActionEvent caller, float state)
|
|
|
|
{
|
|
|
|
if (!canHit) {
|
|
|
|
Clap(false);
|
|
|
|
return;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
2023-01-15 04:33:37 +00:00
|
|
|
if (state >= 1f || state <= -1f) { //todo: proper near miss feedback
|
|
|
|
Clap(false);
|
|
|
|
return;
|
2022-02-05 20:28:04 +00:00
|
|
|
}
|
2023-01-15 04:33:37 +00:00
|
|
|
Clap(true);
|
2022-02-05 20:28:04 +00:00
|
|
|
}
|
2021-12-25 02:37:03 +00:00
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
private void Miss(PlayerActionEvent caller) {
|
2023-05-28 18:48:41 +00:00
|
|
|
game.misses++;
|
2023-04-26 12:43:35 +00:00
|
|
|
game.emoCounter = 2;
|
2022-02-05 20:58:02 +00:00
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
if (clapStarted)
|
|
|
|
this.canHit = false;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
private void Out(PlayerActionEvent caller) {}
|
|
|
|
|
|
|
|
private void Clap(bool just)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2023-04-26 12:43:35 +00:00
|
|
|
game.emoCounter = 2;
|
2023-01-15 04:33:37 +00:00
|
|
|
if (just)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2021-12-24 03:36:16 +00:00
|
|
|
clapEffect.SetActive(true);
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShotGame("clappyTrio/rightClap");
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 03:36:16 +00:00
|
|
|
clapEffect.SetActive(false);
|
2023-06-10 19:13:29 +00:00
|
|
|
SoundByte.PlayOneShot("miss");
|
2023-05-28 18:48:41 +00:00
|
|
|
game.misses++;
|
2021-12-24 03:36:16 +00:00
|
|
|
|
|
|
|
if (clapStarted)
|
|
|
|
this.canHit = false;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
|
2023-01-15 04:33:37 +00:00
|
|
|
clapStarted = false;
|
|
|
|
game.SetFace(game.Lion.Count - 1, 4);
|
2021-12-24 00:58:48 +00:00
|
|
|
this.GetComponent<Animator>().Play("Clap", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|