UnityGameProjectsCode / Rise2Point0Game / TutorialControl.cs
TutorialControl.cs
Raw
using UnityEngine;

public class TutorialControl : MonoBehaviour
{
    public GameObject dragAndReleaseLine;
    public GameObject cooldownLine;
    public GameObject forceIndicatorLine;
    public GameObject itemsLine;
    public GameObject shuffleAndLoopLine;
    public GameObject unlocksLine;

    public GameObject dragAndReleaseText;
    public GameObject cooldownText;
    public GameObject forceIndicatorText;
    public GameObject itemsText;
    public GameObject shuffleAndLoopText;
    public GameObject unlocksText;

    private ScoreManager scoreMgr;

    private bool dragAndReleaseDone;
    private bool cooldownDone;
    private bool forceIndicatorDone;
    private bool itemsDone;
    private bool shuffleAndLoopDone;
    private bool unlocksDone;

    private bool tutorialEnabled = true;

    private float timeSinceStart;

    private void Awake()
    {
        dragAndReleaseLine.SetActive(false);
        cooldownLine.SetActive(false);
        forceIndicatorLine.SetActive(false);
        itemsLine.SetActive(false);
        shuffleAndLoopLine.SetActive(false);
        unlocksLine.SetActive(false);

        dragAndReleaseText.SetActive(false);
        cooldownText.SetActive(false);
        forceIndicatorText.SetActive(false);
        itemsText.SetActive(false);
        shuffleAndLoopText.SetActive(false);
        unlocksText.SetActive(false);

        scoreMgr = GetComponent<ScoreManager>();
    }

    private void Update()
    {
        if (!GUIManager.GetMainMenuCanvasState() && !GUIManager.GetDeathCanvasState() && !GUIManager.GetPauseCanvasState() && !GUIManager.GetUnlocksPanelState() && !unlocksDone && tutorialEnabled)
        {
            timeSinceStart += Time.deltaTime;

            if (timeSinceStart >= 7 && !dragAndReleaseDone)
            {
                dragAndReleaseLine.SetActive(true);
                dragAndReleaseText.SetActive(true);
            }

            if (timeSinceStart >= 14 && !dragAndReleaseDone)
            {
                dragAndReleaseLine.SetActive(false);
                dragAndReleaseText.SetActive(false);
                dragAndReleaseDone = true;
            }

            if (timeSinceStart >= 20 && !cooldownDone)
            {
                cooldownLine.SetActive(true);
                cooldownText.SetActive(true);
            }

            if (timeSinceStart >= 27 && !cooldownDone)
            {
                cooldownLine.SetActive(false);
                cooldownText.SetActive(false);
                cooldownDone = true;
            }

            if (timeSinceStart >= 33 && !forceIndicatorDone)
            {
                forceIndicatorLine.SetActive(true);
                forceIndicatorText.SetActive(true);
            }

            if (timeSinceStart >= 40 && !forceIndicatorDone)
            {
                forceIndicatorLine.SetActive(false);
                forceIndicatorText.SetActive(false);
                forceIndicatorDone = true;
            }

            if (timeSinceStart >= 46 && scoreMgr.GetPlayerHeight() > 50 && !itemsDone)
            {
                itemsLine.SetActive(true);
                itemsText.SetActive(true);
            }

            if (timeSinceStart >= 53 && scoreMgr.GetPlayerHeight() > 50 && !itemsDone)
            {
                itemsLine.SetActive(false);
                itemsText.SetActive(false);
                itemsDone = true;
            }

            if (timeSinceStart >= 59 && !shuffleAndLoopDone)
            {
                shuffleAndLoopLine.SetActive(true);
                shuffleAndLoopText.SetActive(true);
            }

            if (timeSinceStart >= 66 && !shuffleAndLoopDone)
            {
                shuffleAndLoopLine.SetActive(false);
                shuffleAndLoopText.SetActive(false);
                shuffleAndLoopDone = true;
            }

            if (timeSinceStart >= 73 && scoreMgr.GetPlayerHeight() < 10 && !unlocksDone)
            {
                unlocksLine.SetActive(true);
                unlocksText.SetActive(true);
            }

            if (scoreMgr.GetPlayerHeight() > 10 && !unlocksDone && unlocksText.activeSelf)
            {
                unlocksLine.SetActive(false);
                unlocksText.SetActive(false);
                unlocksDone = true;
            }
        }
    }

    public void DisableTutorial(bool state)
    {
        tutorialEnabled = state;
    }

}