ACTUALLY FIXED BROKEN COMMIT

pull this one!
This commit is contained in:
Sam 2023-05-01 17:30:54 -07:00
parent 071a9b43d4
commit fc8c2e6062
2 changed files with 14 additions and 4 deletions

View File

@ -18,12 +18,16 @@ public class GameUIController : MonoBehaviour
private StateController stateController; private StateController stateController;
void Start() { void Start() {
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
if (stateController == null) {
print("state controller not found");
} else {
print("yeehaw");
}
trumpetUI = trumpetBackground.transform.GetChild(0).gameObject; trumpetUI = trumpetBackground.transform.GetChild(0).gameObject;
tambourineUI = tambourineBackground.transform.GetChild(0).gameObject; tambourineUI = tambourineBackground.transform.GetChild(0).gameObject;
clarinetUI = clarinetBackground.transform.GetChild(0).gameObject; clarinetUI = clarinetBackground.transform.GetChild(0).gameObject;
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
if (!stateController.unlockedTrumpet) { if (!stateController.unlockedTrumpet) {
trumpetBackground.SetActive(false); trumpetBackground.SetActive(false);
} }
@ -57,6 +61,9 @@ public class GameUIController : MonoBehaviour
} }
public void ResetInstrumentUI() { public void ResetInstrumentUI() {
if (stateController == null) {
print("state controller null");
}
if (stateController.unlockedTrumpet) { if (stateController.unlockedTrumpet) {
ToggleTrumpet(true); ToggleTrumpet(true);
} }

View File

@ -37,13 +37,12 @@ public class PlayerBehavior : MonoBehaviour
AudioSource audioSource; AudioSource audioSource;
void Start() void Awake()
{ // initialize { // initialize
_rb = GetComponent<Rigidbody2D>(); _rb = GetComponent<Rigidbody2D>();
stateController = GameObject.Find("StateController").GetComponent<StateController>(); stateController = GameObject.Find("StateController").GetComponent<StateController>();
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>(); gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
gameUI.ResetInstrumentUI();
audioSource = this.gameObject.GetComponent<AudioSource>(); audioSource = this.gameObject.GetComponent<AudioSource>();
audioSource.clip = footstepSound; audioSource.clip = footstepSound;
@ -54,6 +53,10 @@ public class PlayerBehavior : MonoBehaviour
playerIsAlive = true; playerIsAlive = true;
} }
void Start() {
gameUI.ResetInstrumentUI();
}
void Update() void Update()
{ {
unlockedTambourine = stateController.unlockedTambourine; unlockedTambourine = stateController.unlockedTambourine;