MAJOR: Re-organize entire project
This commit is contained in:
21
Assets/Scripts/Audio/AudioPlayer.cs
Normal file
21
Assets/Scripts/Audio/AudioPlayer.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class AudioPlayer : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Audio/AudioPlayer.cs.meta
Normal file
11
Assets/Scripts/Audio/AudioPlayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0929d89c738f7434a8aeb4a3142ae89d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
50
Assets/Scripts/Audio/BGMManager.cs
Normal file
50
Assets/Scripts/Audio/BGMManager.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts
|
||||
{
|
||||
public class BGMManager : MonoBehaviour
|
||||
{
|
||||
public static BGMManager Instance { get; private set; }
|
||||
|
||||
[SerializeField]
|
||||
private AudioSource audioSource;
|
||||
|
||||
[SerializeField]
|
||||
private AudioClip[] backgroundMusic;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public void PlaySong()
|
||||
{
|
||||
audioSource.Stop();
|
||||
|
||||
var sceneCount = SceneManager.sceneCount;
|
||||
var scenes = new List<Scene>();
|
||||
|
||||
for (var i = 0; i < sceneCount; ++i)
|
||||
scenes.Add(SceneManager.GetSceneAt(i));
|
||||
|
||||
AudioClip audioClipToPlay = null;
|
||||
|
||||
if (scenes.Any(x => x.name.Contains("Temple")))
|
||||
audioClipToPlay = backgroundMusic[0];
|
||||
if (scenes.Any(x => x.name.Contains("Sanctum")))
|
||||
audioClipToPlay = backgroundMusic[1];
|
||||
|
||||
if (audioClipToPlay != audioSource.clip)
|
||||
{
|
||||
audioSource.clip = audioClipToPlay;
|
||||
audioSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Audio/BGMManager.cs.meta
Normal file
11
Assets/Scripts/Audio/BGMManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 978ba66c51f1aa942bb951304a3dc54d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
39
Assets/Scripts/Audio/Footsteps.cs
Normal file
39
Assets/Scripts/Audio/Footsteps.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Scampz.GameJam.Assets.Scripts;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class Footsteps : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private AudioClip grassStep;
|
||||
[SerializeField]
|
||||
private AudioClip templeStep;
|
||||
[SerializeField]
|
||||
private AudioClip sandStep;
|
||||
[SerializeField]
|
||||
private AudioSource audioSource;
|
||||
|
||||
private void Step()
|
||||
{
|
||||
var clip = GetAudioClip();
|
||||
audioSource.PlayOneShot(clip);
|
||||
}
|
||||
|
||||
private AudioClip GetAudioClip()
|
||||
{
|
||||
var terrainType = TerrainTypeFinder.Find();
|
||||
switch(terrainType)
|
||||
{
|
||||
case TerrainType.Grass:
|
||||
return grassStep;
|
||||
case TerrainType.Temple:
|
||||
return templeStep;
|
||||
case TerrainType.Sand:
|
||||
return sandStep;
|
||||
}
|
||||
|
||||
return templeStep;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Audio/Footsteps.cs.meta
Normal file
11
Assets/Scripts/Audio/Footsteps.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3dc835db21e8a7244a1e4ca279799cd6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user