38 lines
898 B
C#
38 lines
898 B
C#
using Scampz.GameJam.Assets.Scripts;
|
|
using UnityEngine;
|
|
|
|
namespace Scampz.GameJam
|
|
{
|
|
public class PromptDialogue : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private DialogueTrigger _dialogueTrigger;
|
|
|
|
private bool _isWithinRange = false;
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
_isWithinRange = true;
|
|
}
|
|
|
|
private void OnTriggerExit(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
_isWithinRange = false;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (_isWithinRange && Input.GetButtonDown(InputOptions.Submit) && !DialogueManager.Instance.IsTalking)
|
|
{
|
|
var player = GameObject.FindGameObjectWithTag("Player");
|
|
var cc = player.GetComponent<CharacterController>();
|
|
cc.enabled = false;
|
|
_dialogueTrigger.TriggerDialogue();
|
|
cc.enabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|