Firstborn/Assets/RPG Creation Kit/Scripts/Audio/GameAudioManager.cs
Schaken-Mods 959e80cf72 assets upload
assets upload description.
2023-03-28 12:16:30 -05:00

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;
}
}
}
}