lost me mind i did

This commit is contained in:
2022-08-16 01:49:55 -07:00
parent 64a399990c
commit 4255ed97e7
100 changed files with 10152 additions and 7647 deletions

View File

@@ -7,13 +7,12 @@ namespace Scampz.GameJam.Assets.Scripts
{
public class BGMManager : MonoBehaviour
{
[SerializeField]
private AudioSource audioSource;
[SerializeField]
private AudioClip[] backgroundMusic;
private static BGMManager _instance;
private static AudioSource _audioSource;
public static BGMManager Instance
{
@@ -23,7 +22,9 @@ namespace Scampz.GameJam.Assets.Scripts
{
_instance = new GameObject().AddComponent<BGMManager>();
_instance.name = _instance.GetType().ToString();
_audioSource = new GameObject().AddComponent<AudioSource>();
DontDestroyOnLoad(_instance.gameObject);
DontDestroyOnLoad(_audioSource.gameObject);
}
return _instance;
@@ -32,7 +33,7 @@ namespace Scampz.GameJam.Assets.Scripts
public void PlaySong()
{
audioSource.Stop();
_audioSource.Stop();
var sceneCount = SceneManager.sceneCount;
var scenes = new List<Scene>();
@@ -47,10 +48,10 @@ namespace Scampz.GameJam.Assets.Scripts
if (scenes.Any(x => x.name.Contains("Sanctum")))
audioClipToPlay = backgroundMusic[1];
if (audioClipToPlay != audioSource.clip)
if (audioClipToPlay != _audioSource.clip)
{
audioSource.clip = audioClipToPlay;
audioSource.Play();
_audioSource.clip = audioClipToPlay;
_audioSource.Play();
}
}

View File

@@ -6,8 +6,7 @@ namespace Scampz.GameJam
{
public class GameManager : MonoBehaviour
{
public Animator animator;
private static Animator _animator;
private static GameManager _instance;
public static GameManager Instance
@@ -17,26 +16,25 @@ namespace Scampz.GameJam
if (!_instance)
{
_instance = new GameObject().AddComponent<GameManager>();
_animator = new GameObject().AddComponent<Animator>();
_instance.name = _instance.GetType().ToString();
DontDestroyOnLoad(_instance.gameObject);
DontDestroyOnLoad(_animator.gameObject);
}
return _instance;
}
}
void OnEnable()
{
//SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnDisable()
{
//SceneManager.sceneLoaded -= OnSceneLoaded;
}
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
public void LoadScene(string sceneName, Transform spawnPoint, LoadSceneMode loadSceneMode)
{
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
var player = GameObject.FindGameObjectWithTag("Player");
var cc = player.GetComponent<CharacterController>();
cc.enabled = false;
player.transform.position = spawnPoint.transform.position;
player.transform.rotation = spawnPoint.transform.rotation;
cc.enabled = true;
}
public void UnloadScene(string sceneName)
@@ -46,12 +44,11 @@ namespace Scampz.GameJam
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
{
yield return null;
var loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
loadSceneOperation.allowSceneActivation = false;
while (!loadSceneOperation.isDone)
{
yield return null;
if (loadSceneOperation.progress >= 0.9f)
break;
}
@@ -66,10 +63,5 @@ namespace Scampz.GameJam
if (SceneManager.GetSceneByName(sceneName).IsValid())
SceneManager.UnloadSceneAsync(sceneName);
}
private void OnSceneLoaded(Scene scene, LoadSceneMode loadSceneMode)
{
//BGMManager.Instance.PlaySong();
}
}
}

View File

@@ -0,0 +1,28 @@
using UnityEngine;
public class PlayerSpawnController : MonoBehaviour
{
[SerializeField]
private GameObject _player;
[SerializeField]
private GameObject _playerPrefab;
[SerializeField]
private GameObject _spawnLocation;
void Awake()
{
if (GameObject.FindGameObjectWithTag("Player") != null)
{
_player = GameObject.FindGameObjectWithTag("Player");
_player.transform.position = _spawnLocation.transform.position;
}
else
{
_player = Instantiate(_playerPrefab);
_player.transform.position = _spawnLocation.transform.position;
DontDestroyOnLoad(_player);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 743cce483f727904a87ef002d24ec8d6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 5ca69caac3df3d04f8ea0a8ec6f71eac
guid: 3dba135213b069a44a26fb007ac3b3d9
folderAsset: yes
DefaultImporter:
externalObjects: {}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4f40ea8e04cfa704eb8b1dc96bffb38f
guid: b57ff8788cd779d4d8c417c92aa953e2
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,23 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Scampz.GameJam
{
public class LoadScene : MonoBehaviour
{
private bool loaded = false;
[SerializeField]
private string scene;
[SerializeField]
private Transform _spawnPoint;
void OnTriggerEnter(Collider collider)
{
if (!loaded && collider.CompareTag("Player"))
{
loaded = true;
GameManager.Instance.LoadScene(scene, _spawnPoint, LoadSceneMode.Single);
}
}
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: e6d9a426a8d6e57489b2cd44e9ee79e1
guid: 2f7cf3b0e87656149a3acee1198cb0e0
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -0,0 +1,7 @@
namespace Scampz.GameJam.Assets.Scripts
{
public static class SceneNames
{
public static string Singleton => "Singleton";
}
}

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: d2cf3907882b6304784f4054b05dfabf
guid: ca1d98b6ac872ea419ad6eb89ca8db56
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 6a15b9faa55177745bfc9aa5c273dd2a
guid: 492cbb8b94f132345bc45c0c471d3867
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@@ -1,28 +0,0 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace Scampz.GameJam
{
public class LoadScene : MonoBehaviour
{
private bool loaded = false;
public Transform spawnPoint;
[SerializeField]
private string scene;
void OnTriggerEnter(Collider collider)
{
if (!loaded)
{
loaded = true;
var player = GameObject.FindWithTag("Player");
var cc = player.GetComponent<CharacterController>();
cc.enabled = false;
GameManager.Instance.LoadScene(scene, LoadSceneMode.Additive);
player.transform.position = spawnPoint.position;
player.transform.rotation = spawnPoint.rotation;
cc.enabled = true;
}
}
}
}

View File

@@ -1,19 +0,0 @@
namespace Scampz.GameJam.Assets.Scripts
{
public static class SceneNames
{
public static string TempleA => "TempleA";
public static string TempleB => "TempleB";
public static string TempleC => "TempleC";
public static string TempleSanctum => "TempleSanctum";
public static string TitleScreenScene => "TitleScreen";
public static string Singleton => "Singleton";
public static string WorldMap => "WorldMap";
}
}

View File

@@ -10,7 +10,7 @@ namespace Scampz.GameJam
{
if (Input.GetButtonDown(InputOptions.Submit))
{
GameManager.Instance.LoadScene(SceneNames.Singleton, LoadSceneMode.Single);
GameManager.Instance.LoadScene(SceneNames.Singleton, transform, LoadSceneMode.Single);
}
}
}

View File

@@ -0,0 +1,12 @@
using UnityEngine;
namespace Scampz.GameJam
{
public class Singleton : MonoBehaviour
{
void Awake()
{
DontDestroyOnLoad(gameObject);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e97625dba1d482e4eb29baa8830194de
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: