plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,152 @@
using UnityEngine;
namespace GameKitController.Audio
{
public class AudioPlayer
{
public static void Play (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
if (audioElement.clip != null) {
audioElement.audioSource.clip = audioElement.clip;
}
if (audioElement.audioSource.enabled) {
audioElement.audioSource.Play ();
}
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.Play (audioElement, gameObj);
}
}
public static void PlayOneShot (AudioElement audioElement, GameObject gameObj, float volumeScale = 1.0f)
{
if (audioElement == null)
return;
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned || audioElement.clip == null) {
return;
}
if (audioElement.audioSource.enabled) {
audioElement.audioSource.PlayOneShot (audioElement.clip, volumeScale);
}
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.PlayOneShot (audioElement, gameObj, volumeScale);
}
}
public static void Stop (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
audioElement.audioSource.Stop ();
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.Stop (audioElement, gameObj);
}
}
public static void Pause (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
audioElement.audioSource.Pause ();
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.Pause (audioElement, gameObj);
}
}
public static void UnPause (AudioElement audioElement, GameObject gameObj)
{
if (audioElement == null) {
return;
}
if (audioElement.audioPlayMethod == AudioPlayMethod.UnityAudio) {
GetComponentAudioSourceIfNull (audioElement, gameObj);
if (!audioElement.audioSourceAssigned) {
return;
}
audioElement.audioSource.UnPause ();
} else if (audioElement.audioPlayMethod == AudioPlayMethod.External) {
var externalAudioPlayer = AudioManager.Instance.GetExternalAudioPlayer ();
if (externalAudioPlayer == null) {
return;
}
externalAudioPlayer.UnPause (audioElement, gameObj);
}
}
private static void GetComponentAudioSourceIfNull (AudioElement audioElement, GameObject gameObj)
{
if (!audioElement.audioSourceAssigned) {
audioElement.audioSourceAssigned = audioElement.audioSource != null;
}
if (!audioElement.audioSourceAssigned) {
audioElement.audioSource = gameObj.GetComponent<AudioSource> ();
audioElement.audioSourceAssigned = audioElement.audioSource != null;
}
}
}
}