ofb/Assets/Scripts/GameUIController.cs

59 lines
1.9 KiB
C#
Raw Normal View History

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;
[Header("Other Objects")]
private StateController stateController;
void Start() {
trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
if (!stateController.unlockedTrumpet) {
trumpetBackground.SetActive(false);
}
if (!stateController.unlockedTambourine) {
tambourineBackground.SetActive(false);
}
if (!stateController.unlockedClarinet) {
clarinetBackground.SetActive(false);
}
}
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;
}
}
}