186 lines
6.7 KiB
C#
186 lines
6.7 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using TMPro;
|
|
using UnityEngine.Localization;
|
|
|
|
public class TutorialHint : MonoBehaviour
|
|
{
|
|
[TextArea(1,5)]
|
|
public string tutorialHint;
|
|
[TextArea(1, 5)]
|
|
public string tutorialHintXboxController;
|
|
//public TextMeshProUGUI tutorialHintText;
|
|
//public Image tutorialHintBackgroundPanel;
|
|
public Image[] tutorialImage;
|
|
[Range(1,10)]
|
|
public float timeToStayOnScreen = 5f;
|
|
public bool isGif;
|
|
|
|
public LocalizedString localizedTutorialHint;
|
|
public LocalizedString localizedTutorialHintController;
|
|
|
|
[Header("Stop previous tutorial Hint")]
|
|
[SerializeField] private TutorialHint _tutorialHint;
|
|
|
|
float imagecolorFadeSpeed;
|
|
float textcolorFadeSpeed;
|
|
float tutorialHintBackgroundPanelSpeed;
|
|
private bool tutorialHintPlayed;
|
|
public bool turorialHintShouldBeUpdating;
|
|
|
|
private void OnTriggerEnter(Collider col)
|
|
{
|
|
if (col.gameObject.CompareTag("Player") && !tutorialHintPlayed)
|
|
{
|
|
if (_tutorialHint != null)
|
|
{
|
|
_tutorialHint.StopTutorialHint();
|
|
}
|
|
turorialHintShouldBeUpdating = true;
|
|
StartCoroutine(DisplayTutorialHint());
|
|
TutorialHintTextUpdate();
|
|
tutorialHintPlayed = true;
|
|
}
|
|
}
|
|
|
|
public void StopTutorialHint()
|
|
{
|
|
turorialHintShouldBeUpdating = false;
|
|
StopAllCoroutines();
|
|
}
|
|
|
|
public IEnumerator DisplayTutorialHint()
|
|
{
|
|
//for (int i = 0; i < tutorialImage.Length; i++)
|
|
//{
|
|
// if (tutorialImage[i] != null)
|
|
// {
|
|
// foreach (Image _tutorialImage in tutorialImage)
|
|
// {
|
|
// if (isGif)
|
|
// {
|
|
// _tutorialImage.gameObject.SetActive(true);
|
|
// }
|
|
// else
|
|
// {
|
|
// tutorialImage[0].gameObject.SetActive(true);
|
|
// }
|
|
// while (imagecolorFadeSpeed <= 1f)
|
|
// {
|
|
// imagecolorFadeSpeed += 1f * Time.deltaTime;
|
|
// UIManager.GetInstance().tutorialHintBackgroundPanel.gameObject.SetActive(true);
|
|
// if(imagecolorFadeSpeed <= 0.7f)
|
|
// {
|
|
// UIManager.GetInstance().tutorialHintBackgroundPanel.color = new Color(1, 1, 1, imagecolorFadeSpeed);
|
|
// }
|
|
// _tutorialImage.color = new Color(1, 1, 1, imagecolorFadeSpeed);
|
|
// yield return null;
|
|
// }
|
|
// }
|
|
// }
|
|
//}
|
|
while (tutorialHintBackgroundPanelSpeed <= /*0.7f*/1)
|
|
{
|
|
tutorialHintBackgroundPanelSpeed += 1f * Time.deltaTime;
|
|
UIManager.GetInstance().tutorialHintBackgroundPanel.gameObject.SetActive(true);
|
|
UIManager.GetInstance().tutorialHintBackgroundPanel.color = new Color(0, 0, 0, tutorialHintBackgroundPanelSpeed);
|
|
|
|
textcolorFadeSpeed += 1f * Time.deltaTime;
|
|
UIManager.GetInstance().tutorialHintText.color = new Color(1, 1, 1, textcolorFadeSpeed);
|
|
yield return null;
|
|
}
|
|
//while (textcolorFadeSpeed <= 1f)
|
|
//{
|
|
// textcolorFadeSpeed += 1f * Time.deltaTime;
|
|
// //tutorialHintText.text = tutorialHint;
|
|
// //TutorialHintTextUpdate();
|
|
// UIManager.GetInstance().tutorialHintText.color = new Color(1, 1, 1, textcolorFadeSpeed);
|
|
// yield return null;
|
|
//}
|
|
|
|
if (isGif)
|
|
{
|
|
while (isGif) {
|
|
for (int i = 0; i < tutorialImage.Length; i++)
|
|
{
|
|
if (tutorialImage[i] != null)
|
|
{
|
|
for (int index = 0; index < tutorialImage.Length; index++)
|
|
{
|
|
int previousIndex;
|
|
tutorialImage[index].gameObject.SetActive(true);
|
|
previousIndex = index;
|
|
yield return new WaitForSeconds(1f);
|
|
tutorialImage[previousIndex].gameObject.SetActive(false);
|
|
index++;
|
|
if(index >= tutorialImage.Length)
|
|
{
|
|
isGif = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//TutorialHintTextUpdate();
|
|
yield return new WaitForSeconds(timeToStayOnScreen);
|
|
|
|
while (textcolorFadeSpeed >= 0f)
|
|
{
|
|
textcolorFadeSpeed -= 1f * Time.deltaTime;
|
|
UIManager.GetInstance().tutorialHintText.color = new Color(1, 1, 1, textcolorFadeSpeed);
|
|
|
|
tutorialHintBackgroundPanelSpeed -= 1f * Time.deltaTime;
|
|
UIManager.GetInstance().tutorialHintBackgroundPanel.color = new Color(0, 0, 0, tutorialHintBackgroundPanelSpeed);
|
|
|
|
for (int i = 0; i < tutorialImage.Length; i++)
|
|
{
|
|
if (tutorialImage[i] != null)
|
|
{
|
|
foreach (Image _tutorialImage in tutorialImage)
|
|
{
|
|
//_tutorialImage.gameObject.SetActive(true);
|
|
while (imagecolorFadeSpeed >= 0f)
|
|
{
|
|
imagecolorFadeSpeed -= 1f * Time.deltaTime;
|
|
_tutorialImage.color = new Color(1, 1, 1, imagecolorFadeSpeed);
|
|
UIManager.GetInstance().tutorialHintBackgroundPanel.color = new Color(1, 1, 1, imagecolorFadeSpeed);
|
|
turorialHintShouldBeUpdating = false;
|
|
print("IDK BRO");
|
|
yield return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
yield return null;
|
|
}
|
|
turorialHintShouldBeUpdating = false;
|
|
}
|
|
|
|
|
|
|
|
public void TutorialHintTextUpdate()
|
|
{
|
|
StartCoroutine(tutorialHintTextIsUpdating());
|
|
}
|
|
|
|
IEnumerator tutorialHintTextIsUpdating()
|
|
{
|
|
while (turorialHintShouldBeUpdating)
|
|
{
|
|
if (!InputControlManager.Getinstance().IsUsingJoystick)
|
|
{
|
|
UIManager.GetInstance().tutorialHintText.text = localizedTutorialHint.GetLocalizedString();
|
|
}
|
|
else
|
|
{
|
|
UIManager.GetInstance().tutorialHintText.text = localizedTutorialHintController.GetLocalizedString();
|
|
}
|
|
yield return null;
|
|
}
|
|
yield return null;
|
|
}
|
|
}
|