Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Rendering;
  5.  
  6. public class FinalCinematic : MonoBehaviour
  7. {
  8.     private bool movingPlayer = false;
  9.     private bool doOnce = false;
  10.     private float path;
  11.  
  12.     private Vector3 A;
  13.     private Vector3 B;
  14.     private Vector3 C;
  15.     private Vector3 D;
  16.     private Vector3 E;
  17.  
  18.     private GameObject player;  
  19.  
  20.     private Vector3 FirstLocation;
  21.     public Vector3 SecondLocation;
  22.     public GameObject ThirdLocation;
  23.     public GameObject EndLocation;
  24.     public GameObject EnemyBase;
  25.  
  26.     public VolumeProfile profile;
  27.  
  28.     public float speed;
  29.  
  30.     private Camera cam;
  31.     private GameManager gameManagerRef;
  32.  
  33.     private float score = 0;
  34.  
  35.     private void Start()
  36.     {
  37.  
  38.         cam = GetComponentInChildren<Camera>();
  39.         gameManagerRef = GameManager.GetInstance();
  40.         gameManagerRef.GetComponent<ObjectiveManager>().scoreDropOff += IncreaseScore;        
  41.     }
  42.  
  43.  
  44.  
  45.     private void Update()
  46.     {
  47.         if (movingPlayer)
  48.         {
  49.             A = Vector3.Lerp(FirstLocation,SecondLocation,path);
  50.             B = Vector3.Lerp(SecondLocation,ThirdLocation.transform.position,path);
  51.             C = Vector3.Lerp(ThirdLocation.transform.position,EndLocation.transform.position,path);
  52.             D = Vector3.Lerp(A,B,path);
  53.             E = Vector3.Lerp(B,C,path);
  54.             player.transform.position = Vector3.Lerp(D,E,path);
  55.             if (path < 0.9f)
  56.             {
  57.                 player.transform.rotation = Quaternion.LookRotation(Vector3.Lerp(D, E, (path + 0.01f)) - player.transform.position);
  58.  
  59.             }
  60.             if (path > 1)
  61.             {
  62.                 gameManagerRef.SetState((int)State.Win);
  63.             }
  64.             path += 0.15f * Time.deltaTime;
  65.         }
  66.     }
  67.  
  68.  
  69.     private void IncreaseScore()
  70.     {
  71.         score++;
  72.         if (score == 5)
  73.         {
  74.             player = gameManagerRef.PlayerRef;
  75.             FirstLocation = player.gameObject.transform.position;
  76.             SecondLocation = player.transform.position + player.gameObject.transform.forward * 50f;
  77.             player = player.gameObject;
  78.             player.GetComponent<FlyBehaviour>().enabled = false;
  79.             player.GetComponent<HealthBehaviour>().SetImmortal();
  80.  
  81.             movingPlayer = true;
  82.  
  83.  
  84.             doOnce = true;
  85.  
  86.  
  87.             cam.enabled = true;
  88.  
  89.             Camera.main.enabled = false;
  90.  
  91.             profile.components[6].active = false;
  92.  
  93.             EnemyBase.GetComponent<FinalExplosion>().BlowUpTower();
  94.  
  95.  
  96.             gameManagerRef.CanavasManagerRef.ToggleCutsceneMode(false);
  97.         }
  98.     }
  99.  
  100.  
  101.  
  102.  
  103.     private void OnTriggerEnter(Collider other)
  104.     {
  105.         if (other.tag == "Player" && doOnce == false)
  106.         {
  107.             print(other.gameObject.name);
  108.             FirstLocation = other.gameObject.transform.position;
  109.             SecondLocation = other.transform.position + other.gameObject.transform.forward * 50f;
  110.             player = other.gameObject;
  111.             player.GetComponent<FlyBehaviour>().enabled = false;
  112.             player.GetComponent<HealthBehaviour>().SetImmortal();
  113.  
  114.             movingPlayer = true;
  115.  
  116.  
  117.             doOnce = true;
  118.  
  119.  
  120.             cam.enabled = true;
  121.  
  122.             Camera.main.enabled = false;
  123.  
  124.             profile.components[6].active = false;
  125.  
  126.             EnemyBase.GetComponent<FinalExplosion>().BlowUpTower();
  127.  
  128.  
  129.             gameManagerRef.CanavasManagerRef.ToggleCutsceneMode(false);
  130.  
  131.         }
  132.     }
  133. }