This commit is contained in:
2025-05-13 05:19:58 +03:00
parent 853edaf0b4
commit 472b2aee18
1034 changed files with 41844 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
using UnityEngine;
using System.Collections;
using UnityEngine.Audio;
public class DoorAudioController : MonoBehaviour {
private Door _door;
private AudioSource _audio;
public AudioClip openSound;
public AudioClip closeSound;
// Use this for initialization
void Start () {
_door = transform.parent.GetComponentInChildren<Door>();
_door.StateChanged += HandleStateChanged;
_audio = GetComponent<AudioSource>();
}
void HandleStateChanged (Door sender, DoorState from, DoorState to)
{
if(from == DoorState.Closed){
_audio.PlayOneShot(openSound);
}else if(to == DoorState.Closed){
_audio.PlayOneShot(closeSound);
}
}
// Update is called once per frame
void Update () {
}
}