Advertisement
jretchy

Untitled

May 17th, 2022
472
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2.     public PlayableDirector timeline;
  3.  
  4.     private GameObject mainCam;
  5.     public Camera cutsceneCam;
  6.  
  7.     public GameObject playerIdle;
  8.     private GameObject text;
  9.     private GameObject player;
  10.  
  11.     private GameObject journalUpdated;
  12.  
  13.     public bool hasFinishedTalking;
  14.  
  15.     private void Start()
  16.     {
  17.         text = GameObject.Find("Main Camera/ExtraUI/TalkToMarcus");
  18.         mainCam = GameObject.Find("Main Camera");
  19.         player = GameObject.Find("Player");
  20.         journalUpdated = GameObject.Find("Main Camera/ExtraUI/JournalUpdated");
  21.  
  22.         text.SetActive(false);
  23.         playerIdle.SetActive(false);
  24.  
  25.         cutsceneCam.enabled = false;
  26.  
  27.         hasFinishedTalking = false;
  28.     }
  29.  
  30.  
  31.     private void OnTriggerEnter2D(Collider2D col)
  32.     {
  33.         if (col.gameObject.CompareTag("Player"))
  34.         {
  35.             text.SetActive(true);
  36.         }
  37.     }
  38.  
  39.     private void OnTriggerExit2D(Collider2D col)
  40.     {
  41.         if (col.gameObject.CompareTag("Player"))
  42.         {
  43.             text.SetActive(false);
  44.         }
  45.     }
  46.  
  47.  
  48.     private void Update()
  49.     {
  50.         if (text.activeInHierarchy == true && Input.GetKeyDown(KeyCode.E))
  51.         {
  52.             text.SetActive(false);
  53.             timeline.Play();
  54.             StartCoroutine(CutsceneAspects());
  55.         }
  56.     }
  57.  
  58.  
  59.     IEnumerator CutsceneAspects()
  60.     {
  61.         yield return new WaitForSeconds(0.9f);
  62.         player.GetComponent<SpriteRenderer>().enabled = false;
  63.         mainCam.SetActive(false);
  64.         cutsceneCam.enabled = true;
  65.  
  66.         cutsceneCam.GetComponent<AudioListener>().enabled = true;
  67.         mainCam.GetComponent<AudioListener>().enabled = false;
  68.  
  69.         yield return new WaitForSeconds(84.4333333333333f);
  70.         player.GetComponent<SpriteRenderer>().enabled = true;
  71.         mainCam.SetActive(true);
  72.         cutsceneCam.enabled = false;
  73.         FindObjectOfType<PlayerMovement>().hasTalkedToMarcus = true;
  74.  
  75.         this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
  76.  
  77.         cutsceneCam.GetComponent<AudioListener>().enabled = false;
  78.         mainCam.GetComponent<AudioListener>().enabled = true;
  79.  
  80.         hasFinishedTalking = true;
  81.  
  82.         yield return new WaitForSeconds(1);
  83.         journalUpdated.GetComponent<Animator>().SetBool("JournalUpdated", true);
  84.  
  85.         yield return new WaitForSeconds(7);
  86.         journalUpdated.GetComponent<Animator>().SetBool("JournalUpdated", false);
  87.  
  88.         this.gameObject.GetComponent<BoxCollider2D>().enabled = false;
  89.     }
  90.  
Advertisement
RAW Paste Data Copied
Advertisement