2021-12-29 06:52:48 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace RhythmHeavenMania.Games
|
|
|
|
{
|
|
|
|
public class PlayerActionObject : MonoBehaviour
|
|
|
|
{
|
|
|
|
public bool inList = false;
|
|
|
|
public int lastState;
|
2022-01-02 12:09:15 +00:00
|
|
|
public Minigame.Eligible state = new Minigame.Eligible();
|
2021-12-30 08:26:18 +00:00
|
|
|
public bool isEligible;
|
2021-12-29 06:52:48 +00:00
|
|
|
|
|
|
|
public void PlayerActionInit(GameObject g)
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
state.gameObject = g;
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// could possibly add support for custom early, perfect, and end times if needed.
|
|
|
|
public void StateCheck(float normalizedBeat, List<Minigame.Eligible> eligibleHitsList)
|
|
|
|
{
|
2021-12-30 08:26:18 +00:00
|
|
|
if (!isEligible) return;
|
2021-12-29 06:52:48 +00:00
|
|
|
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
|
|
|
|
{
|
|
|
|
MakeEligible(true, false, false, eligibleHitsList);
|
|
|
|
lastState++;
|
|
|
|
}
|
|
|
|
// Perfect State
|
|
|
|
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
|
|
|
|
{
|
|
|
|
MakeEligible(false, true, false, eligibleHitsList);
|
|
|
|
lastState++;
|
|
|
|
}
|
|
|
|
// Late State
|
|
|
|
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
|
|
|
|
{
|
|
|
|
MakeEligible(false, false, true, eligibleHitsList);
|
|
|
|
lastState++;
|
|
|
|
}
|
|
|
|
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
|
|
|
{
|
|
|
|
MakeInEligible(eligibleHitsList);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void MakeEligible(bool early, bool perfect, bool late, List<Minigame.Eligible> eligibleHitsList)
|
|
|
|
{
|
|
|
|
if (!inList)
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
state.early = early;
|
|
|
|
state.perfect = perfect;
|
|
|
|
state.late = late;
|
2021-12-29 06:52:48 +00:00
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
eligibleHitsList.Add(state);
|
2021-12-29 06:52:48 +00:00
|
|
|
inList = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-01-02 12:09:15 +00:00
|
|
|
Minigame.Eligible es = eligibleHitsList[eligibleHitsList.IndexOf(state)];
|
2021-12-29 06:52:48 +00:00
|
|
|
es.early = early;
|
|
|
|
es.perfect = perfect;
|
|
|
|
es.late = late;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void MakeInEligible(List<Minigame.Eligible> eligibleHitsList)
|
|
|
|
{
|
|
|
|
if (!inList) return;
|
|
|
|
|
2022-01-02 12:09:15 +00:00
|
|
|
eligibleHitsList.Remove(state);
|
2021-12-29 06:52:48 +00:00
|
|
|
inList = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void RemoveObject(int currentHitInList, List<Minigame.Eligible> EligibleHits)
|
|
|
|
{
|
|
|
|
if (currentHitInList < EligibleHits.Count)
|
|
|
|
{
|
|
|
|
EligibleHits.Remove(EligibleHits[currentHitInList]);
|
|
|
|
currentHitInList++;
|
|
|
|
}
|
|
|
|
}
|
2022-01-02 12:09:15 +00:00
|
|
|
|
|
|
|
// No list
|
|
|
|
public void StateCheckNoList(float normalizedBeat)
|
|
|
|
{
|
|
|
|
if (normalizedBeat > Minigame.EarlyTime() && normalizedBeat < Minigame.PerfectTime() && lastState == 0)
|
|
|
|
{
|
|
|
|
ModifyState(true, false, false);
|
|
|
|
lastState++;
|
|
|
|
}
|
|
|
|
// Perfect State
|
|
|
|
else if (normalizedBeat > Minigame.PerfectTime() && normalizedBeat < Minigame.LateTime() && lastState == 1)
|
|
|
|
{
|
|
|
|
ModifyState(false, true, false);
|
|
|
|
lastState++;
|
|
|
|
}
|
|
|
|
// Late State
|
|
|
|
else if (normalizedBeat > Minigame.LateTime() && normalizedBeat < Minigame.EndTime() && lastState == 2)
|
|
|
|
{
|
|
|
|
ModifyState(false, false, true);
|
|
|
|
lastState++;
|
|
|
|
}
|
|
|
|
else if (normalizedBeat < Minigame.EarlyTime() || normalizedBeat > Minigame.EndTime())
|
|
|
|
{
|
|
|
|
// ineligible
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void ModifyState(bool early, bool perfect, bool late)
|
|
|
|
{
|
|
|
|
state.early = early;
|
|
|
|
state.perfect = perfect;
|
|
|
|
state.late = late;
|
|
|
|
}
|
2021-12-29 06:52:48 +00:00
|
|
|
}
|
|
|
|
}
|