-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioSupport.cs
More file actions
27 lines (24 loc) · 865 Bytes
/
AudioSupport.cs
File metadata and controls
27 lines (24 loc) · 865 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AudioSupport : MonoBehaviour
{
[SerializeField] private AudioClip tileMatchSound;
[SerializeField] private AudioClip tileFallSound;
private AudioSource audioSource;
private void OnEnable()
{
MatchChecker.OnMatchMade += OnMatch;
Item_move.OnTileMoved += OnFall;
ChangeItemCell.OnMoveDone += OnFall;
}
private void OnDisable()
{
MatchChecker.OnMatchMade -= OnMatch;
Item_move.OnTileMoved -= OnFall;
ChangeItemCell.OnMoveDone -= OnFall;
}
private void Start() => audioSource = GetComponent<AudioSource>();
private void OnMatch(int cellID) => audioSource.PlayOneShot(tileMatchSound);
private void OnFall() => audioSource.PlayOneShot(tileFallSound);
}