1035 lines
25 KiB
C#
1035 lines
25 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Security.Principal;
|
|
using BitStrap;
|
|
using CodeStage.AdvancedFPSCounter;
|
|
using CurvedUI;
|
|
using UnityEngine;
|
|
using UnityEngine.EventSystems;
|
|
using UnityEngine.UI;
|
|
|
|
public class MenuManager : MonoBehaviour
|
|
{
|
|
public enum MenuState
|
|
{
|
|
MAIN_MENU = 0,
|
|
PROFILES = 1,
|
|
LEVELS = 2,
|
|
INVENTORY = 3,
|
|
OPTIONS = 4,
|
|
CREDITS = 5,
|
|
ACHIEVEMENTS = 6,
|
|
TOURNAMENT = 7,
|
|
GAME_MODES_1 = 8,
|
|
GAME_MODES_2 = 9,
|
|
PROFILE_SCREEN = 10,
|
|
ENCYCLOPEDIA = 11,
|
|
LEADERBOARDS = 12,
|
|
MODEL_VIEWER = 13,
|
|
HELP = 14,
|
|
CHANGELOG = 15,
|
|
PLAYERS = 16,
|
|
RADIO = 17,
|
|
DLC = 18,
|
|
UNKNOWN = 19
|
|
}
|
|
|
|
public enum ChangeType
|
|
{
|
|
Show = 0,
|
|
Hide = 1,
|
|
Toggle = 2,
|
|
Nothing = 3
|
|
}
|
|
|
|
public enum CameraPosition
|
|
{
|
|
START = 0,
|
|
MISSIONS = 1,
|
|
EOD = 2,
|
|
MINI = 3,
|
|
DRONE = 4,
|
|
SUB = 5
|
|
}
|
|
|
|
private static MenuManager instance;
|
|
|
|
[ReadOnly]
|
|
public MenuState currentState = MenuState.UNKNOWN;
|
|
|
|
[ReadOnly]
|
|
public MenuState prevState = MenuState.UNKNOWN;
|
|
|
|
public bool dontDestroyOnLoad;
|
|
|
|
[Header("Test", order = 0)]
|
|
[HelpBox("Test", HelpBoxAttribute.MessageType.Info, order = 1)]
|
|
public GameObject menuParent;
|
|
|
|
public Canvas commonButtons;
|
|
|
|
public Canvas[] gamePanels = new Canvas[19];
|
|
|
|
public Text lblPanelName;
|
|
|
|
public GameObject logo;
|
|
|
|
public Image pauseBackground;
|
|
|
|
public GameObject topPanel;
|
|
|
|
public List<Transform> cameraPositions = new List<Transform>();
|
|
|
|
[HideInInspector]
|
|
public CameraPosition currentCameraPosition;
|
|
|
|
public ModelViewerManager modelViewerManager;
|
|
|
|
[ReadOnly]
|
|
public bool firstUpdate = true;
|
|
|
|
[HideInInspector]
|
|
public static MenuState prevMenuState = MenuState.GAME_MODES_1;
|
|
|
|
[Header("Background")]
|
|
public Image backgroundBack;
|
|
|
|
public Image backgroundFront;
|
|
|
|
public List<Sprite> backgroundTextures = new List<Sprite>();
|
|
|
|
public int currentBackground;
|
|
|
|
public float backgroundStayTime = 10f;
|
|
|
|
public float backgroundFadeTime = 3f;
|
|
|
|
public AzureSky_Controller[] azureSkyControllers;
|
|
|
|
[ReadOnly]
|
|
public RefreshMenuObject[] refreshMenuObjects;
|
|
|
|
[ReadOnly]
|
|
public int currentCategoryButton;
|
|
|
|
public List<Button> categoryButtons = new List<Button>();
|
|
|
|
public List<Button> categoryDontInvokeButtons = new List<Button>();
|
|
|
|
public List<MenuState> categoryToState = new List<MenuState>();
|
|
|
|
public List<GameObject> backgroundObjectsToHide = new List<GameObject>();
|
|
|
|
public List<Scrollbar> rightStickScrollbars = new List<Scrollbar>();
|
|
|
|
public float rightStickScrollbarSpeed = 0.05f;
|
|
|
|
public Button equipmentButton;
|
|
|
|
[Header("VR Changes")]
|
|
public Vector3 commonCanvasPosVR = Vector3.zero;
|
|
|
|
public Vector2 commonCanvasSizeVR = Vector2.zero;
|
|
|
|
[ReadOnly]
|
|
[Header("Test")]
|
|
public int currentTestCounter;
|
|
|
|
public Camera guiCamera;
|
|
|
|
public GameObject gameCamera;
|
|
|
|
public bool clearWaterTextures = true;
|
|
|
|
public int systemScreenWidth = 1920;
|
|
|
|
public int systemScreenHeight = 1080;
|
|
|
|
public static MenuManager Instance
|
|
{
|
|
get
|
|
{
|
|
return instance;
|
|
}
|
|
}
|
|
|
|
private MenuManager()
|
|
{
|
|
}
|
|
|
|
private void Awake()
|
|
{
|
|
currentState = (prevState = MenuState.UNKNOWN);
|
|
if (VRManager.IsVROn())
|
|
{
|
|
OVRInput.canChangeGamepad = true;
|
|
}
|
|
if (instance == null)
|
|
{
|
|
instance = this;
|
|
if (dontDestroyOnLoad)
|
|
{
|
|
UnityEngine.Object.DontDestroyOnLoad(base.gameObject);
|
|
}
|
|
modelViewerManager.gameObject.SetActive(true);
|
|
refreshMenuObjects = GetComponentsInChildren<RefreshMenuObject>(true);
|
|
RefreshMenuObjects();
|
|
}
|
|
else
|
|
{
|
|
instance.RefreshInstance();
|
|
instance.RefreshMenuObjects();
|
|
if (!RadioManager.Instance.isSetToPlay)
|
|
{
|
|
AudioController.UnpauseMusic();
|
|
}
|
|
else if (!RadioManager.Instance.isPlaying)
|
|
{
|
|
RadioManager.Instance.Play();
|
|
}
|
|
UnityEngine.Object.DestroyImmediate(base.gameObject);
|
|
}
|
|
instance.pauseBackground.gameObject.SetActive(false);
|
|
GlobalSettings.Instance.ShowInfo(true);
|
|
QualitySettings.shadowDistance = 50f;
|
|
QualitySettings.shadowCascade2Split = 0.33f;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
WindowMod.GetCurrentSettings();
|
|
GlobalSettings.Instance.ShowInfo(true);
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
GlobalSettings.Instance.ShowInfo(false);
|
|
}
|
|
|
|
[Button]
|
|
public void ChangeSystemResolution()
|
|
{
|
|
WindowMod.ChangeDisplaySettings(systemScreenWidth, systemScreenHeight);
|
|
}
|
|
|
|
public void RefreshInstance()
|
|
{
|
|
if ((bool)VRManager.Instance && VRManager.IsVROn())
|
|
{
|
|
VRManager.Instance.TurnOnUIController(true);
|
|
VRManager.Instance.ShowMenuEnviro(true);
|
|
VRControllersManager.Instance.ShowHandsQuick(VRControllersManager.Instance.handsVisible);
|
|
VRManager.Instance.eyeCenterTransform.GetComponent<Camera>().farClipPlane = VRManager.Instance.eyeCenterTransform.GetComponent<Camera>().nearClipPlane + 0.01f;
|
|
VRManager.Instance.eyeCenterTransform.GetComponent<Camera>().clearFlags = CameraClearFlags.Color;
|
|
LeanTween.delayedCall(1f, (Action)delegate
|
|
{
|
|
VRManager.Instance.eyeCenterTransform.GetComponent<Camera>().farClipPlane = 30f;
|
|
VRManager.Instance.eyeCenterTransform.GetComponent<Camera>().clearFlags = CameraClearFlags.Skybox;
|
|
});
|
|
}
|
|
if ((bool)VRManager.Instance && !VRManager.IsVROn())
|
|
{
|
|
VRManager.Instance.SetCurvedUI(false, true);
|
|
}
|
|
for (int num = 0; num < 19; num++)
|
|
{
|
|
gamePanels[num].gameObject.SetActive(false);
|
|
}
|
|
instance.prevState = MenuState.UNKNOWN;
|
|
instance.gameObject.SetActive(true);
|
|
if (GlobalSettings.Instance.saveManager.isProfileLoaded && !EquipmentPreviewManager.wasInEquipmentTest)
|
|
{
|
|
if (GlobalSettings.Instance.levelsManager.isTournament && LoadingManager.chosenLevelPrev != "TrophyRoom" && LoadingManager.chosenLevelPrev != "FisheryEditor")
|
|
{
|
|
ChangeState(MenuState.TOURNAMENT);
|
|
}
|
|
else
|
|
{
|
|
ChangeState(MenuState.LEVELS);
|
|
}
|
|
prevState = MenuState.UNKNOWN;
|
|
}
|
|
else
|
|
{
|
|
EquipmentPreviewManager.wasInEquipmentTest = false;
|
|
ChangeState(MenuState.PROFILES);
|
|
}
|
|
FishingPlayer.playerWasInBoat = false;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
Cursor.visible = true;
|
|
GlobalSettings.Instance.levelsManager.multiRoomName = string.Empty;
|
|
instance.azureSkyControllers = UnityEngine.Object.FindObjectsOfType<AzureSky_Controller>();
|
|
for (int num2 = 0; num2 < azureSkyControllers.Length; num2++)
|
|
{
|
|
instance.azureSkyControllers[num2].makeUpdate = false;
|
|
}
|
|
GlobalSettings.Instance.renderSettings.OnSceneChanged();
|
|
GlobalSettings.Instance.renderSettings.RefreshAll();
|
|
StartCoroutine(Utilities.CleanUp());
|
|
if (clearWaterTextures)
|
|
{
|
|
Utilities.DestroyWaterTextures();
|
|
}
|
|
Utilities.CheckTextureMemory();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
VRManager.Instance.InitializeMainMenu();
|
|
AudioController.PlayMusic("MenuMusic");
|
|
for (int i = 0; i < 19; i++)
|
|
{
|
|
gamePanels[i].gameObject.SetActive(false);
|
|
}
|
|
if (GlobalSettings.Instance.saveManager.isProfileLoaded && !EquipmentPreviewManager.wasInEquipmentTest)
|
|
{
|
|
ChangeState(MenuState.LEVELS);
|
|
prevState = MenuState.UNKNOWN;
|
|
}
|
|
else
|
|
{
|
|
EquipmentPreviewManager.wasInEquipmentTest = false;
|
|
ChangeState(MenuState.PROFILES);
|
|
Utilities.CheckCommanLineArguments();
|
|
}
|
|
FishingPlayer.playerWasInBoat = false;
|
|
Cursor.lockState = CursorLockMode.None;
|
|
Cursor.visible = true;
|
|
instance.azureSkyControllers = UnityEngine.Object.FindObjectsOfType<AzureSky_Controller>();
|
|
for (int j = 0; j < azureSkyControllers.Length; j++)
|
|
{
|
|
instance.azureSkyControllers[j].makeUpdate = false;
|
|
}
|
|
GlobalSettings.Instance.renderSettings.OnSceneChanged();
|
|
GlobalSettings.Instance.renderSettings.RefreshAll();
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if ((bool)BugReporter.Instance && BugReporter.Instance.isVisible)
|
|
{
|
|
return;
|
|
}
|
|
if (firstUpdate && (!GlobalSettings.Instance.saveManager.isProfileLoaded || GlobalSettings.Instance.currentPlatform == GlobalSettings.Platform.ARCADE))
|
|
{
|
|
firstUpdate = false;
|
|
AFPSCounter aFPSCounter = UnityEngine.Object.FindObjectOfType<AFPSCounter>();
|
|
if ((bool)aFPSCounter)
|
|
{
|
|
aFPSCounter.TurnOffCounter();
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
RectTransform component = topPanel.GetComponent<RectTransform>();
|
|
component.sizeDelta = commonCanvasSizeVR;
|
|
component.anchoredPosition3D = commonCanvasPosVR;
|
|
component.ForceUpdateRectTransforms();
|
|
}
|
|
}
|
|
if (Input.GetKeyDown(KeyCode.Escape))
|
|
{
|
|
}
|
|
if (GlobalSettings.Instance.turnOnCheats && Input.GetKey(KeyCode.LeftControl) && (Input.GetKeyDown(KeyCode.Keypad1) || Input.GetKeyDown(KeyCode.U)))
|
|
{
|
|
guiCamera.enabled = !guiCamera.enabled;
|
|
TutorialManager.Instance.gameObject.SetActive(guiCamera.enabled);
|
|
}
|
|
if (UtilitiesInput.GetButtonDown("CHANGE_CATEGORY_LEFT"))
|
|
{
|
|
ChangeCategory(false);
|
|
}
|
|
else if (UtilitiesInput.GetButtonDown("CHANGE_CATEGORY_RIGHT"))
|
|
{
|
|
ChangeCategory(true);
|
|
}
|
|
if (UtilitiesInput.GetAxis("SCROLLBAR_AXIS") == 0f)
|
|
{
|
|
return;
|
|
}
|
|
for (int i = 0; i < rightStickScrollbars.Count; i++)
|
|
{
|
|
if (rightStickScrollbars[i].gameObject.activeInHierarchy)
|
|
{
|
|
rightStickScrollbars[i].value += UtilitiesInput.GetAxis("SCROLLBAR_AXIS") * rightStickScrollbarSpeed * rightStickScrollbars[i].size;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeState(string stateName)
|
|
{
|
|
if (stateName == "BACK")
|
|
{
|
|
SetPrevState();
|
|
return;
|
|
}
|
|
MenuState menuState = MenuState.UNKNOWN;
|
|
switch (stateName)
|
|
{
|
|
case "MAIN_MENU":
|
|
menuState = MenuState.MAIN_MENU;
|
|
break;
|
|
case "PROFILES":
|
|
menuState = MenuState.PROFILES;
|
|
break;
|
|
case "LEVELS":
|
|
menuState = MenuState.LEVELS;
|
|
break;
|
|
case "INVENTORY":
|
|
menuState = MenuState.INVENTORY;
|
|
break;
|
|
case "OPTIONS":
|
|
menuState = MenuState.OPTIONS;
|
|
break;
|
|
case "CREDITS":
|
|
menuState = MenuState.CREDITS;
|
|
break;
|
|
case "ACHIEVEMENTS":
|
|
menuState = MenuState.ACHIEVEMENTS;
|
|
break;
|
|
case "TOURNAMENT":
|
|
menuState = MenuState.TOURNAMENT;
|
|
break;
|
|
case "GAME_MODES_1":
|
|
menuState = MenuState.GAME_MODES_1;
|
|
break;
|
|
case "GAME_MODES_2":
|
|
menuState = MenuState.GAME_MODES_2;
|
|
break;
|
|
case "PROFILE_SCREEN":
|
|
menuState = MenuState.PROFILE_SCREEN;
|
|
break;
|
|
case "ENCYCLOPEDIA":
|
|
menuState = MenuState.ENCYCLOPEDIA;
|
|
break;
|
|
case "LEADERBOARDS":
|
|
menuState = MenuState.LEADERBOARDS;
|
|
break;
|
|
case "MODEL_VIEWER":
|
|
menuState = MenuState.MODEL_VIEWER;
|
|
break;
|
|
case "HELP":
|
|
menuState = MenuState.HELP;
|
|
break;
|
|
case "CHANGELOG":
|
|
menuState = MenuState.CHANGELOG;
|
|
break;
|
|
case "PLAYERS":
|
|
menuState = MenuState.PLAYERS;
|
|
break;
|
|
case "RADIO":
|
|
menuState = MenuState.RADIO;
|
|
break;
|
|
}
|
|
if (menuState != MenuState.UNKNOWN)
|
|
{
|
|
ChangeState(menuState);
|
|
}
|
|
}
|
|
|
|
public void ChangeCategory(bool next)
|
|
{
|
|
bool flag = false;
|
|
for (int i = 0; i < categoryToState.Count; i++)
|
|
{
|
|
if (categoryButtons[i].gameObject.activeInHierarchy)
|
|
{
|
|
flag = true;
|
|
break;
|
|
}
|
|
}
|
|
if (flag)
|
|
{
|
|
currentCategoryButton += (next ? 1 : (-1));
|
|
if (currentCategoryButton >= categoryButtons.Count)
|
|
{
|
|
currentCategoryButton = 0;
|
|
}
|
|
else if (currentCategoryButton < 0)
|
|
{
|
|
currentCategoryButton = categoryButtons.Count - 1;
|
|
}
|
|
if (categoryButtons[currentCategoryButton].gameObject.activeInHierarchy)
|
|
{
|
|
ChangeCategory(currentCategoryButton);
|
|
}
|
|
else
|
|
{
|
|
ChangeCategory(next);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeCategory(int buttonId)
|
|
{
|
|
currentCategoryButton = buttonId;
|
|
if (!categoryDontInvokeButtons.Contains(categoryButtons[currentCategoryButton]))
|
|
{
|
|
categoryButtons[currentCategoryButton].onClick.Invoke();
|
|
}
|
|
EventSystem.current.SetSelectedGameObject(categoryButtons[currentCategoryButton].gameObject);
|
|
}
|
|
|
|
public void UpdateCurrentCategoryButton()
|
|
{
|
|
for (int i = 0; i < categoryToState.Count; i++)
|
|
{
|
|
if (categoryToState[i] == currentState && i != currentCategoryButton)
|
|
{
|
|
currentCategoryButton = i;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowBackgroundObjects(bool show)
|
|
{
|
|
for (int i = 0; i < backgroundObjectsToHide.Count; i++)
|
|
{
|
|
backgroundObjectsToHide[i].SetActive(show);
|
|
}
|
|
}
|
|
|
|
public void ModelViewerBack()
|
|
{
|
|
if (prevState == MenuState.ENCYCLOPEDIA)
|
|
{
|
|
ChangeState(MenuState.ENCYCLOPEDIA);
|
|
}
|
|
else
|
|
{
|
|
ChangeState(MenuState.INVENTORY);
|
|
}
|
|
}
|
|
|
|
public void ChangeState(MenuState nextState)
|
|
{
|
|
switch (nextState)
|
|
{
|
|
case MenuState.MAIN_MENU:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(true);
|
|
ShowCommonButtons(true);
|
|
break;
|
|
case MenuState.LEVELS:
|
|
lblPanelName.text = "Missions";
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
if (VRManager.IsVROn())
|
|
{
|
|
TutorialManager.Instance.ShowTutorial(TutorialManager.TutorialsId.VR_OPTIONS, 0.5f);
|
|
}
|
|
break;
|
|
case MenuState.OPTIONS:
|
|
lblPanelName.text = "Options";
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.CREDITS:
|
|
lblPanelName.text = "Credits";
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.PROFILES:
|
|
lblPanelName.text = "Profiles";
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
if (GlobalSettings.Instance.saveManager.isProfileLoaded)
|
|
{
|
|
GlobalSettings.Instance.levelsManager.multiRoomName = string.Empty;
|
|
}
|
|
break;
|
|
case MenuState.ACHIEVEMENTS:
|
|
lblPanelName.text = "Achievements";
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.INVENTORY:
|
|
lblPanelName.text = "End Game Screen";
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
TutorialManager.Instance.ShowTutorial(TutorialManager.TutorialsId.EQUIPMENT_01, 0.5f);
|
|
break;
|
|
case MenuState.TOURNAMENT:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
gamePanels[7].GetComponent<FisherySettings>().ShowGlobalTournamentInfoWindow();
|
|
}
|
|
else
|
|
{
|
|
gamePanels[7].GetComponent<FisherySettings>().ShowPlayerTournamentWindow();
|
|
}
|
|
break;
|
|
case MenuState.GAME_MODES_1:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.GAME_MODES_2:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.PROFILE_SCREEN:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
TutorialManager.Instance.ShowTutorial(TutorialManager.TutorialsId.SKILLS_01, 0.5f);
|
|
break;
|
|
case MenuState.ENCYCLOPEDIA:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.LEADERBOARDS:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.MODEL_VIEWER:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
modelViewerManager.ChangeView(true);
|
|
break;
|
|
case MenuState.HELP:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
if (!VRManager.IsVROn())
|
|
{
|
|
TutorialManager.Instance.ShowTutorial(TutorialManager.TutorialsId.START_01, 0.5f);
|
|
}
|
|
break;
|
|
case MenuState.PLAYERS:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.RADIO:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
case MenuState.CHANGELOG:
|
|
lblPanelName.text = string.Empty;
|
|
logo.SetActive(false);
|
|
ShowCommonButtons(false);
|
|
break;
|
|
}
|
|
if (currentState == MenuState.OPTIONS)
|
|
{
|
|
GlobalSettings.Instance.soundSettings.Save();
|
|
GlobalSettings.Instance.renderSettings.Save();
|
|
if (VRManager.IsVROn())
|
|
{
|
|
VRManager.Instance.Save();
|
|
}
|
|
}
|
|
if (currentState == MenuState.MODEL_VIEWER)
|
|
{
|
|
modelViewerManager.ChangeView(false);
|
|
}
|
|
if (currentState < MenuState.UNKNOWN)
|
|
{
|
|
Animator component = gamePanels[(int)currentState].GetComponent<Animator>();
|
|
if (Instance.gameObject.activeSelf && (bool)component)
|
|
{
|
|
if (component.isInitialized)
|
|
{
|
|
component.SetBool("Open", false);
|
|
}
|
|
StartCoroutine(HideState(component));
|
|
}
|
|
else
|
|
{
|
|
gamePanels[(int)currentState].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
if (nextState < MenuState.UNKNOWN)
|
|
{
|
|
Animator component2 = gamePanels[(int)nextState].GetComponent<Animator>();
|
|
gamePanels[(int)nextState].gameObject.SetActive(true);
|
|
if ((bool)component2 && component2.isInitialized)
|
|
{
|
|
component2.SetBool("Open", true);
|
|
}
|
|
}
|
|
topPanel.SetActive(nextState != MenuState.PROFILES);
|
|
prevState = currentState;
|
|
currentState = nextState;
|
|
UpdateCurrentCategoryButton();
|
|
}
|
|
|
|
public void SetPrevState()
|
|
{
|
|
if (prevState != MenuState.UNKNOWN && currentState != MenuState.PROFILES)
|
|
{
|
|
if (currentState == MenuState.MODEL_VIEWER || currentState == MenuState.RADIO || currentState == MenuState.DLC)
|
|
{
|
|
ChangeState(prevState);
|
|
}
|
|
else
|
|
{
|
|
ChangeState(MenuState.MAIN_MENU);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void HideAllStates()
|
|
{
|
|
for (int i = 0; i < gamePanels.Length; i++)
|
|
{
|
|
gamePanels[i].gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public static IEnumerator HideState(Animator anim)
|
|
{
|
|
if (!anim.gameObject.activeSelf)
|
|
{
|
|
yield break;
|
|
}
|
|
bool closedStateReached = false;
|
|
bool wantToClose = true;
|
|
while (!closedStateReached && wantToClose)
|
|
{
|
|
if (!anim.IsInTransition(0))
|
|
{
|
|
closedStateReached = anim.GetCurrentAnimatorStateInfo(0).IsName("Closed");
|
|
}
|
|
wantToClose = !anim.GetBool("Open");
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
if (wantToClose)
|
|
{
|
|
anim.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void ToggleWholeMenu(ChangeType changeType)
|
|
{
|
|
if (changeType != ChangeType.Nothing)
|
|
{
|
|
bool flag = false;
|
|
switch (changeType)
|
|
{
|
|
case ChangeType.Show:
|
|
flag = true;
|
|
break;
|
|
case ChangeType.Hide:
|
|
flag = false;
|
|
break;
|
|
default:
|
|
flag = !menuParent.activeSelf;
|
|
break;
|
|
}
|
|
menuParent.SetActive(flag);
|
|
}
|
|
}
|
|
|
|
public void ShowHelpScreen(int scrennId)
|
|
{
|
|
ChangeState(MenuState.HELP);
|
|
gamePanels[14].GetComponent<HelpManager>().ShowScreen(scrennId);
|
|
}
|
|
|
|
public void ShowMap(bool show)
|
|
{
|
|
if (show)
|
|
{
|
|
if ((bool)MapController.Instance)
|
|
{
|
|
MapController.Instance.ShowMap(show);
|
|
}
|
|
ChangeState(MenuState.HELP);
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
else
|
|
{
|
|
HideAllStates();
|
|
base.gameObject.SetActive(true);
|
|
ChangeState(MenuState.INVENTORY);
|
|
}
|
|
}
|
|
|
|
public void ShowDuringGame(bool show)
|
|
{
|
|
if (show)
|
|
{
|
|
HideAllStates();
|
|
Instance.gameObject.SetActive(true);
|
|
ChangeState(MenuState.INVENTORY);
|
|
RefreshMenuObjects();
|
|
UtilitiesInput.StopVibration();
|
|
}
|
|
else
|
|
{
|
|
Instance.gameObject.SetActive(false);
|
|
ChangeState(MenuState.LEVELS);
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.RefreshBoatsRodStands();
|
|
}
|
|
GlobalSettings.Instance.renderSettings.RefreshAntialiasing();
|
|
}
|
|
if (!VRManager.IsVROn())
|
|
{
|
|
pauseBackground.gameObject.SetActive(show);
|
|
}
|
|
if (VRManager.IsVROn())
|
|
{
|
|
VRManager.Instance.TurnOnUIController(show);
|
|
VRManager.Instance.RefreshEyeTextureResolutionScale(show);
|
|
VRManager.Instance.ShowMenuEnviro(show);
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
GameController.Instance.fishingPlayer.baitIndicatorCamera.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ChangeCameraPosition(CameraPosition newPosition)
|
|
{
|
|
}
|
|
|
|
public void ResumeLevel()
|
|
{
|
|
HUDManager.Instance.PauseGame(false);
|
|
}
|
|
|
|
public void ResturnPortLevel()
|
|
{
|
|
ShowDuringGame(false);
|
|
HUDManager.Instance.PortReturn();
|
|
}
|
|
|
|
public void ExitLevel()
|
|
{
|
|
ShowDuringGame(false);
|
|
if (VRManager.IsVROn())
|
|
{
|
|
VRManager.Instance.RefreshEyeTextureResolutionScale(true);
|
|
VRManager.Instance.TurnOnUIController(true);
|
|
}
|
|
HUDManager.Instance.ExitLevel();
|
|
}
|
|
|
|
public void ExitGame()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
|
|
public void LoadScene(string sceneName)
|
|
{
|
|
prevMenuState = currentState;
|
|
LoadingManager.LoadScene(sceneName);
|
|
if (dontDestroyOnLoad)
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void LoadFishery()
|
|
{
|
|
if (!DLCManager.Instance.IsAnyDLCInstalled(GlobalSettings.Instance.levelsManager.GetCurrentFishery().fromDLC) && !GlobalSettings.Instance.turnOnMyCheats)
|
|
{
|
|
Debug.LogError("LoadFishery DLC not installed");
|
|
return;
|
|
}
|
|
prevMenuState = currentState;
|
|
GlobalSettings.Instance.levelsManager.multiRoomName = string.Empty;
|
|
GlobalSettings.Instance.levelsManager.Save();
|
|
GlobalSettings.Instance.soundSettings.Save();
|
|
LoadingManager.LoadScene(GlobalSettings.Instance.levelsManager.GetCurrentFishery().unitySceneName);
|
|
if (dontDestroyOnLoad)
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void LoadInviteFishery(int id, int isTournament, string roomName)
|
|
{
|
|
prevMenuState = currentState;
|
|
GlobalSettings.Instance.levelsManager.isMultiplayer = true;
|
|
GlobalSettings.Instance.levelsManager.multiPrivateRoom = false;
|
|
GlobalSettings.Instance.levelsManager.multiRoomName = roomName;
|
|
GlobalSettings.Instance.levelsManager.isTournament = isTournament == 1;
|
|
LevelsManager.FisheryDefinition fisheryById = GlobalSettings.Instance.levelsManager.GetFisheryById(id);
|
|
if (fisheryById == null)
|
|
{
|
|
GlobalSettings.Instance.levelsManager.multiRoomName = string.Empty;
|
|
Debug.Log("LoadInviteFishery no fishery with id " + id);
|
|
return;
|
|
}
|
|
if (currentState == MenuState.PROFILES)
|
|
{
|
|
GlobalSettings.Instance.levelsManager.currentFishery = GlobalSettings.Instance.levelsManager.GetFisheryMissionNumber(fisheryById);
|
|
return;
|
|
}
|
|
if ((int)fisheryById.availableEntries == 0)
|
|
{
|
|
GlobalSettings.Instance.levelsManager.multiRoomName = string.Empty;
|
|
Debug.Log("LoadInviteFishery no license " + fisheryById.name);
|
|
if ((bool)GameController.Instance)
|
|
{
|
|
HUDManager.Instance.ShowMessage("MULTIPLAYER/INVITE_NO_LICENSE");
|
|
}
|
|
else if (!TrophyRoomManager.Instance)
|
|
{
|
|
GlobalSettings.Instance.levelsManager.currentFishery = GlobalSettings.Instance.levelsManager.GetFisheryMissionNumber(fisheryById);
|
|
if (currentState == MenuState.LEVELS)
|
|
{
|
|
gamePanels[2].GetComponent<FisheryManager>().RefreshInfo();
|
|
}
|
|
else
|
|
{
|
|
ChangeState(MenuState.LEVELS);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
GlobalSettings.Instance.levelsManager.currentFishery = GlobalSettings.Instance.levelsManager.GetFisheryMissionNumber(fisheryById);
|
|
if (fisheryById == null || GlobalSettings.Instance.levelsManager.currentFishery == -1)
|
|
{
|
|
Debug.LogError("Fishery not found: " + id);
|
|
return;
|
|
}
|
|
LoadingManager.LoadScene(GlobalSettings.Instance.levelsManager.GetCurrentFishery().unitySceneName);
|
|
if (dontDestroyOnLoad)
|
|
{
|
|
base.gameObject.SetActive(false);
|
|
}
|
|
}
|
|
|
|
public void ChangeProfile()
|
|
{
|
|
ChangeState(MenuState.PROFILES);
|
|
gamePanels[1].GetComponent<ProfilesScreen>().ChangeState(ProfilesScreen.ProfilesState.SELECT);
|
|
}
|
|
|
|
public void ChangeProfileName()
|
|
{
|
|
ChangeState(MenuState.PROFILES);
|
|
gamePanels[1].GetComponent<ProfilesScreen>().RenameProfile();
|
|
}
|
|
|
|
public void ChangeDifficulty()
|
|
{
|
|
ChangeState(MenuState.PROFILES);
|
|
gamePanels[1].GetComponent<ProfilesScreen>().DifficultyLevelChange();
|
|
}
|
|
|
|
public void CheckTournament()
|
|
{
|
|
if (GlobalSettings.Instance.levelsManager.isTournament)
|
|
{
|
|
ChangeState(MenuState.TOURNAMENT);
|
|
}
|
|
else
|
|
{
|
|
LoadFishery();
|
|
}
|
|
}
|
|
|
|
public void RefreshMenuObjects()
|
|
{
|
|
RefreshMenuObject[] array = refreshMenuObjects;
|
|
foreach (RefreshMenuObject refreshMenuObject in array)
|
|
{
|
|
if (!refreshMenuObject.refreshOnAwake)
|
|
{
|
|
refreshMenuObject.Refresh();
|
|
}
|
|
}
|
|
}
|
|
|
|
public void ShowCommonButtons(bool show)
|
|
{
|
|
if ((bool)commonButtons)
|
|
{
|
|
commonButtons.gameObject.SetActive(show);
|
|
}
|
|
}
|
|
|
|
public IEnumerator ChangeBackground()
|
|
{
|
|
while (true)
|
|
{
|
|
yield return new WaitForSeconds(backgroundStayTime);
|
|
currentBackground++;
|
|
if (currentBackground >= backgroundTextures.Count)
|
|
{
|
|
currentBackground = 0;
|
|
}
|
|
if (backgroundFront.color.a == 0f)
|
|
{
|
|
backgroundFront.sprite = backgroundTextures[currentBackground];
|
|
LeanTween.alpha(backgroundFront.GetComponent<RectTransform>(), 1f, backgroundFadeTime);
|
|
}
|
|
else
|
|
{
|
|
backgroundBack.sprite = backgroundTextures[currentBackground];
|
|
LeanTween.alpha(backgroundFront.GetComponent<RectTransform>(), 0f, backgroundFadeTime);
|
|
}
|
|
}
|
|
}
|
|
|
|
[Button]
|
|
public void GetServerTime()
|
|
{
|
|
StartCoroutine(Utilities.PrintServerTime());
|
|
}
|
|
|
|
public void ShowDLCWindow(DLCManager.DLC_ID dlcId)
|
|
{
|
|
if (currentState != MenuState.DLC)
|
|
{
|
|
ChangeState(MenuState.DLC);
|
|
gamePanels[18].GetComponent<DLCWindow>().Refresh(dlcId);
|
|
}
|
|
}
|
|
|
|
public void OpenUrl(string url)
|
|
{
|
|
Application.OpenURL(url);
|
|
}
|
|
|
|
[Button]
|
|
public void OpenReviewUrl()
|
|
{
|
|
Application.OpenURL("https://store.steampowered.com/recommended/recommendgame/" + SteamManager.Instance.gameId);
|
|
}
|
|
|
|
[Button]
|
|
public void OpenForumUrl()
|
|
{
|
|
Application.OpenURL("https://steamcommunity.com/app/468920/discussions/");
|
|
}
|
|
|
|
[Button]
|
|
public void PrintWindows()
|
|
{
|
|
Debug.Log(gamePanels.ToStringFull());
|
|
}
|
|
|
|
[Button]
|
|
public void CurveUITest()
|
|
{
|
|
gamePanels[1].gameObject.AddComponent<CurvedUISettings>();
|
|
}
|
|
|
|
[Button]
|
|
public void PrintSystemNames()
|
|
{
|
|
Debug.Log("System.Environment.UserName: " + Environment.UserName);
|
|
Debug.Log("System.Environment.UserDomainName: " + Environment.UserDomainName);
|
|
Debug.Log("System.Security.Principal.WindowsIdentity.GetCurrent().Name: " + WindowsIdentity.GetCurrent().Name);
|
|
Debug.Log("System.Environment.GetFolderPath(System.Environment.SpecialFolder.MyDocuments: " + Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
|
|
Debug.Log("SystemInfo.deviceName: " + SystemInfo.deviceName);
|
|
}
|
|
}
|