223 lines
4.6 KiB
C#
223 lines
4.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class QuickMenu : Singleton<QuickMenu>
|
|
{
|
|
[Serializable]
|
|
public class ContentButtonsClass
|
|
{
|
|
public GameObject[] ContentButtons;
|
|
}
|
|
|
|
public bool isOn;
|
|
|
|
public GameObject mainContainer;
|
|
|
|
public Image[] Knob;
|
|
|
|
public Text ContentNameText;
|
|
|
|
public GameObject[] Content;
|
|
|
|
public List<ContentButtonsClass> ContentButtonsList = new List<ContentButtonsClass>();
|
|
|
|
public Color knobOnColor;
|
|
|
|
public Color knobOffColor;
|
|
|
|
private int currentContentIndex;
|
|
|
|
private int nextContentIndex;
|
|
|
|
private void Start()
|
|
{
|
|
ShowContent(0);
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (((bool)FScriptsHandler.Instance.m_PlayerMain && (bool)FScriptsHandler.Instance.m_PlayerMain.underWaterCamera) || GameManager.Instance.ChechIfPlayerShouldBeStoppedFromDoingAnything())
|
|
{
|
|
return;
|
|
}
|
|
if (GameManager.Instance.player.GetButtonDown("quickMenu") && !UnityEngine.Object.FindObjectOfType<FishCatchPanel>())
|
|
{
|
|
if (isOn)
|
|
{
|
|
ShowHide(isHide: true);
|
|
}
|
|
else
|
|
{
|
|
ShowHide();
|
|
}
|
|
}
|
|
if ((InputManager.isBPressed || InputManager.isExit) && isOn)
|
|
{
|
|
ShowHide(isHide: true);
|
|
}
|
|
if (!isOn)
|
|
{
|
|
return;
|
|
}
|
|
if (GameManager.Instance.player.GetButtonDown("LB"))
|
|
{
|
|
int num = currentContentIndex - 1;
|
|
if (num < 0)
|
|
{
|
|
num = Content.Length - 1;
|
|
}
|
|
ShowContent(num);
|
|
PlayClickSound();
|
|
}
|
|
else if (GameManager.Instance.player.GetButtonDown("RB"))
|
|
{
|
|
int num2 = currentContentIndex + 1;
|
|
if (num2 == Content.Length)
|
|
{
|
|
num2 = 0;
|
|
}
|
|
ShowContent(num2);
|
|
PlayClickSound();
|
|
}
|
|
}
|
|
|
|
public void ShowHide(bool isHide = false)
|
|
{
|
|
if (Time.timeScale != 0f || isHide)
|
|
{
|
|
if (!isHide)
|
|
{
|
|
isOn = true;
|
|
}
|
|
else
|
|
{
|
|
isOn = false;
|
|
}
|
|
mainContainer.SetActive(isOn);
|
|
ShowContent(0);
|
|
GameManager.Instance.PauseGame();
|
|
}
|
|
}
|
|
|
|
private void SwitchKnob()
|
|
{
|
|
for (int i = 0; i < Knob.Length; i++)
|
|
{
|
|
if (i == currentContentIndex)
|
|
{
|
|
Knob[i].color = knobOnColor;
|
|
}
|
|
else
|
|
{
|
|
Knob[i].color = knobOffColor;
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ShowContent(int newIndex)
|
|
{
|
|
Content[currentContentIndex].SetActive(value: false);
|
|
Content[newIndex].SetActive(value: true);
|
|
currentContentIndex = newIndex;
|
|
SwitchKnob();
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
switch (newIndex)
|
|
{
|
|
case 0:
|
|
if (TutorialManager.Instance.acctualLessonIndex != 1)
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[1].GetComponent<Button>().interactable = false;
|
|
}
|
|
else
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[1].GetComponent<Button>().interactable = true;
|
|
}
|
|
if (TutorialManager.Instance.acctualLessonIndex != 8)
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[0].GetComponent<Button>().interactable = false;
|
|
}
|
|
else
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[0].GetComponent<Button>().interactable = true;
|
|
}
|
|
break;
|
|
case 1:
|
|
ContentButtonsList[newIndex].ContentButtons[0].GetComponent<Button>().interactable = false;
|
|
break;
|
|
case 2:
|
|
ContentButtonsList[newIndex].ContentButtons[0].GetComponent<Button>().interactable = false;
|
|
ContentButtonsList[newIndex].ContentButtons[1].GetComponent<Button>().interactable = false;
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
if (TutorialManager.Instance.acctualLessonIndex < 12)
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[2].GetComponent<Button>().interactable = false;
|
|
}
|
|
else
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[2].GetComponent<Button>().interactable = true;
|
|
}
|
|
}
|
|
break;
|
|
case 3:
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < ContentButtonsList[newIndex].ContentButtons.Length; i++)
|
|
{
|
|
ContentButtonsList[newIndex].ContentButtons[i].GetComponent<Button>().interactable = true;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void PlayClickSound()
|
|
{
|
|
GetComponent<AudioSource>().Play();
|
|
}
|
|
|
|
public void UseItemAccesory(int id)
|
|
{
|
|
if (id == 0)
|
|
{
|
|
InputManager.isHeadFlashLight = !InputManager.isHeadFlashLight;
|
|
}
|
|
PlayClickSound();
|
|
ShowHide(isHide: true);
|
|
}
|
|
|
|
public void OpenNewScene(int id)
|
|
{
|
|
switch (id)
|
|
{
|
|
case 0:
|
|
InputManager.isOpenEquipmentSceneByMenu = true;
|
|
break;
|
|
case 1:
|
|
InputManager.isOpenShopSceneByMenu = true;
|
|
break;
|
|
case 2:
|
|
InputManager.isOpenSettingsSceneByMenu = true;
|
|
break;
|
|
case 3:
|
|
InputManager.isOpenHelpPanelByMenu = true;
|
|
break;
|
|
case 4:
|
|
InputManager.isOpenLocationMapSceneByMenu = true;
|
|
break;
|
|
case 5:
|
|
InputManager.isExitByMenu = true;
|
|
break;
|
|
case 6:
|
|
InputManager.showUI = !InputManager.showUI;
|
|
break;
|
|
}
|
|
PlayClickSound();
|
|
ShowHide(isHide: true);
|
|
}
|
|
}
|