353 lines
13 KiB
C#
353 lines
13 KiB
C#
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<GameManager.PlayerData.CRods> PlayerRods;
|
|
|
|
public List<GameManager.PlayerData.CReels> PlayerReels;
|
|
|
|
public List<GameManager.PlayerData.CLines> PlayerLines;
|
|
|
|
public List<GameManager.PlayerData.CLeaders> PlayerLeaders;
|
|
|
|
public List<GameManager.PlayerData.CBaits> PlayerBaits;
|
|
|
|
public List<GameManager.PlayerData.CHooks> PlayerHooks;
|
|
|
|
public List<GameManager.PlayerData.CFloats> PlayerFloats;
|
|
|
|
public List<GameManager.PlayerData.CFeeders> PlayerFeeders;
|
|
|
|
public List<GameManager.PlayerData.CWeights> PlayerWeights;
|
|
|
|
public List<GameManager.PlayerData.CSlots> PlayerSlotsEquip;
|
|
|
|
public List<GameManager.PlayerData.CRods> _previousPlayerRods;
|
|
|
|
public List<GameManager.PlayerData.CReels> _previousPlayerReels;
|
|
|
|
public List<GameManager.PlayerData.CLines> _previousPlayerLines;
|
|
|
|
public List<GameManager.PlayerData.CLeaders> _previousPlayerLeaders;
|
|
|
|
public List<GameManager.PlayerData.CBaits> _previousPlayerBaits;
|
|
|
|
public List<GameManager.PlayerData.CHooks> _previousPlayerHooks;
|
|
|
|
public List<GameManager.PlayerData.CFloats> _previousPlayerFloats;
|
|
|
|
public List<GameManager.PlayerData.CFeeders> _previousPlayerFeeders;
|
|
|
|
public List<GameManager.PlayerData.CWeights> _previousPlayerWeights;
|
|
|
|
public List<GameManager.PlayerData.CSlots> _previousPlayerSlotsEquip;
|
|
|
|
public int acctualLessonIndex;
|
|
|
|
public bool tutUpdateBool;
|
|
|
|
public List<Steps> lekcje = new List<Steps>();
|
|
|
|
[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<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerRods = _previousPlayerRods;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerReels = _previousPlayerReels;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLines = _previousPlayerLines;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLeaders = _previousPlayerLeaders;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerBaits = _previousPlayerBaits;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerHooks = _previousPlayerHooks;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFloats = _previousPlayerFloats;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFeeders = _previousPlayerFeeders;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerWeights = _previousPlayerWeights;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerSlotsEquip = new List<GameManager.PlayerData.CSlots>(_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<TutorialPopUpItem>();
|
|
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<Image>().sprite = imagecontent;
|
|
}
|
|
if (imagecontent2 != null)
|
|
{
|
|
currentTutorialPopUp.ImageContent2.SetActive(value: true);
|
|
currentTutorialPopUp.ImageContent2.GetComponent<Image>().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<TutorialPopUpItem>();
|
|
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<GameManager.PlayerData.CRods>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerRods);
|
|
_previousPlayerReels = new List<GameManager.PlayerData.CReels>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerReels);
|
|
_previousPlayerLines = new List<GameManager.PlayerData.CLines>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLines);
|
|
_previousPlayerLeaders = new List<GameManager.PlayerData.CLeaders>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLeaders);
|
|
_previousPlayerBaits = new List<GameManager.PlayerData.CBaits>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerBaits);
|
|
_previousPlayerHooks = new List<GameManager.PlayerData.CHooks>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerHooks);
|
|
_previousPlayerFloats = new List<GameManager.PlayerData.CFloats>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFloats);
|
|
_previousPlayerFeeders = new List<GameManager.PlayerData.CFeeders>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFeeders);
|
|
_previousPlayerWeights = new List<GameManager.PlayerData.CWeights>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerWeights);
|
|
_previousPlayerSlotsEquip = new List<GameManager.PlayerData.CSlots>(Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerSlotsEquip);
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerRods = PlayerRods;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerReels = PlayerReels;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLines = PlayerLines;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerLeaders = PlayerLeaders;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerBaits = PlayerBaits;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerHooks = PlayerHooks;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFloats = PlayerFloats;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerFeeders = PlayerFeeders;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerWeights = PlayerWeights;
|
|
Singleton<SaveDataManager>.Instance.GetCurrentPlayerData().PlayerSlotsEquip = new List<GameManager.PlayerData.CSlots>(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<SaveDataManager>.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<SaveDataManager>.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();
|
|
}
|
|
}
|
|
}
|