Files
Scampz/Assets/Scripts/Dialogue/PromptDialogue.cs
Zenny b907cdcd9b Bug Fixes from v1.0
- Fix lighting on desert
- Move dialogue radius to correct spot
- Disable movement while talking to NPCs
- Move desert spawn point a little bit
2022-08-31 22:56:09 -07:00

54 lines
1.2 KiB
C#

using Scampz.GameJam.Assets.Scripts;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Scampz.GameJam
{
public class PromptDialogue : MonoBehaviour
{
[SerializeField]
private DialogueTrigger _dialogueTrigger;
private bool _isWithinRange = false;
private InputAction confirmAction;
void Start()
{
confirmAction = new InputAction("confirm", binding: "<Keyboard>/x");
confirmAction.AddBinding("<GamePad>/buttonSouth");
confirmAction.Enable();
}
private void OnDisable()
{
confirmAction.Disable();
}
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 && confirmAction.triggered && !DialogueManager.Instance.IsTalking)
{
var player = GameObject.FindGameObjectWithTag("Player");
var inputController = player.GetComponent<CharacterInputController>();
inputController.DisableActions();
_dialogueTrigger.TriggerDialogue();
}
}
}
}