fixed cymbal bugs

sound no longer breaks (separate game object for sound), ui updated
This commit is contained in:
Sam
2023-05-05 12:24:04 -07:00
parent d3dfe2acac
commit 6131bc7ca1
5 changed files with 306 additions and 190 deletions

View File

@@ -59,12 +59,12 @@ public class GameUIController : MonoBehaviour
}
}
public void ToggleCymbal(bool desiredState)
public void ToggleCymbal(bool toggleState)
{
bool curEnabled = clarinetUI.GetComponent<Image>().enabled;
if (curEnabled != desiredState)
bool curEnabled = cymbalUI.GetComponent<Image>().enabled;
if (curEnabled != toggleState)
{
cymbalUI.GetComponent<Image>().enabled = desiredState;
cymbalUI.GetComponent<Image>().enabled = toggleState;
}
}

View File

@@ -33,6 +33,7 @@ public class PlayerBehavior : MonoBehaviour
[Header("Cymbals:")]
private float cymbalActiveTime = 0f;
[SerializeField] AudioSource cymbalAudio;
[Header("Grappling:")]
[SerializeField] public Tutorial_GrapplingGun grapplingGun;
@@ -49,7 +50,6 @@ public class PlayerBehavior : MonoBehaviour
[Header("Sound")]
[SerializeField] public AudioClip footstepSound;
[SerializeField] public AudioClip deathSound;
[SerializeField] public AudioClip cymbalSound;
AudioSource audioSource;
@@ -152,9 +152,10 @@ public class PlayerBehavior : MonoBehaviour
{
// Play the sound
this.gameUI.ToggleCymbal(false);
this.audioSource.clip = cymbalSound;
this.audioSource.loop = false;
this.audioSource.Play();
// this.audioSource.clip = cymbalSound;
// this.audioSource.loop = false;
// this.audioSource.Play();
cymbalAudio.Play();
// Set the cymbal active for the equivalent of one second
this.cymbalActiveTime = 1;