6131bc7ca1
sound no longer breaks (separate game object for sound), ui updated
79 lines
2.6 KiB
C#
79 lines
2.6 KiB
C#
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;
|
|
public GameObject cymbalBackground;
|
|
[HideInInspector] public GameObject trumpetUI;
|
|
[HideInInspector] public GameObject tambourineUI;
|
|
[HideInInspector] public GameObject clarinetUI;
|
|
[HideInInspector] public GameObject cymbalUI;
|
|
|
|
void Awake()
|
|
{
|
|
this.trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
|
|
this.tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
|
|
this.clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
|
|
this.cymbalUI = this.cymbalBackground.transform.GetChild(0).gameObject;
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
this.trumpetBackground.SetActive(StateController.Instance.HasTrumpet());
|
|
this.tambourineBackground.SetActive(StateController.Instance.HasTambourine());
|
|
this.clarinetBackground.SetActive(StateController.Instance.HasClarinet());
|
|
this.cymbalBackground.SetActive(StateController.Instance.HasCymbal());
|
|
}
|
|
|
|
public void ToggleTrumpet(bool toggleState)
|
|
{
|
|
bool curEnabled = trumpetUI.GetComponent<Image>().enabled;
|
|
if (curEnabled != toggleState)
|
|
{
|
|
trumpetUI.GetComponent<Image>().enabled = toggleState;
|
|
}
|
|
}
|
|
|
|
public void ToggleTambourine(bool toggleState)
|
|
{
|
|
bool curEnabled = tambourineUI.GetComponent<Image>().enabled;
|
|
if (curEnabled != toggleState)
|
|
{
|
|
tambourineUI.GetComponent<Image>().enabled = toggleState;
|
|
}
|
|
}
|
|
|
|
public void ToggleClarinet(bool toggleState)
|
|
{
|
|
bool curEnabled = clarinetUI.GetComponent<Image>().enabled;
|
|
if (curEnabled != toggleState)
|
|
{
|
|
clarinetUI.GetComponent<Image>().enabled = toggleState;
|
|
}
|
|
}
|
|
|
|
public void ToggleCymbal(bool toggleState)
|
|
{
|
|
bool curEnabled = cymbalUI.GetComponent<Image>().enabled;
|
|
if (curEnabled != toggleState)
|
|
{
|
|
cymbalUI.GetComponent<Image>().enabled = toggleState;
|
|
}
|
|
}
|
|
|
|
public void UpdateInstrumentUI()
|
|
{
|
|
this.ToggleTrumpet(StateController.Instance.HasTrumpet());
|
|
this.ToggleTambourine(StateController.Instance.HasTambourine());
|
|
this.ToggleClarinet(StateController.Instance.HasClarinet());
|
|
this.ToggleCymbal(StateController.Instance.HasCymbal());
|
|
}
|
|
}
|