using UnityEngine; using UnityEngine.UI; public class QuestManager : Singleton { [SerializeField] private Image mainContentMaskImage; [SerializeField] private Camera mCamera; [SerializeField] private PlayerHeader playerHeader; public Transform QuestContainer; public Transform WeeklyQuestContainer; public Transform MonthlyQuestContainer; public GameObject[] QuestTypeContent; public Sprite[] QuestTypeButtonSprites; public Image[] QuestTypeButtonImage; public AudioSource RewardAudioSource; public GameObject[] QuestItemPrefabs; public GameObject[] WeeklyQuestItemPrefabs; public GameObject[] MonthlyQuestItemPrefabs; public GameObject RewardPopUpPrefab; public Text timerText; public Text WeeklytimerText; public Text MonthlytimerText; public Text questpointsText; public Text QuestPointsTitlelText; public Text DailyCategoryText; public Text WeeklyCategoryText; public Text MonthlyCategoryText; private int currentShowQuestIndex = -1; private void Start() { if ((bool)FScriptsHandler.Instance) { playerHeader.gameObject.SetActive(value: true); mainContentMaskImage.enabled = true; FScriptsHandler.Instance.m_Canvas.gameObject.SetActive(value: false); mCamera.transform.position = FScriptsHandler.Instance.m_PlayerMain.m_Camera.transform.position; mCamera.transform.rotation = FScriptsHandler.Instance.m_PlayerMain.m_Camera.transform.rotation; } else if (Object.FindObjectOfType() != null) { playerHeader.gameObject.SetActive(value: true); mainContentMaskImage.enabled = true; mCamera.transform.position = Camera.main.transform.position; mCamera.transform.rotation = Camera.main.transform.rotation; } else { playerHeader.gameObject.SetActive(value: false); mainContentMaskImage.enabled = false; } } private void Update() { GameManager.Instance._playerData.QuestTimer(); GameManager.Instance._playerData.WeeklyQuestTimer(); GameManager.Instance._playerData.MonthlyQuestTimer(); ShowTimer(); } private void OnEnable() { ChangeQuestConent(0); } private void OnDisable() { timerText.gameObject.SetActive(value: false); WeeklytimerText.gameObject.SetActive(value: false); MonthlytimerText.gameObject.SetActive(value: false); currentShowQuestIndex = -1; } private void OnDestroy() { if (FScriptsHandler.Instance != null) { FScriptsHandler.Instance.m_Canvas.gameObject.SetActive(value: true); } } private void InstantiateDailyQuest(int i, int cardindex) { QuestItem component = Object.Instantiate(QuestItemPrefabs[cardindex], QuestContainer).GetComponent(); component.titleText.text = GameManager.Instance.GetQuestDescription(Singleton.Instance.GetCurrentPlayerData().PlayerQuest[i].gameQuest); component.uid = Singleton.Instance.GetCurrentPlayerData().PlayerQuest[i].uid; component.SetProgress(Singleton.Instance.GetCurrentPlayerData().PlayerQuest[i].curentObjectiveProgress, Singleton.Instance.GetCurrentPlayerData().PlayerQuest[i].gameQuest.objectiveValue); component.pointsText.text = Singleton.Instance.GetCurrentPlayerData().PlayerQuest[i].gameQuest.points.ToString(); component.indexOfPlayerQuest = i; } private void InstantiateWeeklyQuest(int i, int cardindex) { WeeklyQuestItem component = Object.Instantiate(WeeklyQuestItemPrefabs[cardindex], WeeklyQuestContainer).GetComponent(); component.QuestDescriptionText.text = GameManager.Instance.GetQuestDescription(Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[i].gameQuest); component.QuestTypeText.text = GetQuestCategory(Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[i].gameQuest); component.uid = Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[i].uid; component.RewardText.text = "$" + Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[i].gameQuest.reward; component.SetProgress(Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[i].curentObjectiveProgress, Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[i].gameQuest.objectiveValue); component.indexOfPlayerQuest = i; } private void InstantiateMonthlyQuest(int i, int cardindex) { MonthlyQuestItem component = Object.Instantiate(MonthlyQuestItemPrefabs[cardindex], MonthlyQuestContainer).GetComponent(); component.QuestDescriptionText.text = GameManager.Instance.GetQuestDescription(Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].gameQuest); component.uid = Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].uid; component.QuestTypeText.text = GetQuestCategory(Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].gameQuest); component.RewardText.text = "$" + Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].gameQuest.reward; component.SetProgress(Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].curentObjectiveProgress, Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].gameQuest.objectiveValue); component.indexOfPlayerQuest = i; } public void ShowQuests() { GameManager.TruncateContainer(QuestContainer); GameManager.TruncateContainer(WeeklyQuestContainer); GameManager.TruncateContainer(MonthlyQuestContainer); switch (currentShowQuestIndex) { case 0: { for (int j = 0; j < Singleton.Instance.GetCurrentPlayerData().PlayerQuest.Count; j++) { switch (Singleton.Instance.GetCurrentPlayerData().PlayerQuest[j].gameQuest.type) { case GameManager.GameQuest.Type.Common: InstantiateDailyQuest(j, 0); break; case GameManager.GameQuest.Type.Epic: InstantiateDailyQuest(j, 1); break; case GameManager.GameQuest.Type.Legendary: InstantiateDailyQuest(j, 2); break; } } break; } case 1: { for (int k = 0; k < Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest.Count; k++) { switch (Singleton.Instance.GetCurrentPlayerData().PlayerWeeklyQuest[k].gameQuest.questObjectiveType) { case GameManager.GameQuest.QuestObjectiveType.Catch_fish: case GameManager.GameQuest.QuestObjectiveType.Catch_fish_by_species: InstantiateWeeklyQuest(k, 0); break; case GameManager.GameQuest.QuestObjectiveType.Catch_fish_by_weight: case GameManager.GameQuest.QuestObjectiveType.Catch_fish_total_weight: InstantiateWeeklyQuest(k, 1); break; case GameManager.GameQuest.QuestObjectiveType.Spend_time: InstantiateWeeklyQuest(k, 2); break; } } break; } case 2: { for (int i = 0; i < Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest.Count; i++) { switch (Singleton.Instance.GetCurrentPlayerData().PlayerMonthlyQuest[i].gameQuest.questObjectiveType) { case GameManager.GameQuest.QuestObjectiveType.Catch_fish: case GameManager.GameQuest.QuestObjectiveType.Catch_fish_total_weight: InstantiateMonthlyQuest(i, 0); break; case GameManager.GameQuest.QuestObjectiveType.Catch_fish_by_weight: case GameManager.GameQuest.QuestObjectiveType.Catch_fish_by_species: InstantiateMonthlyQuest(i, 1); break; case GameManager.GameQuest.QuestObjectiveType.Spend_time: InstantiateMonthlyQuest(i, 2); break; } } break; } } } public void ChangeQuest(int indexOfPlayerQuest) { GameManager.Instance._playerData.RandomAndChangeOneQuest(indexOfPlayerQuest); ShowQuests(); } private void ShowTimer() { timerText.text = GameManager.Instance._playerData.GetMidnightTime(); WeeklytimerText.text = GameManager.Instance._playerData.GetWeeklyMidnightTime(); MonthlytimerText.text = GameManager.Instance._playerData.GetMonthlyMidnightTime(); if (Singleton.Instance.IsCurrentlySandbox()) { questpointsText.text = "∞"; } else { questpointsText.text = Singleton.Instance.GetCurrentPlayerData().QuestPoints + "/" + Singleton.Instance.GetCurrentPlayerData().PointsCap; } QuestPointsTitlelText.text = LanguageManager.Instance.GetText("QUEST_POINTS"); DailyCategoryText.text = LanguageManager.Instance.GetText("DAILY_QUESTS"); WeeklyCategoryText.text = LanguageManager.Instance.GetText("WEEKLY_QUESTS"); MonthlyCategoryText.text = LanguageManager.Instance.GetText("MONTHLY_QUESTS"); timerText.gameObject.SetActive(value: true); WeeklytimerText.gameObject.SetActive(value: true); MonthlytimerText.gameObject.SetActive(value: true); } public void ChangeQuestConent(int index) { if (currentShowQuestIndex != index) { for (int i = 0; i < 3; i++) { QuestTypeContent[i].SetActive(value: false); QuestTypeButtonImage[i].sprite = QuestTypeButtonSprites[0]; QuestTypeButtonImage[i].color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); QuestTypeButtonImage[i].gameObject.GetComponentInChildren().color = new Color32(0, 0, 0, byte.MaxValue); QuestTypeButtonImage[i].gameObject.GetComponentInChildren().enabled = true; } QuestTypeContent[index].SetActive(value: true); QuestTypeButtonImage[index].sprite = QuestTypeButtonSprites[0]; QuestTypeButtonImage[index].color = new Color32(58, 58, 58, byte.MaxValue); QuestTypeButtonImage[index].gameObject.GetComponentInChildren().color = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue); QuestTypeButtonImage[index].gameObject.GetComponentInChildren().Rebind(); QuestTypeButtonImage[index].gameObject.GetComponentInChildren().enabled = false; currentShowQuestIndex = index; ShowQuests(); } } private string GetQuestCategory(GameManager.GameQuest gamequest) { string result = ""; switch (gamequest.questObjectiveType) { case GameManager.GameQuest.QuestObjectiveType.Catch_fish: result = LanguageManager.Instance.GetText("QUEST_CATCH_FISH_CATEGORY"); break; case GameManager.GameQuest.QuestObjectiveType.Catch_fish_by_species: result = LanguageManager.Instance.GetText("QUEST_FISH_BY_SPECIES_CATEGORY"); break; case GameManager.GameQuest.QuestObjectiveType.Catch_fish_by_weight: result = LanguageManager.Instance.GetText("QUEST_FISH_BY_WEIGHT_CATEGORY"); break; case GameManager.GameQuest.QuestObjectiveType.Catch_fish_total_weight: result = LanguageManager.Instance.GetText("QUEST_FISH_TOTAL_WEIGHT_CATEGORY"); break; case GameManager.GameQuest.QuestObjectiveType.Spend_time: result = LanguageManager.Instance.GetText("QUEST_SPEND_TIME_CATEGORY"); break; } return result; } }