Add SFX and SFX logic

This commit is contained in:
BuyMyMojo 2023-03-03 05:10:23 +11:00
parent f0e4f6c9ba
commit 1aa97baff4
19 changed files with 504 additions and 8 deletions

View file

@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StoveCounterSound : MonoBehaviour
{
[SerializeField] private StoveCounter stoveCounter;
private AudioSource audioSource;
private void Awake()
{
audioSource = GetComponent<AudioSource>();
}
private void Start()
{
stoveCounter.OnStateChanged += StoveCounter_OnStateChanged;
}
private void StoveCounter_OnStateChanged(object sender, StoveCounter.OnStateChangedEventArgs e)
{
bool playSound = e.state == StoveCounter.State.Frying || e.state == StoveCounter.State.Fried;
if (playSound)
{
audioSource.Play();
} else
{
audioSource.Pause();
}
}
}