Actual Alpha Build
This commit is contained in:
@@ -7,7 +7,6 @@ namespace Scampz.GameJam
|
||||
public class GameManager : MonoBehaviour
|
||||
{
|
||||
public static GameManager Instance;
|
||||
private LevelChanger _levelChanger;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -16,20 +15,26 @@ namespace Scampz.GameJam
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
Instance = this;
|
||||
_levelChanger = GetComponentInChildren<LevelChanger>();
|
||||
}
|
||||
|
||||
|
||||
public void LoadScene(string sceneName, LoadSceneMode loadSceneMode)
|
||||
public void LoadScene(string sceneName, Transform spawnPoint, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
StartCoroutine(LoadSceneAsync(sceneName, loadSceneMode));
|
||||
StartCoroutine(LoadSceneAsync(sceneName, spawnPoint, loadSceneMode));
|
||||
}
|
||||
|
||||
private IEnumerator LoadSceneAsync(string sceneName, LoadSceneMode loadSceneMode)
|
||||
public void LoadFromWorldMap(LoadSceneMode loadSceneMode)
|
||||
{
|
||||
_levelChanger.FadeAnimation();
|
||||
SceneManager.LoadScene("WorldMap", loadSceneMode);
|
||||
}
|
||||
|
||||
private IEnumerator LoadSceneAsync(string sceneName, Transform spawnPoint, LoadSceneMode loadSceneMode)
|
||||
{
|
||||
yield return null;
|
||||
var player = GameObject.FindGameObjectWithTag("Player");
|
||||
var levelChanger = GetComponentInChildren<LevelChanger>();
|
||||
levelChanger.FadeAnimation();
|
||||
yield return null;
|
||||
var loadSceneOperation = SceneManager.LoadSceneAsync(sceneName, loadSceneMode);
|
||||
yield return new WaitForSeconds(3f);
|
||||
@@ -44,6 +49,11 @@ namespace Scampz.GameJam
|
||||
|
||||
loadSceneOperation.allowSceneActivation = true;
|
||||
yield return loadSceneOperation;
|
||||
var cc = player.GetComponent<CharacterController>();
|
||||
cc.enabled = false;
|
||||
player.transform.position = spawnPoint.position;
|
||||
player.transform.rotation = spawnPoint.rotation;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Scampz.GameJam.Assets.Scripts.Player
|
||||
{
|
||||
@@ -21,7 +22,7 @@ namespace Scampz.GameJam.Assets.Scripts.Player
|
||||
_canMove = true;
|
||||
_animator.SetFloat("Speed", _characterController.velocity.magnitude);
|
||||
var rayCasterExists = TryGetComponent<RayCaster>(out var rayCaster);
|
||||
if (rayCasterExists)
|
||||
if (SceneManager.GetActiveScene().name.Equals("WorldMap") && rayCasterExists)
|
||||
_canMove = rayCaster.IsWithinBoundsWithRay();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,13 +8,15 @@ namespace Scampz.GameJam
|
||||
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, LoadSceneMode.Single);
|
||||
GameManager.Instance.LoadScene(scene, _spawnPoint, LoadSceneMode.Single);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace Scampz.GameJam
|
||||
{
|
||||
if (Input.GetButtonDown(InputOptions.Submit))
|
||||
{
|
||||
GameManager.Instance.LoadScene("WorldMap", LoadSceneMode.Single);
|
||||
GameManager.Instance.LoadFromWorldMap(LoadSceneMode.Single);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user