Add prompt to enter levels, add sprint button
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -9,5 +9,7 @@
|
||||
public static string Submit => "Submit";
|
||||
|
||||
public static string Cancel => "Cancel";
|
||||
|
||||
public static string Sprint => "Sprint";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user