64 lines
2.0 KiB
C#
64 lines
2.0 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;
|
|
[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;
|
|
}
|
|
|
|
void Start() {
|
|
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<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 UpdateInstrumentUI()
|
|
{
|
|
this.ToggleTrumpet(StateController.Instance.HasTrumpet());
|
|
this.ToggleTambourine(StateController.Instance.HasTambourine());
|
|
this.ToggleClarinet(StateController.Instance.HasClarinet());
|
|
}
|
|
}
|