2023-03-11 04:51:22 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
using HeavenStudio.Util;
|
|
|
|
using HeavenStudio.Games;
|
|
|
|
|
|
|
|
namespace HeavenStudio.Common
|
|
|
|
{
|
|
|
|
public class SectionMedalsManager : MonoBehaviour
|
|
|
|
{
|
|
|
|
public static SectionMedalsManager instance { get; private set; }
|
|
|
|
|
|
|
|
[SerializeField] GameObject MedalsHolder;
|
|
|
|
[SerializeField] GameObject MedalOkPrefab;
|
|
|
|
[SerializeField] GameObject MedalMissPrefab;
|
|
|
|
|
|
|
|
Conductor cond;
|
|
|
|
bool isMedalsStarted = false;
|
|
|
|
bool isMedalsEligible = true;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
2023-05-07 20:33:15 +00:00
|
|
|
public void Awake()
|
2023-03-11 04:51:22 +00:00
|
|
|
{
|
|
|
|
instance = this;
|
2023-05-07 20:33:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void Start()
|
|
|
|
{
|
2023-03-11 04:51:22 +00:00
|
|
|
cond = Conductor.instance;
|
|
|
|
GameManager.instance.onSectionChange += OnSectionChange;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
void Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2023-05-07 20:33:15 +00:00
|
|
|
public void AnchorToOverlay(GameObject overlay)
|
|
|
|
{
|
|
|
|
transform.position = overlay.transform.position;
|
|
|
|
transform.rotation = overlay.transform.rotation;
|
|
|
|
transform.localScale = overlay.transform.localScale;
|
|
|
|
}
|
|
|
|
|
2023-03-11 04:51:22 +00:00
|
|
|
public void MakeIneligible()
|
|
|
|
{
|
|
|
|
isMedalsEligible = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void Reset()
|
|
|
|
{
|
|
|
|
isMedalsStarted = false;
|
|
|
|
isMedalsEligible = true;
|
2023-05-07 20:33:15 +00:00
|
|
|
foreach (Transform child in MedalsHolder?.transform)
|
2023-03-11 04:51:22 +00:00
|
|
|
{
|
|
|
|
Destroy(child.gameObject);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnSectionChange(DynamicBeatmap.ChartSection section)
|
|
|
|
{
|
|
|
|
if (section == null) return;
|
2023-04-03 04:17:55 +00:00
|
|
|
if (!PersistentDataManager.gameSettings.isMedalOn) return;
|
2023-03-11 04:51:22 +00:00
|
|
|
if (PersistentDataManager.gameSettings.isMedalOn && !isMedalsStarted)
|
|
|
|
{
|
|
|
|
isMedalsStarted = true;
|
|
|
|
isMedalsEligible = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
GameManager.instance.ClearedSection = isMedalsEligible;
|
2023-03-11 04:51:22 +00:00
|
|
|
GameObject medal = Instantiate(isMedalsEligible ? MedalOkPrefab : MedalMissPrefab, MedalsHolder.transform);
|
|
|
|
medal.SetActive(true);
|
|
|
|
isMedalsEligible = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnRemixEnd()
|
|
|
|
{
|
2023-04-03 04:17:55 +00:00
|
|
|
if (!PersistentDataManager.gameSettings.isMedalOn) return;
|
2023-03-11 04:51:22 +00:00
|
|
|
if (PersistentDataManager.gameSettings.isMedalOn && isMedalsStarted)
|
|
|
|
{
|
2023-05-07 20:33:15 +00:00
|
|
|
GameManager.instance.ClearedSection = isMedalsEligible;
|
2023-03-11 04:51:22 +00:00
|
|
|
GameObject medal = Instantiate(isMedalsEligible ? MedalOkPrefab : MedalMissPrefab, MedalsHolder.transform);
|
|
|
|
medal.SetActive(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|