using System; using System.Collections; using System.Linq; using UnityEngine; using UnityEngine.UI; public class Home : MonoBehaviour { public Image GoFishingImage; public Text GoFishingText; public Text GoFishingNameText; public Text levelValueText; public Text xPValueText; public Image xpProgressBarImage; public RawImage profileAvatar; public Text profileLevelValueText; public Text profileXpValueText; public Image profileXpProgressBarImage; public Text profileGametimeValueText; public Text profileFishCaughtValueText; public Text profileRankingPointsValueText; public Text profileTournamentsValueText; public Text completedDailyQuestsValueText; public Text completedWeeklyQuestsValueText; public Text completedMonthlyQuestsValueText; public Text ResidenceFishAquariumsText; public Text ResidenceTotalAquariumsText; public Text ResidenceTotalTrophiesText; public Text FishNetLevelText; public Text FishNetCapacityText; public Text FishNetTotalFishText; public Text FishNetXpText; public Image FishNetLevelProgress; public Text FishStatsWeightText; public Text FishStatsAmoutText; public Button ShowFishNetButton; public Button ShowResidenceButton; public GameObject[] homeContents; public GameObject tournamentsGameObject; public GameObject tournamentsBannedGameObject; public GameObject inventoryGameObject; public GameObject ShopGameObject; public BaitFishListItem BaitFishListItemPrefab; public GameObject BaitFishListScrollView; [SerializeField] private Sprite ResidenceSprite; [SerializeField] private Sprite TournamentSprite; [SerializeField] private LocalizationUIText tournamentLocalizationText; public Color activePanelColor; public Color inactivePanelColor; public Color inactiveTextColor; private int lastPlayLocationIndex; private MainGameScene mgscene; public int lastDisplayedContent; public static event Action OnShowContent; private void Start() { if (FScriptsHandler.Instance != null) { ShowResidenceButton.gameObject.SetActive(value: false); } if ((bool)GameManager.Instance.playerResidence) { ShowResidenceButton.gameObject.SetActive(value: false); } mgscene = UnityEngine.Object.FindObjectOfType(); ShowFisheshOnMap(); } private void FixedUpdate() { if (ServerManager.isBanned) { if (!tournamentsBannedGameObject.activeSelf) { tournamentsBannedGameObject.SetActive(value: true); } } else if (tournamentsBannedGameObject.activeSelf) { tournamentsBannedGameObject.SetActive(value: false); } } private void Update() { if (InputManager.isBPressed || InputManager.isExit) { if (lastDisplayedContent == 2) { ShowContent(1); } else { ShowContent(0); } } } private void ShowFisheshOnMap() { if (GameManager.Instance.playerResidence != null || FScriptsHandler.Instance == null) { BaitFishListScrollView.gameObject.SetActive(value: false); return; } int num = GameManager.Instance._playerData.Player[GameManager.Instance._playerData.currentPlayerProfileIndex].lastPlayLocationIndex; GameManager.FishSpecies[] fishSpecies = GameManager.Instance.gameLocations[num].fishSpecies; _ = GameManager.Instance.gameFish[0].speciesName; GameManager.FishSpecies[] array = fishSpecies; foreach (GameManager.FishSpecies f in array) { GameManager.GameFish fish = GameManager.Instance.gameFish.ToList().FirstOrDefault((GameManager.GameFish x) => x.speciesName == f); UnityEngine.Object.Instantiate(BaitFishListItemPrefab, BaitFishListScrollView.transform).Initialize(fish); } } public void ShowContent(int index) { Home.OnShowContent?.Invoke(index); for (int i = 0; i < homeContents.Length; i++) { homeContents[i].SetActive(value: false); } lastDisplayedContent = index; if (index == -1) { return; } homeContents[index].SetActive(value: true); GetData(); if ((bool)TutorialManager.Instance) { inventoryGameObject.GetComponent().color = inactivePanelColor; inventoryGameObject.GetComponentInChildren().color = inactiveTextColor; ShopGameObject.GetComponent().color = inactivePanelColor; ShopGameObject.GetComponentInChildren().color = inactiveTextColor; return; } inventoryGameObject.GetComponent().color = activePanelColor; inventoryGameObject.GetComponentInChildren().color = activePanelColor; ShopGameObject.GetComponent().color = activePanelColor; ShopGameObject.GetComponentInChildren().color = activePanelColor; if ((bool)GameManager.Instance.playerResidence) { GoFishingImage.color = inactivePanelColor; GoFishingText.color = inactiveTextColor; } } private void GetData() { _ = GameManager.Instance._playerData.currentPlayerProfileIndex; FishNetLevelText.text = Singleton.Instance.GetCurrentPlayerData().PlayerFishNetLevel.ToString(); FishNetCapacityText.text = GameManager.Instance.ConvertWeight(GameManager.Instance._playerData.GetFishNetCapacity()); FishNetTotalFishText.text = GameManager.Instance.ConvertWeight(GameManager.Instance._playerData.GetUsedFishNet()); FishNetXpText.text = Singleton.Instance.GetCurrentPlayerData().PlayerFishNetExp + " XP"; FishNetLevelProgress.fillAmount = (float)Singleton.Instance.GetCurrentPlayerData().PlayerFishNetExp / (float)GameManager.Instance._playerData.fishNetMaxExp[Singleton.Instance.GetCurrentPlayerData().PlayerFishNetLevel - 1]; FishStatsWeightText.text = GameManager.Instance.ConvertWeight(GameManager.Instance._playerData.GetUsedFishNet()) + "/" + GameManager.Instance.ConvertWeight(GameManager.Instance._playerData.GetFishNetCapacity()); if (Singleton.Instance.GetCurrentPlayerData().PlayerFishNet.Count == 0) { FishStatsAmoutText.text = "0"; } else { FishStatsAmoutText.text = Singleton.Instance.GetCurrentPlayerData().PlayerFishNet.Count.ToString(); } if (Singleton.Instance.GetCurrentPlayerData().PlayerFishNet.Count == 0) { ShowFishNetButton.interactable = false; } else { ShowFishNetButton.interactable = true; } lastPlayLocationIndex = GameManager.Instance._playerData.Player[GameManager.Instance._playerData.currentPlayerProfileIndex].lastPlayLocationIndex; GoFishingImage.sprite = GameManager.Instance.gameLocations[lastPlayLocationIndex].GetScreenMapImage(0); GoFishingNameText.text = GameManager.Instance.gameLocations[lastPlayLocationIndex].name; if (FScriptsHandler.Instance != null) { GoFishingText.enabled = false; } else { GoFishingText.enabled = true; } levelValueText.text = Singleton.Instance.GetCurrentPlayerData().PlayerLevel.ToString(); xPValueText.text = Singleton.Instance.GetCurrentPlayerData().PlayerExp + " XP"; xpProgressBarImage.fillAmount = Singleton.Instance.GetCurrentPlayerData().PlayerExp / Singleton.Instance.GetCurrentPlayerData().PlayerMaxExp; profileLevelValueText.text = Singleton.Instance.GetCurrentPlayerData().PlayerLevel.ToString(); profileXpValueText.text = Singleton.Instance.GetCurrentPlayerData().PlayerExp + " XP"; profileXpProgressBarImage.fillAmount = Singleton.Instance.GetCurrentPlayerData().PlayerExp / Singleton.Instance.GetCurrentPlayerData().PlayerMaxExp; profileGametimeValueText.text = Mathf.RoundToInt(GameManager.Instance._playerData.GetGameTimeInSeconds() / 3600) + "h"; profileFishCaughtValueText.text = Singleton.Instance.GetCurrentPlayerData().TotalFish.ToString(); profileRankingPointsValueText.text = Singleton.Instance.GetCurrentPlayerData().PlayerRankingPoints.ToString(); completedDailyQuestsValueText.text = Singleton.Instance.GetCurrentPlayerData().CompletedDailyQuests.ToString(); completedWeeklyQuestsValueText.text = Singleton.Instance.GetCurrentPlayerData().CompletedWeeklyQuests.ToString(); completedMonthlyQuestsValueText.text = Singleton.Instance.GetCurrentPlayerData().CompletedMonthlyQuests.ToString(); profileTournamentsValueText.text = Singleton.Instance.GetCurrentPlayerData().PlayerTournamentsWon.ToString(); ResidenceFishAquariumsText.text = GetAquariumsFish("CURRENT").ToString(); ResidenceTotalAquariumsText.text = Singleton.Instance.GetCurrentPlayerData().PlayerAquarium.Count.ToString(); ResidenceTotalTrophiesText.text = Singleton.Instance.GetCurrentPlayerData().PlayerTrophy.Count.ToString(); } private int GetAquariumsFish(string valueType) { int num = 0; for (int i = 0; i < Singleton.Instance.GetCurrentPlayerData().PlayerAquarium.Count; i++) { if (!(valueType == "CURRENT")) { if (valueType == "MAX") { num += Singleton.Instance.GetCurrentPlayerData().PlayerAquarium[i].maxCapacity; } } else { num += Singleton.Instance.GetCurrentPlayerData().PlayerAquarium[i].fish.Count; } } return num; } public void GoToResidence() { if (!(FScriptsHandler.Instance != null)) { GameManager.Instance.LoadScene("Residence"); } } public void OpenSettings() { UnityEngine.Object.FindObjectOfType().ShowSettings(); } public void OpenInventory() { if (!TutorialManager.Instance) { UnityEngine.Object.FindObjectOfType().ShowEquipment(); } } public void OpenShop() { if (!TutorialManager.Instance) { UnityEngine.Object.FindObjectOfType().ShowShop(); } } public void Gameplay() { if (!TutorialManager.Instance) { UnityEngine.Object.FindObjectOfType().ShowGameplay(); } } public void GoFishing() { GameManager.Instance.UnloadAddectiveScene(); if (FScriptsHandler.Instance == null) { GameManager.Instance.LoadScene(GameManager.Instance.gameLocations[lastPlayLocationIndex].sceneName); } } public void OpenTournaments() { if (Singleton.Instance.IsCurrentlySandbox()) { UnityEngine.Object.FindObjectOfType().ShowResidence(); } else { UnityEngine.Object.FindObjectOfType().ShowTournaments(); } } public void PlayOnClickSound() { GameManager.Instance.PlayOnClickSound(); } private void OnEnable() { StartCoroutine(ShowContentDelay(0)); GetData(); if (Singleton.Instance.IsCurrentlySandbox()) { tournamentsGameObject.GetComponent().sprite = ResidenceSprite; tournamentLocalizationText.key = "RESIDENCE_GRID"; } else { tournamentsGameObject.GetComponent().sprite = TournamentSprite; tournamentLocalizationText.key = "TOURNAMENTS"; } } private IEnumerator ShowContentDelay(int index) { yield return null; if (GameManager.Instance._playerData.forceShowFishNet) { ShowContent(2); GameManager.Instance._playerData.forceShowFishNet = false; } else { ShowContent(index); } } }