2021-03-02 19:27:51 +01:00
|
|
|
using System;
|
2021-03-01 19:09:21 +01:00
|
|
|
using Ktyl.Util;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
2021-03-02 17:33:31 +01:00
|
|
|
using UnityEngine.InputSystem;
|
|
|
|
using UnityEngine.UI;
|
2021-03-01 19:09:21 +01:00
|
|
|
|
|
|
|
public class PickUpDisplay : MonoBehaviour
|
|
|
|
{
|
|
|
|
public bool paused => _paused;
|
|
|
|
[SerializeField] private static bool _paused;
|
|
|
|
|
|
|
|
[SerializeField] private GameObject artefactUI;
|
2021-03-02 17:33:31 +01:00
|
|
|
[SerializeField] private Text artefactText;
|
2021-03-02 19:27:51 +01:00
|
|
|
[SerializeField] private DialogueSystem dialogue;
|
2021-03-05 14:26:15 +01:00
|
|
|
[SerializeField] private ArtefactSystem artefacts;
|
2021-03-11 14:31:35 +01:00
|
|
|
[SerializeField] private ArtefactPreview _preview;
|
2021-03-01 19:09:21 +01:00
|
|
|
|
2021-03-11 14:12:19 +01:00
|
|
|
[SerializeField]
|
|
|
|
private GameEvent _uiOpen;
|
|
|
|
|
|
|
|
[SerializeField]
|
|
|
|
private GameEvent _uiClose;
|
|
|
|
|
2021-03-02 17:33:31 +01:00
|
|
|
private Artefact chosenArtefact;
|
|
|
|
|
2021-03-05 14:26:15 +01:00
|
|
|
private void Start()
|
2021-03-01 19:09:21 +01:00
|
|
|
{
|
|
|
|
EventHandler.current.onArtefactUI += PopUpOn;
|
|
|
|
}
|
2021-03-02 17:33:31 +01:00
|
|
|
|
2021-03-05 14:26:15 +01:00
|
|
|
private void Update()
|
2021-03-02 17:33:31 +01:00
|
|
|
{
|
2021-03-05 14:26:15 +01:00
|
|
|
var artefact = artefacts.GetNearbyArtefact();
|
|
|
|
if (!artefact) return;
|
|
|
|
|
|
|
|
chosenArtefact = artefact;
|
2021-03-02 17:33:31 +01:00
|
|
|
}
|
|
|
|
|
2021-03-01 19:09:21 +01:00
|
|
|
public void PopUpOn()
|
|
|
|
{
|
|
|
|
_paused = true;
|
|
|
|
artefactUI.SetActive(true);
|
2021-03-11 14:12:19 +01:00
|
|
|
artefactText.text = chosenArtefact.Name;
|
|
|
|
// inputSettings.updateMode = (InputSettings.UpdateMode)1;
|
2021-03-11 14:31:35 +01:00
|
|
|
dialogue.PlayLine( chosenArtefact.dialogueKey );
|
|
|
|
_preview.Preview( chosenArtefact.Prefab );
|
2021-03-11 14:12:19 +01:00
|
|
|
|
|
|
|
_uiOpen.Raise();
|
2021-03-01 19:09:21 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void PopUpOff()
|
|
|
|
{
|
|
|
|
_paused = false;
|
2021-03-11 14:31:35 +01:00
|
|
|
artefactUI.SetActive( false );
|
2021-03-11 16:50:19 +01:00
|
|
|
_preview.Dismiss();
|
2021-03-11 14:12:19 +01:00
|
|
|
// inputSettings.updateMode = (InputSettings.UpdateMode)2;
|
2021-03-02 19:27:51 +01:00
|
|
|
chosenArtefact = null;
|
2021-03-11 14:12:19 +01:00
|
|
|
|
|
|
|
_uiClose.Raise();
|
2021-03-01 19:09:21 +01:00
|
|
|
}
|
|
|
|
}
|