2021-12-24 00:58:48 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using RhythmHeavenMania.Util;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games.ClappyTrio
|
|
|
|
{
|
2022-01-25 03:49:40 +00:00
|
|
|
public class ClappyTrioPlayer : PlayerActionObject
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
|
|
|
private float lastClapBeat;
|
2021-12-25 02:37:03 +00:00
|
|
|
private float lastClapLength;
|
2021-12-24 08:35:54 +00:00
|
|
|
[SerializeField] private bool clapVacant;
|
2021-12-24 00:58:48 +00:00
|
|
|
|
|
|
|
private int lastIndex;
|
|
|
|
|
|
|
|
private bool hit;
|
|
|
|
|
2021-12-24 03:36:16 +00:00
|
|
|
public bool clapStarted = false;
|
|
|
|
public bool canHit;
|
|
|
|
|
|
|
|
private GameObject clapEffect;
|
2022-01-25 03:49:40 +00:00
|
|
|
int aceTimes = 0;
|
2021-12-24 03:36:16 +00:00
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
clapEffect = transform.GetChild(4).GetChild(3).gameObject;
|
|
|
|
}
|
|
|
|
|
2022-01-25 03:49:40 +00:00
|
|
|
public override void OnAce()
|
|
|
|
{
|
2022-01-26 05:38:12 +00:00
|
|
|
if (aceTimes == 0)
|
|
|
|
{
|
|
|
|
Clap(true);
|
|
|
|
aceTimes++;
|
|
|
|
}
|
2022-01-25 03:49:40 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 00:58:48 +00:00
|
|
|
private void Update()
|
|
|
|
{
|
|
|
|
if (PlayerInput.Pressed())
|
|
|
|
{
|
2022-01-25 03:49:40 +00:00
|
|
|
Clap(false);
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-25 02:37:03 +00:00
|
|
|
if (clapVacant == true)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2021-12-25 02:37:03 +00:00
|
|
|
float normalizedBeat = (Conductor.instance.GetLoopPositionFromBeat(lastClapBeat, lastClapLength));
|
2021-12-24 00:58:48 +00:00
|
|
|
|
2022-01-25 03:49:40 +00:00
|
|
|
/*if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastIndex == 0)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
|
|
|
SetEligibility(true, false, false);
|
|
|
|
lastIndex++;
|
|
|
|
}
|
2021-12-25 02:37:03 +00:00
|
|
|
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastIndex == 1)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
|
|
|
SetEligibility(false, true, false);
|
|
|
|
// Clap();
|
|
|
|
lastIndex++;
|
|
|
|
}
|
2021-12-25 02:37:03 +00:00
|
|
|
else if (normalizedBeat > Minigame.LateTime() && lastIndex == 2)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
|
|
|
SetEligibility(false, false, true);
|
|
|
|
clapVacant = false;
|
|
|
|
lastIndex = 0;
|
2021-12-25 02:37:03 +00:00
|
|
|
lastClapLength = 0;
|
|
|
|
lastClapBeat = 0;
|
2021-12-24 00:58:48 +00:00
|
|
|
hit = false;
|
2022-01-25 03:49:40 +00:00
|
|
|
}*/
|
|
|
|
|
|
|
|
StateCheck(normalizedBeat);
|
|
|
|
|
|
|
|
if (normalizedBeat > Minigame.LateTime())
|
|
|
|
{
|
|
|
|
clapVacant = false;
|
|
|
|
lastIndex = 0;
|
|
|
|
lastClapLength = 0;
|
|
|
|
lastClapBeat = 0;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-26 05:11:54 +00:00
|
|
|
/*public void ClearLog()
|
2021-12-25 02:37:03 +00:00
|
|
|
{
|
|
|
|
var assembly = System.Reflection.Assembly.GetAssembly(typeof(UnityEditor.Editor));
|
|
|
|
var type = assembly.GetType("UnityEditor.LogEntries");
|
|
|
|
var method = type.GetMethod("Clear");
|
|
|
|
method.Invoke(new object(), null);
|
2021-12-26 05:11:54 +00:00
|
|
|
}*/
|
2021-12-25 02:37:03 +00:00
|
|
|
|
|
|
|
public void SetClapAvailability(float startBeat, float length)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2022-01-27 00:33:52 +00:00
|
|
|
aceTimes = 0;
|
2021-12-24 00:58:48 +00:00
|
|
|
lastClapBeat = startBeat;
|
|
|
|
clapVacant = true;
|
2021-12-25 02:37:03 +00:00
|
|
|
lastClapLength = length;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
|
2022-01-25 03:49:40 +00:00
|
|
|
private void Clap(bool overrideCanHit)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2022-01-25 03:49:40 +00:00
|
|
|
bool canHit = state.early != true && state.late != true && state.perfect == true && hit == false;
|
2021-12-24 00:58:48 +00:00
|
|
|
|
2022-01-25 03:49:40 +00:00
|
|
|
if (canHit || overrideCanHit)
|
2021-12-24 00:58:48 +00:00
|
|
|
{
|
2021-12-24 03:36:16 +00:00
|
|
|
clapEffect.SetActive(true);
|
2021-12-24 00:58:48 +00:00
|
|
|
Jukebox.PlayOneShotGame("clappyTrio/rightClap");
|
2021-12-24 03:36:16 +00:00
|
|
|
|
|
|
|
if (this.canHit)
|
|
|
|
ClappyTrio.instance.playerHitLast = true;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-12-24 03:36:16 +00:00
|
|
|
clapEffect.SetActive(false);
|
2021-12-24 00:58:48 +00:00
|
|
|
Jukebox.PlayOneShot("miss");
|
|
|
|
ClappyTrio.instance.playerHitLast = false;
|
2021-12-24 03:36:16 +00:00
|
|
|
|
|
|
|
if (clapStarted)
|
|
|
|
this.canHit = false;
|
2021-12-24 00:58:48 +00:00
|
|
|
}
|
|
|
|
|
2021-12-24 08:35:54 +00:00
|
|
|
ClappyTrio.instance.SetFace(ClappyTrio.instance.Lion.Count - 1, 4);
|
2021-12-24 00:58:48 +00:00
|
|
|
this.GetComponent<Animator>().Play("Clap", 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|