using System; using System.Collections; using System.Collections.Generic; using UFS2.Gameplay; using UnityEngine; using UnityEngine.UI; public class TutorialManager : MonoBehaviour { [Serializable] public class Steps { public string titleTranslateKey; public string GamePadtitleTranslateKey; public string contentTranslateKey; public string GamePadcontentTranslateKey; public bool isComplete; public Sprite image; public Sprite image2; } public List PlayerRods; public List PlayerReels; public List PlayerLines; public List PlayerLeaders; public List PlayerBaits; public List PlayerHooks; public List PlayerFloats; public List PlayerFeeders; public List PlayerWeights; public List PlayerSlotsEquip; public List _previousPlayerRods; public List _previousPlayerReels; public List _previousPlayerLines; public List _previousPlayerLeaders; public List _previousPlayerBaits; public List _previousPlayerHooks; public List _previousPlayerFloats; public List _previousPlayerFeeders; public List _previousPlayerWeights; public List _previousPlayerSlotsEquip; public int acctualLessonIndex; public bool tutUpdateBool; public List lekcje = new List(); [HideInInspector] public TutorialPopUpItem currentTutorialPopUp; private FPlayer playermain; public GameObject TutorialPopUp; public GameObject EndTutorialPopUp; private static TutorialManager instance; public static TutorialManager Instance => instance; private void Awake() { UnityEngine.Object.DontDestroyOnLoad(this); if (instance == null) { instance = this; } else if (instance != this) { UnityEngine.Object.Destroy(base.gameObject); } } private void OnDestroy() { Singleton.Instance.GetCurrentPlayerData().PlayerRods = _previousPlayerRods; Singleton.Instance.GetCurrentPlayerData().PlayerReels = _previousPlayerReels; Singleton.Instance.GetCurrentPlayerData().PlayerLines = _previousPlayerLines; Singleton.Instance.GetCurrentPlayerData().PlayerLeaders = _previousPlayerLeaders; Singleton.Instance.GetCurrentPlayerData().PlayerBaits = _previousPlayerBaits; Singleton.Instance.GetCurrentPlayerData().PlayerHooks = _previousPlayerHooks; Singleton.Instance.GetCurrentPlayerData().PlayerFloats = _previousPlayerFloats; Singleton.Instance.GetCurrentPlayerData().PlayerFeeders = _previousPlayerFeeders; Singleton.Instance.GetCurrentPlayerData().PlayerWeights = _previousPlayerWeights; Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip = new List(_previousPlayerSlotsEquip); Debug.Log("[TutorialManager.cs] Destroy TutorialManager."); } public void CheckLessonPopUp(int index) { Debug.Log("CHECK SIE WYKONUJE 2 RAZY"); if (acctualLessonIndex == index) { lekcje[index].isComplete = true; acctualLessonIndex++; tutUpdateBool = false; if (acctualLessonIndex == 13) { Invoke("ShowEndTutorialPopUp", 2f); } else if (GameManager.Instance.controllerType == GameManager.ControllerType.GamePad) { ShowTutorialUpPopUp(FScriptsHandler.Instance.m_Canvas.transform, lekcje[acctualLessonIndex].GamePadtitleTranslateKey, lekcje[acctualLessonIndex].GamePadcontentTranslateKey, lekcje[acctualLessonIndex].image, lekcje[acctualLessonIndex].image2); } else { ShowTutorialUpPopUp(FScriptsHandler.Instance.m_Canvas.transform, lekcje[acctualLessonIndex].titleTranslateKey, lekcje[acctualLessonIndex].contentTranslateKey, lekcje[acctualLessonIndex].image, lekcje[acctualLessonIndex].image2); } } } public void ShowTutorialUpPopUp(Transform canvas_tramsform, string titleKey, string contentKey, Sprite imagecontent, Sprite imagecontent2) { if (currentTutorialPopUp != null) { return; } currentTutorialPopUp = UnityEngine.Object.Instantiate(TutorialPopUp, canvas_tramsform).GetComponent(); currentTutorialPopUp.titleText.text = LanguageManager.Instance.GetText(titleKey); currentTutorialPopUp.contentText.text = LanguageManager.Instance.GetText(contentKey); if (imagecontent != null || imagecontent2 != null) { currentTutorialPopUp.imageContainer.SetActive(value: true); if (imagecontent != null) { currentTutorialPopUp.ImageContent1.SetActive(value: true); currentTutorialPopUp.ImageContent1.GetComponent().sprite = imagecontent; } if (imagecontent2 != null) { currentTutorialPopUp.ImageContent2.SetActive(value: true); currentTutorialPopUp.ImageContent2.GetComponent().sprite = imagecontent2; } } InputManager.isCastNear = false; InputManager.isCastFar = false; playermain.firstPersonController.frezzePosition = true; playermain.firstPersonController.frezzeRotation = true; } public void ShowEndTutorialPopUp() { FScriptsHandler.Instance.m_HudManager.gameObject.SetActive(value: false); if (!(currentTutorialPopUp != null)) { currentTutorialPopUp = UnityEngine.Object.Instantiate(EndTutorialPopUp, FScriptsHandler.Instance.m_Canvas.transform).GetComponent(); playermain.firstPersonController.frezzePosition = true; playermain.firstPersonController.frezzeRotation = true; GameManager.Instance.SetMouseCurrsor(val: true); } } public void CloseTutorialUpPopUp() { FScriptsHandler.Instance.m_HudManager.gameObject.SetActive(value: true); if (!(currentTutorialPopUp == null)) { UnityEngine.Object.Destroy(currentTutorialPopUp.gameObject); currentTutorialPopUp = null; playermain.firstPersonController.UnFrezzeLook(); _ = acctualLessonIndex; _ = lekcje.Count; } } private IEnumerator ShowStartPopUp() { yield return new WaitForSeconds(0.3f); if (GameManager.Instance.controllerType == GameManager.ControllerType.GamePad) { ShowTutorialUpPopUp(FScriptsHandler.Instance.m_Canvas.transform, lekcje[0].GamePadtitleTranslateKey, lekcje[0].GamePadcontentTranslateKey, lekcje[0].image, lekcje[0].image2); } else { ShowTutorialUpPopUp(FScriptsHandler.Instance.m_Canvas.transform, lekcje[0].titleTranslateKey, lekcje[0].contentTranslateKey, lekcje[0].image, lekcje[0].image2); } } public void LoadTutorialEQ() { Debug.Log("[TutorialManager.cs] TutorialManager Start."); _previousPlayerRods = new List(Singleton.Instance.GetCurrentPlayerData().PlayerRods); _previousPlayerReels = new List(Singleton.Instance.GetCurrentPlayerData().PlayerReels); _previousPlayerLines = new List(Singleton.Instance.GetCurrentPlayerData().PlayerLines); _previousPlayerLeaders = new List(Singleton.Instance.GetCurrentPlayerData().PlayerLeaders); _previousPlayerBaits = new List(Singleton.Instance.GetCurrentPlayerData().PlayerBaits); _previousPlayerHooks = new List(Singleton.Instance.GetCurrentPlayerData().PlayerHooks); _previousPlayerFloats = new List(Singleton.Instance.GetCurrentPlayerData().PlayerFloats); _previousPlayerFeeders = new List(Singleton.Instance.GetCurrentPlayerData().PlayerFeeders); _previousPlayerWeights = new List(Singleton.Instance.GetCurrentPlayerData().PlayerWeights); _previousPlayerSlotsEquip = new List(Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip); Singleton.Instance.GetCurrentPlayerData().PlayerRods = PlayerRods; Singleton.Instance.GetCurrentPlayerData().PlayerReels = PlayerReels; Singleton.Instance.GetCurrentPlayerData().PlayerLines = PlayerLines; Singleton.Instance.GetCurrentPlayerData().PlayerLeaders = PlayerLeaders; Singleton.Instance.GetCurrentPlayerData().PlayerBaits = PlayerBaits; Singleton.Instance.GetCurrentPlayerData().PlayerHooks = PlayerHooks; Singleton.Instance.GetCurrentPlayerData().PlayerFloats = PlayerFloats; Singleton.Instance.GetCurrentPlayerData().PlayerFeeders = PlayerFeeders; Singleton.Instance.GetCurrentPlayerData().PlayerWeights = PlayerWeights; Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip = new List(PlayerSlotsEquip); } private void Start() { LoadTutorialEQ(); StartCoroutine(ShowStartPopUp()); } public void FishCatchPanelInvoke() { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } public void CheckLessonPopUpInvoke() { Debug.Log("INVOKE SIE WYKONA³"); if (acctualLessonIndex == 1) { CheckLessonPopUp(1); } else if (acctualLessonIndex == 2) { CheckLessonPopUp(2); } else if (acctualLessonIndex == 3) { CheckLessonPopUp(3); } else if (acctualLessonIndex == 4) { CheckLessonPopUp(4); } else if (acctualLessonIndex == 5) { CheckLessonPopUp(5); } else if (acctualLessonIndex == 6) { CheckLessonPopUp(6); } else if (acctualLessonIndex == 7) { CheckLessonPopUp(7); } else if (acctualLessonIndex == 8) { CheckLessonPopUp(8); } else if (acctualLessonIndex == 9) { CheckLessonPopUp(9); } else if (acctualLessonIndex == 10) { CheckLessonPopUp(10); } else if (acctualLessonIndex == 11) { CheckLessonPopUp(11); } else if (acctualLessonIndex == 12) { CheckLessonPopUp(13); } } private void Update() { if (!tutUpdateBool && acctualLessonIndex == 1 && Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[1].rod.status == GameManager.PlayerData.CRods.Status.InHand) { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } if (playermain != FScriptsHandler.Instance.m_PlayerMain) { playermain = FScriptsHandler.Instance.m_PlayerMain; } if (playermain != null && playermain.currentRod != null && playermain.currentRod.currentHook != null && !tutUpdateBool && acctualLessonIndex == 2 && playermain.currentRod.currentHook.transform.position.y < 0f && playermain.currentRod.fishingLine.currentLineHandler.PhisicsLineOut > 2f) { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } if (!tutUpdateBool && acctualLessonIndex == 3 && playermain.currentRod.currentHook.transform.position.y > 0f && playermain.currentRod.fishingLine.currentLineHandler.PhisicsLineOut == 0f) { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } if (!tutUpdateBool && acctualLessonIndex == 4 && playermain.currentRod.currentHook.transform.position.y <= 0f && playermain.currentRod.fishingLine.currentLineHandler.PhisicsLineOut > 2f) { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } if (!tutUpdateBool && acctualLessonIndex == 5 && playermain.currentRod.currentHook.transform.position.y <= 0f && (bool)FishEntity.CurrentFishInFight && !FishEntity.CurrentFishInFight.IsHooked) { tutUpdateBool = true; CheckLessonPopUpInvoke(); } if (!tutUpdateBool && acctualLessonIndex == 6 && playermain.currentRod.currentHook.transform.position.y <= 0f && (bool)FishEntity.CurrentFishInFight) { tutUpdateBool = true; CheckLessonPopUpInvoke(); } if (!tutUpdateBool && acctualLessonIndex == 7 && GameManager.Instance.fishCatchPanel != null) { tutUpdateBool = true; CheckLessonPopUpInvoke(); } if (!tutUpdateBool && acctualLessonIndex == 8 && Singleton.Instance.GetCurrentPlayerData().PlayerSlotsEquip[0].rod.status == GameManager.PlayerData.CRods.Status.InHand) { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } if ((bool)playermain && playermain.currentRod != null && playermain.currentRod.currentLure != null && !tutUpdateBool && acctualLessonIndex == 9 && playermain.currentRod.currentLure.transform.position.y <= 0f && playermain.currentRod.fishingLine.currentLineHandler.PhisicsLineOut > 2f) { tutUpdateBool = true; Invoke("CheckLessonPopUpInvoke", 2f); } if (!tutUpdateBool && acctualLessonIndex == 10 && GameManager.Instance.fishCatchPanel != null) { tutUpdateBool = true; CheckLessonPopUpInvoke(); } } }