Add prompt to enter levels, add sprint button

This commit is contained in:
2022-08-29 01:43:16 -07:00
parent 571639f8d1
commit 82bf43452b
18 changed files with 1760 additions and 333 deletions

View File

@@ -24,11 +24,14 @@ namespace Scampz.GameJam.Assets.Scripts
void Move()
{
var movementSpeed = Speed;
if (Input.GetButton(InputOptions.Sprint))
movementSpeed *= 2;
var horizontalMovement = Input.GetAxisRaw(InputOptions.Horizontal);
var verticalMovement = Input.GetAxisRaw(InputOptions.Vertical);
var movementDirection = new Vector3(-horizontalMovement, 0, -verticalMovement);
var magnitude = Mathf.Clamp01(movementDirection.magnitude) * Speed;
var magnitude = Mathf.Clamp01(movementDirection.magnitude) * movementSpeed;
movementDirection.Normalize();
_ySpeed += Physics.gravity.y * Time.deltaTime;

View File

@@ -9,5 +9,7 @@
public static string Submit => "Submit";
public static string Cancel => "Cancel";
public static string Sprint => "Sprint";
}
}

View File

@@ -1,3 +1,5 @@
using Scampz.GameJam.Assets.Scripts;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
@@ -5,19 +7,44 @@ namespace Scampz.GameJam
{
public class LoadScene : MonoBehaviour
{
private bool loaded = false;
private bool _loaded = false;
[SerializeField]
private string scene;
private string _scene;
[SerializeField]
private Transform _spawnPoint;
[SerializeField]
private bool _promptToEnter;
[SerializeField]
private TextMeshProUGUI _promptText;
void OnTriggerEnter(Collider collider)
{
if (!loaded && collider.CompareTag("Player"))
if (!_loaded && collider.CompareTag("Player"))
{
loaded = true;
GameManager.Instance.LoadScene(scene, _spawnPoint, LoadSceneMode.Single);
if (_promptToEnter)
_promptText.enabled = true;
if (!_promptToEnter)
LoadNextLevel();
}
}
private void OnTriggerStay(Collider collider)
{
if (!_loaded && collider.CompareTag("Player") && _promptText != null && _promptText.enabled && Input.GetButtonDown(InputOptions.Submit))
LoadNextLevel();
}
private void OnTriggerExit(Collider collider)
{
if (_promptToEnter && collider.CompareTag("Player"))
_promptText.enabled = false;
}
private void LoadNextLevel()
{
_loaded = true;
GameManager.Instance.LoadScene(_scene, _spawnPoint, LoadSceneMode.Single);
}
}
}