Add new character model, add title screen
This commit is contained in:
@@ -1,56 +0,0 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class CharacterManager : MonoBehaviour
|
||||
{
|
||||
public static CharacterManager Instance;
|
||||
private bool gameStart;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (!gameStart)
|
||||
{
|
||||
Instance = this;
|
||||
LoadScene(0, LoadSceneMode.Additive);
|
||||
gameStart = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadScene(int levelIndex, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(levelIndex, loadSceneMode));
|
||||
}
|
||||
|
||||
public void UnloadScene(int levelIndex)
|
||||
{
|
||||
StartCoroutine(UnloadSceneAsync(levelIndex));
|
||||
}
|
||||
|
||||
IEnumerator LoadSceneAsync(int levelIndex, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
var loadSceneOperation = SceneManager.LoadSceneAsync(levelIndex, loadSceneMode);
|
||||
loadSceneOperation.allowSceneActivation = false;
|
||||
while (!loadSceneOperation.isDone)
|
||||
{
|
||||
if (loadSceneOperation.progress >= 0.9f)
|
||||
break;
|
||||
}
|
||||
|
||||
loadSceneOperation.allowSceneActivation = true;
|
||||
yield return loadSceneOperation;
|
||||
}
|
||||
|
||||
IEnumerator UnloadSceneAsync(int levelIndex)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
SceneManager.UnloadSceneAsync(levelIndex);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
86
Assets/Scripts/GameManager.cs
Normal file
86
Assets/Scripts/GameManager.cs
Normal file
@@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using Scampz.GameJam.Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadScene(int levelIndex, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(levelIndex, loadSceneMode));
|
||||
}
|
||||
|
||||
public void UnloadScene(int levelIndex)
|
||||
{
|
||||
StartCoroutine(UnloadSceneAsync(levelIndex));
|
||||
}
|
||||
|
||||
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
|
||||
}
|
||||
|
||||
public void UnloadScene(string sceneName)
|
||||
{
|
||||
StartCoroutine(UnloadSceneAsync(sceneName));
|
||||
}
|
||||
|
||||
IEnumerator LoadSceneAsync(int levelIndex, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
var loadSceneOperation = SceneManager.LoadSceneAsync(levelIndex, loadSceneMode);
|
||||
loadSceneOperation.allowSceneActivation = false;
|
||||
while (!loadSceneOperation.isDone)
|
||||
{
|
||||
if (loadSceneOperation.progress >= 0.9f)
|
||||
break;
|
||||
}
|
||||
|
||||
loadSceneOperation.allowSceneActivation = true;
|
||||
yield return loadSceneOperation;
|
||||
}
|
||||
|
||||
private IEnumerator UnloadSceneAsync(int levelIndex)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
SceneManager.UnloadSceneAsync(levelIndex);
|
||||
}
|
||||
|
||||
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
yield return null;
|
||||
var loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
|
||||
loadSceneOperation.allowSceneActivation = false;
|
||||
while (!loadSceneOperation.isDone)
|
||||
{
|
||||
if (loadSceneOperation.progress >= 0.9f)
|
||||
break;
|
||||
}
|
||||
|
||||
loadSceneOperation.allowSceneActivation = true;
|
||||
yield return loadSceneOperation;
|
||||
}
|
||||
|
||||
private IEnumerator UnloadSceneAsync(string sceneName)
|
||||
{
|
||||
yield return null;
|
||||
|
||||
SceneManager.UnloadSceneAsync(sceneName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
public static string Horizontal => "Horizontal";
|
||||
|
||||
public static string Interact => "Interact";
|
||||
public static string Submit => "Submit";
|
||||
|
||||
public static string Cancel => "Cancel";
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace Scampz.GameJam
|
||||
{
|
||||
loaded = true;
|
||||
|
||||
CharacterManager.Instance.LoadScene(sceneIndex, LoadSceneMode.Additive);
|
||||
GameManager.Instance.LoadScene(sceneIndex, LoadSceneMode.Additive);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
25
Assets/Scripts/SceneNames.cs
Normal file
25
Assets/Scripts/SceneNames.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace Scampz.GameJam.Assets.Scripts
|
||||
{
|
||||
public static class SceneNames
|
||||
{
|
||||
public static string FirstPreRenderedScene => "Pre-Render0";
|
||||
|
||||
public static string SecondPreRenderedScene => "Pre-Render1";
|
||||
|
||||
public static string ThirdPreRenderedScene => "Pre-Render2";
|
||||
|
||||
public static string FourthPreRenderedScene => "Pre-Render3";
|
||||
|
||||
public static string FifthPreRenderedScene => "Pre-Render4";
|
||||
|
||||
public static string SixthPreRenderedScene => "Pre-Render5";
|
||||
|
||||
public static string SeventhPreRenderedScene => "Pre-Render6";
|
||||
|
||||
public static string EightPreRenderedScene => "Pre-Render8";
|
||||
|
||||
public static string TitleScreenScene => "TitleScreen";
|
||||
|
||||
public static string BaseScene => "BaseScene";
|
||||
}
|
||||
}
|
||||
18
Assets/Scripts/TitleScreen.cs
Normal file
18
Assets/Scripts/TitleScreen.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using Scampz.GameJam.Assets.Scripts;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Scampz.GameJam
|
||||
{
|
||||
public class TitleScreen : MonoBehaviour
|
||||
{
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetButtonDown(InputOptions.Submit))
|
||||
{
|
||||
GameManager.Instance.LoadScene(SceneNames.BaseScene, LoadSceneMode.Single);
|
||||
GameManager.Instance.LoadScene(SceneNames.FirstPreRenderedScene, LoadSceneMode.Additive);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ namespace Scampz.GameJam
|
||||
{
|
||||
unloaded = true;
|
||||
|
||||
CharacterManager.Instance.UnloadScene(scene);
|
||||
GameManager.Instance.UnloadScene(scene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user