393 lines
11 KiB
C#
393 lines
11 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using Rewired.UI.ControlMapper;
|
|
using Steamworks;
|
|
using UnityEngine;
|
|
|
|
public class MainGameScene : MonoBehaviour
|
|
{
|
|
public enum Content
|
|
{
|
|
Profiles = 0,
|
|
Gameplay = 1,
|
|
Equipment = 2,
|
|
Shop = 3,
|
|
Tournament = 4,
|
|
Stats = 5,
|
|
Skills = 6,
|
|
Quests = 7,
|
|
Settings = 8,
|
|
Help = 9,
|
|
Home = 10,
|
|
Records = 11,
|
|
Ranking = 12,
|
|
Fishpedia = 13,
|
|
CharacterCustomize = 14,
|
|
Multiplayer = 15
|
|
}
|
|
|
|
public GameObject mainContent;
|
|
|
|
public GameObject profileSellection;
|
|
|
|
public PlayerHeader playerHeader;
|
|
|
|
public GameObject homeContent;
|
|
|
|
public GameObject freefishingContent;
|
|
|
|
public GameObject FishRecordsContent;
|
|
|
|
public GameObject RankingConent;
|
|
|
|
public GameObject bottomBar;
|
|
|
|
public GameObject bottomBarProfileBtn;
|
|
|
|
public Content currentContent;
|
|
|
|
public Content lastContent;
|
|
|
|
private List<Content> mainmenuContent = new List<Content>
|
|
{
|
|
Content.Home,
|
|
Content.Skills,
|
|
Content.Quests,
|
|
Content.Records,
|
|
Content.Ranking,
|
|
Content.Fishpedia,
|
|
Content.Help
|
|
};
|
|
|
|
private int mainmenuContentIndex;
|
|
|
|
public AudioClip[] mainMusic;
|
|
|
|
private AudioSource audioSource;
|
|
|
|
public GameObject bottomBarExitBtn;
|
|
|
|
public GameObject bottomBarBackBtn;
|
|
|
|
public Home homeController;
|
|
|
|
private bool isQuit;
|
|
|
|
public static event Action OnBackgroundMusicGlobal;
|
|
|
|
public static event Action OnBackgroundMusicStopGlobal;
|
|
|
|
private void incrementCurrentContent()
|
|
{
|
|
if (mainmenuContentIndex < mainmenuContent.Count - 1)
|
|
{
|
|
mainmenuContentIndex++;
|
|
}
|
|
else
|
|
{
|
|
mainmenuContentIndex = 0;
|
|
}
|
|
}
|
|
|
|
private void decrementCurrentContent()
|
|
{
|
|
if (mainmenuContentIndex > 0)
|
|
{
|
|
mainmenuContentIndex--;
|
|
}
|
|
else
|
|
{
|
|
mainmenuContentIndex = mainmenuContent.Count - 1;
|
|
}
|
|
}
|
|
|
|
public void QuickSceneChange(bool directionRight)
|
|
{
|
|
if (GameManager.Instance.messageBoxStack.Count != 0 || profileSellection.activeSelf || SRDebug.Instance.IsDebugPanelVisible || (bool)UnityEngine.Object.FindObjectOfType<SetNamePopUpItem>() || (bool)UnityEngine.Object.FindObjectOfType<Window>() || ((bool)UnityEngine.Object.FindObjectOfType<ShopManager>() && UnityEngine.Object.FindObjectOfType<ShopManager>().searchField.isFocused) || ((bool)UnityEngine.Object.FindObjectOfType<FishPediaManager>() && UnityEngine.Object.FindObjectOfType<FishPediaManager>().searchText.isFocused) || ((bool)UnityEngine.Object.FindObjectOfType<EquipmentManager>() && UnityEngine.Object.FindObjectOfType<EquipmentManager>().searchInputField.isFocused) || MultiplayerAddectiveScene.IsFocused)
|
|
{
|
|
return;
|
|
}
|
|
MainGameScene mainGameScene = UnityEngine.Object.FindObjectOfType<MainGameScene>();
|
|
if (!(mainGameScene == null))
|
|
{
|
|
if (directionRight)
|
|
{
|
|
incrementCurrentContent();
|
|
}
|
|
else
|
|
{
|
|
decrementCurrentContent();
|
|
}
|
|
mainGameScene.ShowContent(mainmenuContent[mainmenuContentIndex]);
|
|
}
|
|
}
|
|
|
|
private void OnDestroy()
|
|
{
|
|
MainGameScene.OnBackgroundMusicStopGlobal?.Invoke();
|
|
}
|
|
|
|
private void Start()
|
|
{
|
|
audioSource = GetComponent<AudioSource>();
|
|
if (GameManager.Instance.currentSceneLoadedType != GameManager.SceneLoadedType.Main && SteamManager.Initialized && (bool)Singleton<SteamStorage>.Instance)
|
|
{
|
|
Singleton<SteamStorage>.Instance.SaveAllPlayerDataToCloude();
|
|
}
|
|
GameManager.Instance.currentSceneLoadedType = GameManager.SceneLoadedType.Main;
|
|
GameManager.Instance.SetMouseCurrsor(val: true);
|
|
SetProfilesSelection();
|
|
audioSource = GetComponent<AudioSource>();
|
|
MainGameScene.OnBackgroundMusicGlobal?.Invoke();
|
|
if ((bool)TutorialManager.Instance)
|
|
{
|
|
if (Time.timeScale == 0f)
|
|
{
|
|
GameManager.Instance.PauseGame();
|
|
}
|
|
UnityEngine.Object.Destroy(TutorialManager.Instance.gameObject);
|
|
}
|
|
homeController = homeContent.GetComponent<Home>();
|
|
GameObject.Find("MasterAudio").transform.position = Vector3.zero;
|
|
}
|
|
|
|
private void OnEnable()
|
|
{
|
|
FreeFishing.OnGoToMultiplayer += FreeFishing_OnGoToMultiplayer;
|
|
Home.OnShowContent += Home_OnShowContent;
|
|
}
|
|
|
|
private void OnDisable()
|
|
{
|
|
FreeFishing.OnGoToMultiplayer -= FreeFishing_OnGoToMultiplayer;
|
|
Home.OnShowContent -= Home_OnShowContent;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (GameManager.Instance.player.GetButtonDown("RB") || GameManager.Instance.player.GetButtonDown("E"))
|
|
{
|
|
QuickSceneChange(directionRight: true);
|
|
}
|
|
else if (GameManager.Instance.player.GetButtonDown("LB") || GameManager.Instance.player.GetButtonDown("Q"))
|
|
{
|
|
QuickSceneChange(directionRight: false);
|
|
}
|
|
}
|
|
|
|
public void OpenProfiles()
|
|
{
|
|
GameManager.Instance._playerData.currentPlayerProfileIndex = -1;
|
|
SetProfilesSelection();
|
|
}
|
|
|
|
public void SetProfilesSelection()
|
|
{
|
|
if (GameManager.Instance._playerData.currentPlayerProfileIndex == -1)
|
|
{
|
|
ShowContent(Content.Profiles);
|
|
return;
|
|
}
|
|
if (Singleton<SaveDataManager>.Instance.IsCurrentlySandbox())
|
|
{
|
|
if (mainmenuContent[4] == Content.Ranking)
|
|
{
|
|
mainmenuContent.RemoveAt(4);
|
|
}
|
|
}
|
|
else if (mainmenuContent[4] != Content.Ranking)
|
|
{
|
|
mainmenuContent.Insert(4, Content.Ranking);
|
|
}
|
|
ShowContent(Content.Home);
|
|
QualitySettings.vSyncCount = (Singleton<SaveDataManager>.Instance.SettingsData.IsVSyncEnabled ? 1 : 0);
|
|
}
|
|
|
|
public void BackToLastContent()
|
|
{
|
|
ShowContent(lastContent);
|
|
}
|
|
|
|
public void ShowContent(Content content)
|
|
{
|
|
if (content == Content.Tournament && ServerManager.isBanned)
|
|
{
|
|
return;
|
|
}
|
|
playerHeader.gameObject.SetActive(value: false);
|
|
homeContent.SetActive(value: false);
|
|
mainContent.SetActive(value: false);
|
|
profileSellection.SetActive(value: false);
|
|
freefishingContent.SetActive(value: false);
|
|
bottomBar.SetActive(value: true);
|
|
bottomBarProfileBtn.SetActive(value: false);
|
|
lastContent = currentContent;
|
|
currentContent = content;
|
|
GameManager.Instance.UnloadAddectiveScene();
|
|
switch (content)
|
|
{
|
|
case Content.Profiles:
|
|
playerHeader.gameObject.SetActive(value: false);
|
|
mainContent.SetActive(value: false);
|
|
profileSellection.SetActive(value: true);
|
|
bottomBarProfileBtn.SetActive(value: false);
|
|
break;
|
|
case Content.Gameplay:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(0);
|
|
mainContent.SetActive(value: true);
|
|
freefishingContent.SetActive(value: true);
|
|
bottomBar.SetActive(value: true);
|
|
bottomBarProfileBtn.SetActive(value: false);
|
|
bottomBarExitBtn.SetActive(value: false);
|
|
bottomBarBackBtn.SetActive(value: true);
|
|
if (Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().GameMode == GameManager.PlayerData.CPlayer.GameMode.Normal)
|
|
{
|
|
GameManager.Instance._playerData.ShowStartTutorialPanel();
|
|
}
|
|
break;
|
|
case Content.Equipment:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(9);
|
|
bottomBar.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
GameManager.Instance.LoadAddectiveScene("Equipment");
|
|
break;
|
|
case Content.Shop:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(9);
|
|
bottomBar.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
GameManager.Instance.LoadAddectiveScene("Shop");
|
|
break;
|
|
case Content.Skills:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(7);
|
|
bottomBar.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
playerHeader.tokensUI.SetActive(value: false);
|
|
GameManager.Instance.LoadAddectiveScene("SkillTree");
|
|
mainmenuContentIndex = 1;
|
|
break;
|
|
case Content.Quests:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(8);
|
|
bottomBar.SetActive(value: false);
|
|
playerHeader.tokensUI.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
GameManager.Instance.LoadAddectiveScene("Quests");
|
|
mainmenuContentIndex = 2;
|
|
break;
|
|
case Content.Settings:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(5);
|
|
bottomBar.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
GameManager.Instance.LoadAddectiveScene("Settings");
|
|
break;
|
|
case Content.Help:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(6);
|
|
bottomBar.SetActive(value: false);
|
|
playerHeader.tokensUI.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
GameManager.Instance._playerData.startHelpPanelViaStart = false;
|
|
GameManager.Instance.LoadAddectiveScene("Help");
|
|
mainmenuContentIndex = 6;
|
|
break;
|
|
case Content.Home:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(9);
|
|
mainContent.SetActive(value: true);
|
|
homeContent.SetActive(value: true);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
bottomBarExitBtn.SetActive(value: true);
|
|
bottomBarBackBtn.SetActive(value: false);
|
|
GameManager.Instance._playerData.RentierReward();
|
|
mainmenuContentIndex = 0;
|
|
break;
|
|
case Content.Records:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(4);
|
|
mainContent.SetActive(value: true);
|
|
bottomBar.SetActive(value: false);
|
|
playerHeader.tokensUI.SetActive(value: false);
|
|
GameManager.Instance.LoadAddectiveScene("PersonalRecords");
|
|
mainmenuContentIndex = 3;
|
|
break;
|
|
case Content.Ranking:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(4);
|
|
mainContent.SetActive(value: true);
|
|
bottomBar.SetActive(value: false);
|
|
playerHeader.tokensUI.SetActive(value: false);
|
|
bottomBarProfileBtn.SetActive(value: true);
|
|
GameManager.Instance.LoadAddectiveScene("Ranking");
|
|
mainmenuContentIndex = 4;
|
|
break;
|
|
case Content.Tournament:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
bottomBar.SetActive(value: false);
|
|
GameManager.Instance.LoadAddectiveScene("Tournaments");
|
|
break;
|
|
case Content.Fishpedia:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
playerHeader.SetSelectedOptionBtn(4);
|
|
mainContent.SetActive(value: true);
|
|
bottomBar.SetActive(value: false);
|
|
playerHeader.tokensUI.SetActive(value: false);
|
|
GameManager.Instance.LoadAddectiveScene("FishPedia");
|
|
mainmenuContentIndex = 5;
|
|
break;
|
|
case Content.Multiplayer:
|
|
playerHeader.gameObject.SetActive(value: true);
|
|
bottomBar.SetActive(value: false);
|
|
GameManager.Instance.LoadAddectiveScene("Multiplayer");
|
|
break;
|
|
case Content.Stats:
|
|
case Content.CharacterCustomize:
|
|
break;
|
|
}
|
|
}
|
|
|
|
public void ExitButton()
|
|
{
|
|
if (GameManager.Instance.messageBoxStack.Count == 0)
|
|
{
|
|
GameManager.Instance.CreateMessageBox("EXIT_WINDOWS", GetComponent<Canvas>().transform, 7, 1);
|
|
}
|
|
}
|
|
|
|
public void Exit()
|
|
{
|
|
if (!isQuit)
|
|
{
|
|
SteamAPI.Shutdown();
|
|
Invoke("Quit", 1f);
|
|
isQuit = true;
|
|
}
|
|
}
|
|
|
|
private void Quit()
|
|
{
|
|
Application.Quit();
|
|
}
|
|
|
|
private void FreeFishing_OnGoToMultiplayer()
|
|
{
|
|
ShowContent(Content.Multiplayer);
|
|
}
|
|
|
|
private void Home_OnShowContent(int indexOfContent)
|
|
{
|
|
if (indexOfContent == 1)
|
|
{
|
|
bottomBar.SetActive(value: false);
|
|
}
|
|
else
|
|
{
|
|
bottomBar.SetActive(value: true);
|
|
}
|
|
}
|
|
}
|