238 lines
5.7 KiB
C#
238 lines
5.7 KiB
C#
using System.Collections.Generic;
|
|
using BitStrap;
|
|
using UnityEngine;
|
|
|
|
public class TrophyRoomManager : MonoBehaviour
|
|
{
|
|
private static TrophyRoomManager instance;
|
|
|
|
public static bool isInTrophyRoom;
|
|
|
|
public bool showAll;
|
|
|
|
public GameObject everythingParent;
|
|
|
|
public TrophyRoomPlayer trophyPlayer;
|
|
|
|
public TrophyRoomPlayer trophyPlayerVR;
|
|
|
|
public Texture2D aquariumImage;
|
|
|
|
public Texture2D aquariumVRImage;
|
|
|
|
public Material aquariumSignMaterial;
|
|
|
|
public TrophyRoomGUI trophyRoomGUI;
|
|
|
|
public Material[] _aquariumMaterials;
|
|
|
|
public float refractionAmount = 0.02f;
|
|
|
|
[HideInInspector]
|
|
public GlobalSettings globalSettings;
|
|
|
|
[ReadOnly]
|
|
public List<TrophyFishHolder> trophyFishHolders = new List<TrophyFishHolder>();
|
|
|
|
public List<GameObject> quickJumpPoints = new List<GameObject>();
|
|
|
|
private int currentQuickJump;
|
|
|
|
[Space(10f)]
|
|
public GameObject aquariumParent;
|
|
|
|
public GameObject exitInteract;
|
|
|
|
public GameObject fishDLCParent;
|
|
|
|
public List<Transform> doors = new List<Transform>();
|
|
|
|
public List<Transform> aquariumDoors = new List<Transform>();
|
|
|
|
public GameObject aquariumRoom;
|
|
|
|
public FishingWaterSystem.WaterSystemType waterType;
|
|
|
|
public FishingWaterSystem.WaterSystemType vrWaterType;
|
|
|
|
public GameObject crestWater;
|
|
|
|
public static TrophyRoomManager Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private TrophyRoomManager()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
trophyPlayer.gameObject.SetActive(false);
|
|
trophyPlayer = trophyPlayerVR;
|
|
VRManager.Instance.TurnOnUIController(false);
|
|
VRControllersManager.Instance.ShowHandsQuick(VRControllersManager.Instance.handsVisible);
|
|
}
|
|
else
|
|
{
|
|
trophyPlayerVR.gameObject.SetActive(false);
|
|
}
|
|
Cursor.lockState = CursorLockMode.Locked;
|
|
Cursor.visible = false;
|
|
showAll = false;
|
|
AudioController.PauseMusic(1f);
|
|
if ((bool)RadioManager.Instance)
|
|
{
|
|
RadioManager.Instance.Stop();
|
|
}
|
|
InitializeWater();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
if ((bool)GlobalSettings.Instance)
|
|
{
|
|
globalSettings = GlobalSettings.Instance;
|
|
}
|
|
GameObject[] array = MultiTags.FindGameObjectsWithMultiTag("TROPHY_FISH_HOLDER");
|
|
GameObject[] array2 = array;
|
|
foreach (GameObject gameObject in array2)
|
|
{
|
|
trophyFishHolders.Add(gameObject.GetComponent<TrophyFishHolder>());
|
|
}
|
|
RefreshAllFishHolders();
|
|
QualitySettings.shadowDistance = 30f;
|
|
QualitySettings.shadowCascade2Split = 0.35f;
|
|
Vector3 zero = Vector3.zero;
|
|
zero.x = 0.1f;
|
|
zero.y = 0.25f;
|
|
zero.z = 0.467f;
|
|
QualitySettings.shadowCascade4Split = zero;
|
|
InitializeAquarium();
|
|
if ((bool)DLCManager.Instance && !DLCManager.Instance.IsDLCInstalled(DLCManager.DLC_ID.FISH_01))
|
|
{
|
|
fishDLCParent.SetActive(false);
|
|
}
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)BugReporter.Instance && BugReporter.Instance.isVisible)
|
|
{
|
|
return;
|
|
}
|
|
if (UtilitiesInput.GetButtonDown("PAUSE") && !trophyRoomGUI.TryClose())
|
|
{
|
|
EnterTrophyRoom(false);
|
|
}
|
|
else if (GlobalSettings.Instance == null || ((bool)GlobalSettings.Instance && GlobalSettings.Instance.turnOnCheats))
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.Tab))
|
|
{
|
|
Cursor.lockState = (Cursor.visible ? CursorLockMode.Locked : CursorLockMode.None);
|
|
Cursor.visible = !Cursor.visible;
|
|
trophyPlayer.ufpsInput.AllowGameplayInput = !Cursor.visible;
|
|
trophyPlayer.ufpsCamera.freezeInput = Cursor.visible;
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.F9))
|
|
{
|
|
showAll = !showAll;
|
|
RefreshAllFishHolders();
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.F11))
|
|
{
|
|
ResizeAllFishHolders(true);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.F12))
|
|
{
|
|
ResizeAllFishHolders(false);
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.F10))
|
|
{
|
|
QuickJump();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void InitializeWater()
|
|
{
|
|
FishingWaterSystem.WaterSystemType waterSystemType = ((!VRManager.IsVROn()) ? waterType : vrWaterType);
|
|
}
|
|
|
|
private void InitializeAquarium()
|
|
{
|
|
bool flag = true;
|
|
aquariumSignMaterial.mainTexture = ((!VRManager.IsVROn()) ? aquariumImage : aquariumVRImage);
|
|
aquariumParent.SetActive(flag);
|
|
if (!flag)
|
|
{
|
|
return;
|
|
}
|
|
exitInteract.SetActive(false);
|
|
doors[0].localEulerAngles = new Vector3(doors[0].localEulerAngles.x, -80f, doors[0].localEulerAngles.z);
|
|
doors[1].localEulerAngles = new Vector3(doors[1].localEulerAngles.x, 80f, doors[1].localEulerAngles.z);
|
|
bool flag2 = DLCManager.Instance != null && DLCManager.Instance.IsDLCInstalled(DLCManager.DLC_ID.AQUARIUM);
|
|
flag2 |= GlobalSettings.Instance != null && GlobalSettings.Instance.turnOnCheats;
|
|
aquariumRoom.SetActive(flag2);
|
|
if (flag2)
|
|
{
|
|
aquariumDoors[0].localEulerAngles = new Vector3(doors[0].localEulerAngles.x, -80f, doors[0].localEulerAngles.z);
|
|
aquariumDoors[1].localEulerAngles = new Vector3(doors[1].localEulerAngles.x, 80f, doors[1].localEulerAngles.z);
|
|
Material[] aquariumMaterials = _aquariumMaterials;
|
|
foreach (Material material in aquariumMaterials)
|
|
{
|
|
material.SetFloat("_Refraction", (!VRManager.IsVROn()) ? refractionAmount : 0f);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void EnterTrophyRoom(bool enter)
|
|
{
|
|
if (!enter)
|
|
{
|
|
if (VRManager.IsVROn())
|
|
{
|
|
VRManager.Instance.RefreshEyeTextureResolutionScale(true);
|
|
VRManager.Instance.TurnOnUIController(true);
|
|
VRManager.Instance.ShowMenuEnviro(true);
|
|
}
|
|
LoadingManager.LoadScene("MainMenu");
|
|
}
|
|
}
|
|
|
|
public void RefreshAllFishHolders()
|
|
{
|
|
for (int i = 0; i < trophyFishHolders.Count; i++)
|
|
{
|
|
trophyFishHolders[i].Refresh();
|
|
}
|
|
}
|
|
|
|
public void ResizeAllFishHolders(bool maxLength)
|
|
{
|
|
for (int i = 0; i < trophyFishHolders.Count; i++)
|
|
{
|
|
trophyFishHolders[i].Resize(maxLength);
|
|
}
|
|
}
|
|
|
|
public void QuickJump()
|
|
{
|
|
trophyPlayer.GetComponent<vp_FPController>().SetPosition(quickJumpPoints[currentQuickJump].transform.position);
|
|
currentQuickJump++;
|
|
if (currentQuickJump >= quickJumpPoints.Count)
|
|
{
|
|
currentQuickJump = 0;
|
|
}
|
|
}
|
|
}
|