HeavenStudioPlus/Assets/Scripts/UI/Overlays/SectionMedalsManager.cs
minenice55 3984c8353f
Rendering Fixes and Other Adjustments (#384)
* fix game view alpha issues

* fix right-clicking on parameter-less entity locking event selection

* reduce ram use of rendertextures

* fix missing sprite references

fix cheer readers sprite masks not working

* fix lockstep rendering discrepancy

* fix section medal toggle not matching described behaviour in UI

* fix game settings masking issue

* dj school "Scratchy Music" toggle on by default

* import new sheets for fan club, mahou tsukai

* make dj school audio FX persist between game change

* make one shot sounds not create extra objects when not needed

* fix potential issue with new one shots

* make string properties apply changes for every keystroke
2023-04-03 04:17:55 +00:00

78 lines
No EOL
2.2 KiB
C#

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
void Start()
{
instance = this;
cond = Conductor.instance;
GameManager.instance.onSectionChange += OnSectionChange;
}
// Update is called once per frame
void Update()
{
}
public void MakeIneligible()
{
isMedalsEligible = false;
}
public void Reset()
{
isMedalsStarted = false;
isMedalsEligible = true;
foreach (Transform child in MedalsHolder.transform)
{
Destroy(child.gameObject);
}
}
public void OnSectionChange(DynamicBeatmap.ChartSection section)
{
if (section == null) return;
if (!PersistentDataManager.gameSettings.isMedalOn) return;
if (PersistentDataManager.gameSettings.isMedalOn && !isMedalsStarted)
{
isMedalsStarted = true;
isMedalsEligible = true;
}
else
{
GameObject medal = Instantiate(isMedalsEligible ? MedalOkPrefab : MedalMissPrefab, MedalsHolder.transform);
medal.SetActive(true);
isMedalsEligible = true;
}
}
public void OnRemixEnd()
{
if (!PersistentDataManager.gameSettings.isMedalOn) return;
if (PersistentDataManager.gameSettings.isMedalOn && isMedalsStarted)
{
GameObject medal = Instantiate(isMedalsEligible ? MedalOkPrefab : MedalMissPrefab, MedalsHolder.transform);
medal.SetActive(true);
}
}
}
}