revival/game/Assets/Scripts/Artefacts/PickUpDisplay.cs

57 lines
1.5 KiB
C#

using System;
using Ktyl.Util;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;
public class PickUpDisplay : MonoBehaviour
{
public bool paused => _paused;
[SerializeField] private static bool _paused;
[SerializeField] private GameObject artefactUI;
[SerializeField] private GameObject Player;
[SerializeField] private Text artefactText;
[SerializeField] private InputSettings inputSettings;
[SerializeField] private DialogueSystem dialogue;
[SerializeField] private ArtefactSystem artefacts;
private Artefact chosenArtefact;
private void Start()
{
EventHandler.current.onArtefactUI += PopUpOn;
}
private void Update()
{
var artefact = artefacts.GetNearbyArtefact();
if (!artefact) return;
chosenArtefact = artefact;
}
public void PopUpOn()
{
_paused = true;
artefactUI.SetActive(true);
Player.GetComponent<PlayerInput>().enabled = false;
artefactText.text = "You have unlocked " + chosenArtefact.Name + "!";
inputSettings.updateMode = (InputSettings.UpdateMode)1;
Time.timeScale = 0f;
}
public void PopUpOff()
{
_paused = false;
artefactUI.SetActive(false);
inputSettings.updateMode = (InputSettings.UpdateMode)2;
Player.GetComponent<PlayerInput>().enabled = true;
Time.timeScale = 1.0f;
dialogue.PlayLine(chosenArtefact.dialogueKey);
chosenArtefact = null;
}
}