140 lines
3.4 KiB
C#
140 lines
3.4 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class UIFishInspect : MonoBehaviour
|
|
{
|
|
[SerializeField]
|
|
private GameObject _parent;
|
|
|
|
[SerializeField]
|
|
private Transform _camera;
|
|
|
|
[SerializeField]
|
|
private Text _fishNameText;
|
|
|
|
[SerializeField]
|
|
private Text _fishWeightText;
|
|
|
|
[SerializeField]
|
|
private Text _fishLengthText;
|
|
|
|
[SerializeField]
|
|
private Text _fisheryText;
|
|
|
|
[SerializeField]
|
|
private Text _habitatText;
|
|
|
|
[SerializeField]
|
|
private Text _exitTextVR;
|
|
|
|
[SerializeField]
|
|
private string _exitInputVR = "RESET_THROW";
|
|
|
|
[SerializeField]
|
|
private GameObject _inspectNavigationButtons;
|
|
|
|
[SerializeField]
|
|
private GameObject _informationParent;
|
|
|
|
private AquariumController _aquarium;
|
|
|
|
private AudioObject _underwaterAudioObject;
|
|
|
|
private bool _isInformationActive = true;
|
|
|
|
private void Update()
|
|
{
|
|
if (VRManager.IsVROn() && VRInputManager.GetButtonDown(_exitInputVR))
|
|
{
|
|
OnClose();
|
|
}
|
|
}
|
|
|
|
private void LateUpdate()
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
_camera.localPosition = TrophyRoomManager.Instance.trophyPlayerVR.ufpsCamera.transform.localPosition;
|
|
_camera.localRotation = TrophyRoomManager.Instance.trophyPlayerVR.ufpsCamera.transform.localRotation;
|
|
}
|
|
}
|
|
|
|
public void Show(UIFish fish, AquariumController aquarium)
|
|
{
|
|
base.enabled = true;
|
|
_aquarium = aquarium;
|
|
if ((bool)_inspectNavigationButtons)
|
|
{
|
|
_inspectNavigationButtons.SetActive(_aquarium.GetFishNumber() > 1);
|
|
}
|
|
FishManager.FishDefinition fishDefinition = fish.FishKept.GetFishDefinition();
|
|
_fishNameText.text = Utilities.GetTranslation(fishDefinition.fishPrefab.fishName);
|
|
_fishWeightText.text = UtilitiesUnits.GetWeightString(fish.FishKept.weight);
|
|
_fishLengthText.text = UtilitiesUnits.GetLengthString(fish.FishKept.length);
|
|
_fisheryText.text = Utilities.GetTranslation(fish.FishKept.fishery);
|
|
_habitatText.text = Utilities.GetTranslation((!fish.FishKept.isSaltwater) ? "GUI/AQUARIUM/FRESHWATER" : "GUI/AQUARIUM/SALTWATER");
|
|
if (VRManager.IsVROn())
|
|
{
|
|
VRInputManager.ActionDefinition actionDefinition = VRInputManager.Instance.FindAction(_exitInputVR);
|
|
List<VRInputManager.ButtonDefinition> currentButtonDefinitions = VRInputManager.GetCurrentButtonDefinitions(actionDefinition);
|
|
string[] array = new string[currentButtonDefinitions.Count];
|
|
for (int i = 0; i < currentButtonDefinitions.Count; i++)
|
|
{
|
|
array[i] = GetButtonString(currentButtonDefinitions[i].button);
|
|
}
|
|
_exitTextVR.text = string.Format("{0} - {1}", array.JoinToString(", "), Utilities.GetTranslation("GUI/BTN_EXIT"));
|
|
}
|
|
_parent.SetActive(true);
|
|
if ((bool)_camera)
|
|
{
|
|
_camera.gameObject.SetActive(true);
|
|
}
|
|
if (!_underwaterAudioObject)
|
|
{
|
|
_underwaterAudioObject = AudioController.Play("Ambient_Underwater_01");
|
|
}
|
|
else
|
|
{
|
|
_underwaterAudioObject.Play(0.3f);
|
|
}
|
|
}
|
|
|
|
private string GetButtonString(OVRInput.Button button)
|
|
{
|
|
return OVRInput.ResolveToRawMask(button).ToString();
|
|
}
|
|
|
|
public void Hide()
|
|
{
|
|
_parent.SetActive(false);
|
|
if ((bool)_camera)
|
|
{
|
|
_camera.gameObject.SetActive(false);
|
|
}
|
|
if ((bool)_underwaterAudioObject)
|
|
{
|
|
_underwaterAudioObject.Pause();
|
|
}
|
|
}
|
|
|
|
public void OnClose()
|
|
{
|
|
base.enabled = false;
|
|
_aquarium.OnCloseInspectFish();
|
|
if ((bool)_underwaterAudioObject)
|
|
{
|
|
_underwaterAudioObject.Pause();
|
|
}
|
|
}
|
|
|
|
public void ToggleInformation()
|
|
{
|
|
if ((bool)_informationParent)
|
|
{
|
|
_informationParent.SetActive(!_isInformationActive);
|
|
_isInformationActive = !_isInformationActive;
|
|
}
|
|
}
|
|
}
|