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; [HideInInspector] public GameObject trumpetUI; [HideInInspector] public GameObject tambourineUI; [HideInInspector] public GameObject clarinetUI; void Awake() { this.trumpetUI = trumpetBackground.transform.GetChild(0).gameObject; this.tambourineUI = tambourineBackground.transform.GetChild(0).gameObject; this.clarinetUI = clarinetBackground.transform.GetChild(0).gameObject; // TODO: This can be probably be combined with the update methods this.trumpetBackground.SetActive(StateController.Instance.HasTrumpet()); this.tambourineBackground.SetActive(StateController.Instance.HasTambourine()); this.clarinetBackground.SetActive(StateController.Instance.HasClarinet()); } public void ToggleTrumpet(bool toggleState) { bool curEnabled = trumpetUI.GetComponent().enabled; if (curEnabled != toggleState) { trumpetUI.GetComponent().enabled = toggleState; } } public void ToggleTambourine(bool toggleState) { bool curEnabled = tambourineUI.GetComponent().enabled; if (curEnabled != toggleState) { tambourineUI.GetComponent().enabled = toggleState; } } public void ToggleClarinet(bool toggleState) { bool curEnabled = clarinetUI.GetComponent().enabled; if (curEnabled != toggleState) { clarinetUI.GetComponent().enabled = toggleState; } } public void UpdateInstrumentUI() { this.ToggleTrumpet(StateController.Instance.HasTrumpet()); this.ToggleTambourine(StateController.Instance.HasTambourine()); this.ToggleClarinet(StateController.Instance.HasClarinet()); } }