3cc77c1791
backing up before re-importing library. - I built the game last night and it had more errors than sleepy joe's memory.
88 lines
2.4 KiB
C#
88 lines
2.4 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,
|
|
Spells = 6
|
|
}
|
|
|
|
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 AudioSource Spells;
|
|
|
|
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;
|
|
|
|
case AudioSources.Spells:
|
|
Spells.clip = clip;
|
|
Spells.Play();
|
|
break;
|
|
}
|
|
}
|
|
|
|
}
|
|
} |