81 lines
2.2 KiB
C#
81 lines
2.2 KiB
C#
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
using RPGCreationKit;
|
|||
|
|
|||
|
namespace RPGCreationKit
|
|||
|
{
|
|||
|
public enum AudioSources
|
|||
|
{
|
|||
|
GeneralSounds = 0, // This is very near to the camera, used for general sounds (Item pick up, trade sounds, etc.)
|
|||
|
UISounds = 1,
|
|||
|
Player = 2,
|
|||
|
PlayerFPS = 3,
|
|||
|
Ambience = 4,
|
|||
|
Music = 5
|
|||
|
}
|
|||
|
|
|||
|
public class GameAudioManager : MonoBehaviour
|
|||
|
{
|
|||
|
public static GameAudioManager instance;
|
|||
|
private void Awake()
|
|||
|
{
|
|||
|
if (instance == null)
|
|||
|
instance = this;
|
|||
|
else
|
|||
|
{
|
|||
|
Debug.Log("Anomaly detected with the singleton pattern of 'GameAudioManager', do you have multiple instances?");
|
|||
|
Destroy(this);
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public AudioSource player;
|
|||
|
public AudioSource playerFPS;
|
|||
|
|
|||
|
public AudioSource uiSounds;
|
|||
|
public AudioSource generalSounds;
|
|||
|
|
|||
|
public AudioSource Ambience;
|
|||
|
public AudioSource Music;
|
|||
|
|
|||
|
public AudioClip CurrentMusic;
|
|||
|
|
|||
|
public void PlayOneShot(AudioSources source, AudioClip clip)
|
|||
|
{
|
|||
|
switch (source)
|
|||
|
{
|
|||
|
case AudioSources.GeneralSounds:
|
|||
|
//generalSounds.PlayOneShot(clip);
|
|||
|
generalSounds.clip = clip;
|
|||
|
generalSounds.Play();
|
|||
|
break;
|
|||
|
|
|||
|
case AudioSources.UISounds:
|
|||
|
uiSounds.clip = clip;
|
|||
|
uiSounds.Play(); break;
|
|||
|
|
|||
|
case AudioSources.Player:
|
|||
|
player.clip = clip;
|
|||
|
player.Play();
|
|||
|
break;
|
|||
|
|
|||
|
case AudioSources.PlayerFPS:
|
|||
|
playerFPS.clip = clip;
|
|||
|
playerFPS.Play();
|
|||
|
break;
|
|||
|
|
|||
|
case AudioSources.Ambience:
|
|||
|
Ambience.clip = clip;
|
|||
|
Ambience.Play();
|
|||
|
break;
|
|||
|
|
|||
|
case AudioSources.Music:
|
|||
|
CurrentMusic = clip;
|
|||
|
Music.clip = clip;
|
|||
|
Music.Play();
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|