This commit is contained in:
falc@null.net 2016-10-30 19:17:58 +01:00
parent 3668eb17a6
commit 632ebfca7d
25 changed files with 546 additions and 0 deletions

9
Assets/AudioManager.meta Normal file
View file

@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 50e31b970e23305488a83154ea8c8cb2
folderAsset: yes
timeCreated: 1477850803
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: f74396619b7154fa5a38a1959cfa67ae
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 2c9cfb2c9889844ac889f2ad14683d0e
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 0805de7e4fb0f4d03a30ae90e7c64311
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: e83e7bcb4f4fb4a79a977d9b03628b87
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,16 @@
using UnityEngine;
using System.Collections;
public class Audio : MonoBehaviour {
AudioSource aus;
// Use this for initialization
public void PlaySoundOnce (AudioClip song){
StartCoroutine (PlaySoundCoroutine (song));
}
IEnumerator PlaySoundCoroutine(AudioClip sound){
aus = GetComponent<AudioSource> ();
aus.PlayOneShot (sound);
yield return new WaitForSeconds (sound.length);
Destroy (gameObject);
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bc2b62a66353228499d873aa87df6856
timeCreated: 1477899362
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,128 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1000010051293816}
m_IsPrefabParent: 1
--- !u!1 &1000010051293816
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 4000013545904244}
- 114: {fileID: 114000011367234474}
- 82: {fileID: 82000010457914330}
m_Layer: 0
m_Name: Audio
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4000013545904244
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010051293816}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.165492, y: 5.1624355, z: -1.8925428}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!82 &82000010457914330
AudioSource:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010051293816}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
--- !u!114 &114000011367234474
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000010051293816}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bc2b62a66353228499d873aa87df6856, type: 3}
m_Name:
m_EditorClassIdentifier:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0c8d88d53b46acb48b5bee989993566c
timeCreated: 1477899384
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,57 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class AudioManager : MonoBehaviour {
public Dictionary<string,int> mapSound;
public AudioClip[] sounds; //0 Sword
//1 DodgeSword
//1 Dodge
//1 Sword
//1 Sword
//1 Sword
public GameObject auxiliar; //objeto para variables temporales
public AudioClip backgroundSound;//musica de fondo
AudioSource aus; //nuestro "reproductor"
public string dir; //de donde cargamos los sonidos
public static AudioManager instance = null;
// Use this for initialization
void Start () {
loadMap ();
//Check if there is already an instance of SoundManager
if (instance == null)
//if not, set it to this.
instance = this;
//If instance already exists:
else if (instance != this)
//Destroy this, this enforces our singleton pattern so there can only be one instance of SoundManager.
Destroy (gameObject);
//Set SoundManager to DontDestroyOnLoad so that it won't be destroyed when reloading our scene.
DontDestroyOnLoad (gameObject);
//Cogemos nuestro componente de sonido y lo reproducimos
aus = GetComponent<AudioSource> ();
aus.clip = backgroundSound;
aus.loop = true;
aus.Play();
}
public void playSound(string name){
if (mapSound.ContainsKey (name)) {
GameObject inst = Instantiate (auxiliar);
AudioClip temp = sounds[ mapSound[name]];
inst.GetComponent<Audio> ().PlaySoundOnce (temp);
}
}
public void setAudioManager(AudioClip bgs, string directory){
bgs = backgroundSound;
dir = directory;
}
private void loadMap(){
mapSound.Add ("sword", 0);
mapSound.Add ("dodgesword", 1);
mapSound.Add ("arrow", 2);
mapSound.Add ("spell1", 3);
mapSound.Add ("goblin", 4);
mapSound.Add ("spell2", 5);
}
}

View file

@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f706c75b49148b64bbb8497e63007cca
timeCreated: 1477898496
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: f32d44a6bdb854aa5b10a83f60a507ab
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,136 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1000013955497836}
m_IsPrefabParent: 1
--- !u!1 &1000013955497836
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 4000011738344164}
- 114: {fileID: 114000010385191948}
- 82: {fileID: 82000012437299840}
m_Layer: 0
m_Name: SoundController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4000011738344164
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013955497836}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.165492, y: 5.1624355, z: -1.8925428}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!82 &82000012437299840
AudioSource:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013955497836}
m_Enabled: 1
serializedVersion: 4
OutputAudioMixerGroup: {fileID: 0}
m_audioClip: {fileID: 0}
m_PlayOnAwake: 1
m_Volume: 1
m_Pitch: 1
Loop: 0
Mute: 0
Spatialize: 0
Priority: 128
DopplerLevel: 1
MinDistance: 1
MaxDistance: 500
Pan2D: 0
rolloffMode: 0
BypassEffects: 0
BypassListenerEffects: 0
BypassReverbZones: 0
rolloffCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
- time: 1
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
panLevelCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
spreadCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 0
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 4
reverbZoneMixCustomCurve:
serializedVersion: 2
m_Curve:
- time: 0
value: 1
inSlope: 0
outSlope: 0
tangentMode: 0
m_PreInfinity: 2
m_PostInfinity: 2
m_RotationOrder: 0
--- !u!114 &114000010385191948
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1000013955497836}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f706c75b49148b64bbb8497e63007cca, type: 3}
m_Name:
m_EditorClassIdentifier:
sounds:
- {fileID: 8300000, guid: f3645d7388d9f4efc88a56c59b3a70d4, type: 3}
- {fileID: 8300000, guid: 52fa067c25c5c401b811eb86d142287e, type: 3}
- {fileID: 8300000, guid: 0805de7e4fb0f4d03a30ae90e7c64311, type: 3}
- {fileID: 8300000, guid: e83e7bcb4f4fb4a79a977d9b03628b87, type: 3}
auxiliar: {fileID: 1000010051293816, guid: 0c8d88d53b46acb48b5bee989993566c, type: 2}
backgroundSound: {fileID: 8300000, guid: 2c9cfb2c9889844ac889f2ad14683d0e, type: 3}
dir:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b642fc53397026446a90e99bcfcffe87
timeCreated: 1477898784
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 9ae32f8e1a94c486c9929faca77ff03b
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: f3645d7388d9f4efc88a56c59b3a70d4
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant:

Binary file not shown.

View file

@ -0,0 +1,20 @@
fileFormatVersion: 2
guid: 52fa067c25c5c401b811eb86d142287e
AudioImporter:
serializedVersion: 6
defaultSettings:
loadType: 1
sampleRateSetting: 0
sampleRateOverride: 0
compressionFormat: 0
quality: 0
conversionMode: 0
platformSettingOverrides: {}
forceToMono: 0
normalize: 1
preloadAudioData: 1
loadInBackground: 0
3D: 1
userData:
assetBundleName:
assetBundleVariant: