DLevel Sounds

This commit is contained in:
DominikB 2023-06-24 14:57:13 +02:00
parent 9c043b51cb
commit ba6e8cd54e
5 changed files with 22 additions and 9 deletions

View File

@ -14,11 +14,14 @@ public bool einsAn = false;
public GameObject _LevelManager1; public GameObject _LevelManager1;
private keyWhenPressed script1; private keyWhenPressed script1;
bool isActivated; bool isActivated;
private AudioSource audioSource; // Reference to the AudioSource component
public AudioClip pressedSound; // The sound clip to be played
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
originalPointPosition = movingPoint.transform.position; originalPointPosition = movingPoint.transform.position;
audioSource = GetComponent<AudioSource>();
} }
// Update is called once per frame // Update is called once per frame
@ -36,6 +39,9 @@ void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("PressurePlatable") || other.CompareTag("PlayerIsOnIt")){ if (other.CompareTag("PressurePlatable") || other.CompareTag("PlayerIsOnIt")){
spriteRenderer.sprite = activatedSprite; spriteRenderer.sprite = activatedSprite;
movingPoint.transform.position = activatedPointPosition; movingPoint.transform.position = activatedPointPosition;
audioSource.PlayOneShot(pressedSound);
einsAn = true; einsAn = true;
} }
} }

View File

@ -11,10 +11,12 @@ public Sprite activatedSprite;
public bool startActivated = false; public bool startActivated = false;
private Collider2D Stein = null; private Collider2D Stein = null;
public bool dreiAn = false; public bool dreiAn = false;
private AudioSource audioSource; // Reference to the AudioSource component
public AudioClip pressedSound; // The sound clip to be played
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
audioSource = GetComponent<AudioSource>();
} }
// Update is called once per frame // Update is called once per frame
@ -37,6 +39,9 @@ void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("PressurePlatable")||other.CompareTag("Player")) { if (other.CompareTag("PressurePlatable")||other.CompareTag("Player")) {
startActivated = true; startActivated = true;
spriteRenderer.sprite = activatedSprite; spriteRenderer.sprite = activatedSprite;
if(!dreiAn){
audioSource.PlayOneShot(pressedSound);
}
dreiAn = true; dreiAn = true;
} }

View File

@ -11,10 +11,12 @@ public Sprite activatedSprite;
public bool startActivated = false; public bool startActivated = false;
private Collider2D Stein = null; private Collider2D Stein = null;
public bool zweiAn = false; public bool zweiAn = false;
private AudioSource audioSource; // Reference to the AudioSource component
public AudioClip pressedSound; // The sound clip to be played
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
audioSource = GetComponent<AudioSource>();
} }
// Update is called once per frame // Update is called once per frame
@ -37,6 +39,9 @@ void OnTriggerEnter2D(Collider2D other) {
if (other.CompareTag("PressurePlatable")||other.CompareTag("Player")) { if (other.CompareTag("PressurePlatable")||other.CompareTag("Player")) {
startActivated = true; startActivated = true;
spriteRenderer.sprite = activatedSprite; spriteRenderer.sprite = activatedSprite;
if(!zweiAn){
audioSource.PlayOneShot(pressedSound);
}
zweiAn = true; zweiAn = true;
} }

View File

@ -11,6 +11,8 @@ public class keyWhenPressed : MonoBehaviour
private ButtonDTwo script2; private ButtonDTwo script2;
public GameObject _LevelManager3; public GameObject _LevelManager3;
private ButtonDThree script3; private ButtonDThree script3;
private AudioSource audioSource; // Reference to the AudioSource component
public AudioClip keyAppearSound; // The sound clip to be played
public bool isActivated; public bool isActivated;
@ -18,6 +20,7 @@ public class keyWhenPressed : MonoBehaviour
{ {
// Disable the object by default // Disable the object by default
objectToActivate.SetActive(false); objectToActivate.SetActive(false);
audioSource = GetComponent<AudioSource>();
} }
@ -33,6 +36,7 @@ public class keyWhenPressed : MonoBehaviour
if (eins && zwei && drei && !isActivated) if (eins && zwei && drei && !isActivated)
{ {
// Activate the object // Activate the object
audioSource.PlayOneShot(keyAppearSound);
objectToActivate.SetActive(true); objectToActivate.SetActive(true);
isActivated = true; isActivated = true;
} }

View File

@ -1,7 +0,0 @@
fileFormatVersion: 2
guid: 3512dddf54c8f2d4c8406d418d09c0b9
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: