Files
HauntedBloodlines/Assets/Scripts/Examine/ExaminableItemData.cs
2025-05-29 22:31:40 +03:00

131 lines
4.9 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
using TMPro;
using UnityEngine.Serialization;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.Localization;
public class ExaminableItemData : MonoBehaviour
{
//public GameObject ExamineCamera;
public GameObject ItemsExaminationPos;
public Transform ItemLerpPosition;
public Light examinationPointLight;
public uint renderingLayerMask = 1; // Set in the Unity Editor, default is the first layer
public bool IsExamining;
[SerializeField] private Volume postProcess;
//private DepthOfField depthOfField;
public bool CanInteractWithInteractableItem;
[Header("Object Name Text")]
[Tooltip("Here you declare The object's name text")]
public TextMeshProUGUI nameText; //The object's name text that will appear in the screen from the canvas.
public LocalizedString localizedNameText;
[Header("Object Sentences Text")]
[Tooltip("Here you declare The object's sentences text")]
public TextMeshProUGUI sentencesText; //The object's sentences text that will appear in the screen from the canvas.
public LocalizedString localizedSentencesText;
public Animator examinationUIAnimator;
[Header("Diary Entry Sentences")]
[Tooltip("Here will appear the text of the diary on the screen")]
public GameObject diaryScrollView;
public TextMeshProUGUI diaryText;
public RectTransform diaryScrollViewContent;
[Header("GetItemUI")]
public GameObject pressEToGetItemUI;
public TextMeshProUGUI itemInteractionMessage;
private static ExaminableItemData _instance;
public static ExaminableItemData GetInstance() { return _instance; }
//private void OnValidate()
//{
// GameObject playerGo = PlayerManager.GetInstance().playerGameObj;
// if (ItemsExaminationPos == null)
// {
// //Gets the gameobject in the children of the playerGameObj:
// ItemsExaminationPos = playerGo.transform.Find("Main Camera/ItemsExaminationPos").gameObject;
// }
// else
// {
// Debug.LogError("No GameObject with name " + "ItemsExaminationPos" + " found in the scene.");
// }
// if (ItemLerpPosition == null)
// { //Gets the transform in the children of the playerGameObj:
// ItemLerpPosition = playerGo.transform.Find("Main Camera/ItemsExaminationPos/ItemExamPosition");
// }
// else
// {
// Debug.LogError("No GameObject with name " + "ItemExamPosition" + " found in the scene.");
// }
// if (examinationPointLight == null)
// { //Gets the transform in the children of the playerGameObj:
// examinationPointLight = playerGo.transform.Find("CMCameraFPSMain/ExaminationPointLight").GetComponent<Light>();
// }
// else
// {
// Debug.LogError("No GameObject with name " + "ItemExamPosition" + " found in the scene.");
// }
//}
void Awake()
{
if (!_instance)
{
_instance = this;
}
}
private void Start()
{
GameObject playerGo = PlayerManager.GetInstance().playerGameObj;
if (ItemsExaminationPos == null)
{
//Gets the gameobject in the children of the playerGameObj:
ItemsExaminationPos = playerGo.transform.Find("Main Camera/ItemsExaminationPos").gameObject;
}
if (ItemLerpPosition == null)
{ //Gets the transform in the children of the playerGameObj:
ItemLerpPosition = playerGo.transform.Find("Main Camera/ItemsExaminationPos/ItemExamPosition");
}
if (examinationPointLight == null)
{ //Gets the transform in the children of the playerGameObj:
examinationPointLight = playerGo.transform.Find("CMCameraFPSMain/ExaminationPointLight").GetComponent<Light>();
//Closes the active examination point light at awake since it is supposed to stay close when the game starts because there's nothing to examine in order to light it.
examinationPointLight.gameObject.SetActive(false);
}
////Closes the active examination point light at awake since it is supposed to stay close when the game starts because there's nothing to examine in order to light it.
examinationPointLight.gameObject.SetActive(false);
CleanItemInteractionMessage(); //Cleans the item interaction message at start.
}
public void EnableBlur()
{
postProcess.gameObject.SetActive(true);
}
public void DisableBlur()
{
postProcess.gameObject.SetActive(false);
}
public void DisplayItemInteractionMessage(LocalizedString message)
{
itemInteractionMessage.text = message.GetLocalizedString();
}
public void CleanItemInteractionMessage()
{
itemInteractionMessage.text = "";
}
}