added some basic ui

still work in progress, just a progress commit!
This commit is contained in:
Sam
2023-05-01 16:05:41 -07:00
parent d1528cc6ff
commit febbf21253
11 changed files with 1577 additions and 292 deletions

View File

@@ -0,0 +1,58 @@
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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ddba2a418da03482da8b928ab93c0c52
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -66,6 +66,8 @@ public class PlayerMovement : MonoBehaviour
[HideInInspector] private AudioSource audioSource;
[HideInInspector] private bool soundPlaying = false;
[HideInInspector] private GameUIController gameUI;
#endregion
private void Awake()
@@ -75,6 +77,7 @@ public class PlayerMovement : MonoBehaviour
grapplingRope = playerBehavior.grapplingRope;
stateController = GameObject.FindGameObjectWithTag("StateController").GetComponent<StateController>();
audioSource = GetComponent<AudioSource>();
gameUI = GameObject.FindGameObjectWithTag("GameUICanvas").GetComponent<GameUIController>();
}
private void Start()
@@ -135,6 +138,7 @@ public class PlayerMovement : MonoBehaviour
LastOnGroundTime = Data.coyoteTime; //if so sets the lastGrounded to coyoteTime
if (unlockedTrumpet) {
trumpet = 2;
gameUI.ToggleTrumpet(true);
} else {
trumpet = -1;
}
@@ -145,6 +149,7 @@ public class PlayerMovement : MonoBehaviour
if(!_isJumpFalling && !isRegFalling) {
if(unlockedTrumpet) {
trumpet = 1;
gameUI.ToggleTrumpet(true);
} else {
trumpet = -1;
}
@@ -302,6 +307,12 @@ public class PlayerMovement : MonoBehaviour
soundPlaying = false;
}
#endregion
#region UPDATE UI
if (trumpet == 0) {
gameUI.ToggleTrumpet(false);
}
#endregion
}
private void FixedUpdate()