2023-05-01 16:05:41 -07:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
public class GameUIController : MonoBehaviour
|
|
|
|
{
|
|
|
|
|
|
|
|
[Header("Instruments (backgrounds)")]
|
|
|
|
public GameObject trumpetBackground;
|
|
|
|
public GameObject tambourineBackground;
|
|
|
|
public GameObject clarinetBackground;
|
2023-05-05 10:44:42 -07:00
|
|
|
public GameObject cymbalBackground;
|
2023-05-01 16:05:41 -07:00
|
|
|
[HideInInspector] public GameObject trumpetUI;
|
|
|
|
[HideInInspector] public GameObject tambourineUI;
|
|
|
|
[HideInInspector] public GameObject clarinetUI;
|
2023-05-05 10:44:42 -07:00
|
|
|
[HideInInspector] public GameObject cymbalUI;
|
2023-05-01 16:05:41 -07:00
|
|
|
|
2023-05-03 15:18:21 -07:00
|
|
|
void Awake()
|
2023-05-04 02:19:51 -07:00
|
|
|
{
|
|
|
|
this.trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
|
|
|
|
this.tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
|
|
|
|
this.clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
|
2023-05-05 10:44:42 -07:00
|
|
|
this.cymbalUI = this.cymbalBackground.transform.GetChild(0).gameObject;
|
2023-05-04 14:17:57 -07:00
|
|
|
}
|
2023-05-01 16:05:41 -07:00
|
|
|
|
2023-05-05 10:44:42 -07:00
|
|
|
void Start()
|
|
|
|
{
|
2023-05-04 02:19:51 -07:00
|
|
|
this.trumpetBackground.SetActive(StateController.Instance.HasTrumpet());
|
|
|
|
this.tambourineBackground.SetActive(StateController.Instance.HasTambourine());
|
|
|
|
this.clarinetBackground.SetActive(StateController.Instance.HasClarinet());
|
2023-05-05 10:44:42 -07:00
|
|
|
this.cymbalBackground.SetActive(StateController.Instance.HasCymbal());
|
2023-05-01 16:05:41 -07:00
|
|
|
}
|
|
|
|
|
2023-05-04 02:19:51 -07:00
|
|
|
public void ToggleTrumpet(bool toggleState)
|
|
|
|
{
|
2023-05-01 16:05:41 -07:00
|
|
|
bool curEnabled = trumpetUI.GetComponent<Image>().enabled;
|
2023-05-04 02:19:51 -07:00
|
|
|
if (curEnabled != toggleState)
|
|
|
|
{
|
2023-05-01 16:05:41 -07:00
|
|
|
trumpetUI.GetComponent<Image>().enabled = toggleState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 02:19:51 -07:00
|
|
|
public void ToggleTambourine(bool toggleState)
|
|
|
|
{
|
2023-05-01 16:05:41 -07:00
|
|
|
bool curEnabled = tambourineUI.GetComponent<Image>().enabled;
|
2023-05-04 02:19:51 -07:00
|
|
|
if (curEnabled != toggleState)
|
|
|
|
{
|
2023-05-01 16:05:41 -07:00
|
|
|
tambourineUI.GetComponent<Image>().enabled = toggleState;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 02:19:51 -07:00
|
|
|
public void ToggleClarinet(bool toggleState)
|
|
|
|
{
|
2023-05-01 16:05:41 -07:00
|
|
|
bool curEnabled = clarinetUI.GetComponent<Image>().enabled;
|
2023-05-04 02:19:51 -07:00
|
|
|
if (curEnabled != toggleState)
|
|
|
|
{
|
2023-05-01 16:05:41 -07:00
|
|
|
clarinetUI.GetComponent<Image>().enabled = toggleState;
|
|
|
|
}
|
|
|
|
}
|
2023-05-01 16:53:13 -07:00
|
|
|
|
2023-05-05 12:24:04 -07:00
|
|
|
public void ToggleCymbal(bool toggleState)
|
2023-05-05 10:44:42 -07:00
|
|
|
{
|
2023-05-05 12:24:04 -07:00
|
|
|
bool curEnabled = cymbalUI.GetComponent<Image>().enabled;
|
|
|
|
if (curEnabled != toggleState)
|
2023-05-05 10:44:42 -07:00
|
|
|
{
|
2023-05-05 12:24:04 -07:00
|
|
|
cymbalUI.GetComponent<Image>().enabled = toggleState;
|
2023-05-05 10:44:42 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-04 02:19:51 -07:00
|
|
|
public void UpdateInstrumentUI()
|
|
|
|
{
|
|
|
|
this.ToggleTrumpet(StateController.Instance.HasTrumpet());
|
|
|
|
this.ToggleTambourine(StateController.Instance.HasTambourine());
|
|
|
|
this.ToggleClarinet(StateController.Instance.HasClarinet());
|
2023-05-05 10:44:42 -07:00
|
|
|
this.ToggleCymbal(StateController.Instance.HasCymbal());
|
2023-05-01 16:53:13 -07:00
|
|
|
}
|
2023-05-01 16:05:41 -07:00
|
|
|
}
|