l3enjamin

CyberSiege VR - Tutorial.cs

May 8th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 14.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class SwitchPath : MonoBehaviour {
  6.  
  7.     public GameObject TutorialWall, Gate, WayOne, WayTwo, WayFour, AttractPath, Lhand, Chime, Rhand, SkipButton, Boulder, TutorialWayOne, TutorialWayTwo, TutorialWayThree, RLaser, LLaser, Right, Left, Enemy, Ammo, Min, MinionSpawnOne, MinionSpawnTwo, MinionSpawnThree, Player, GUI, EnemyPositionOne, EnemyPositionTwo, EnemyPositionThree, TutorialInfoOne, TutorialInfoTwo, TutorialInfoThree, TutorialInfoFour, FinalGate;
  8.     public bool PathChangedOne, PathChangedTwo, CannonTouched, AttractMode, HealthTouched, SummonMinionsTouched, SoundOne, SoundTwo, SoundThree, SoundFour, SoundFive, SoundSix, TutorialInfoEnabled, ChangeOne, ChangeTwo, ChangeThree, ChangeFour, ChangeFive, ChangeSix, ChangeSeven, AmmoDetached, BulletFired, MinionDirected, MinionsEnabled, PathChangedFromOneToTwo, PathChangedFromTwoToThree, PathChangedFromThreeToGamePath, AmmoDeposited, TowerAttacked, MinionsSpawned, AllEnemiesDead;
  9.     public float Death, TowerDeath, Timer, TargetTime = 60f;
  10.     public int AmmoDetachCount;
  11.     public Vector3 StartPosition;
  12.     public GameObject[] StageOneTowers;
  13.     public Quaternion Rotation;
  14.  
  15.     void Start () {
  16.         WayOne = GameObject.FindGameObjectWithTag ("WayOne");
  17.         WayTwo = GameObject.FindGameObjectWithTag ("WayTwo");
  18.         WayFour = GameObject.FindGameObjectWithTag ("WayFour");
  19.         Ammo = GameObject.FindGameObjectWithTag ("Ammo");
  20.         TutorialWayOne = GameObject.FindGameObjectWithTag ("Tut1");
  21.         TutorialWayTwo = GameObject.FindGameObjectWithTag ("Tut2");
  22.         TutorialWayThree = GameObject.FindGameObjectWithTag ("Tut3");
  23.         Player = GameObject.FindGameObjectWithTag ("Player");
  24.         MinionSpawnOne = transform.Find ("DropOffPoint").gameObject.transform.Find ("spawn1").gameObject;
  25.         MinionSpawnTwo = transform.Find ("DropOffPoint").gameObject.transform.Find ("spawn2").gameObject;
  26.         MinionSpawnThree = transform.Find ("DropOffPoint").gameObject.transform.Find ("spawn3").gameObject;
  27.         GUI = transform.Find ("3DGUI").gameObject;
  28.         SkipButton = transform.Find ("CyberMonitorControls").gameObject.transform.Find ("ControlPanelPadArrowSkip").gameObject;
  29.         EnemyPositionOne = transform.Find ("EneTutSpawn1").gameObject;
  30.         EnemyPositionTwo = transform.Find ("EneTutSpawn2").gameObject;
  31.         EnemyPositionThree = transform.Find ("EneTutSpawn3").gameObject;
  32.         TutorialInfoOne = transform.Find ("TutorialInfoOne").gameObject;
  33.         TutorialInfoTwo = transform.Find ("TutorialInfoTwo").gameObject;
  34.         TutorialInfoThree = transform.Find ("TutorialInfoThree").gameObject;
  35.         TutorialInfoFour = transform.Find ("TutorialInfoFour").gameObject;
  36.         TutorialInfoOne.SetActive (false);
  37.         TutorialInfoTwo.SetActive (false);
  38.         TutorialInfoThree.SetActive (false);
  39.         TutorialInfoFour.SetActive (false);
  40.         TutorialWall = GameObject.FindGameObjectWithTag("Barrier");
  41.         AttractPath = GameObject.FindGameObjectWithTag("AttractPath");
  42.         StartPosition = transform.position;
  43.         Rotation = transform.rotation;
  44.         Boulder = transform.Find ("DropOffPoint").gameObject;
  45.     }
  46.  
  47.     void Update () {
  48.         //Search for the left and right hands until they are found
  49.         if (Rhand == null && Lhand == null) {
  50.             Rhand = GameObject.FindGameObjectWithTag ("Directing");
  51.             Lhand = GameObject.FindGameObjectWithTag ("Gun");
  52.         }
  53.         //Find the gate
  54.         if (Gate == null) {
  55.             Gate = GameObject.FindGameObjectWithTag ("Gate");
  56.         }
  57.         //If the gate dies and the path hasn't been changed, change the path
  58.         if (Gate == null && PathChangedOne == false) {
  59.             GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
  60.             GetComponent<MoveOnPath> ().PathToFollow = WayTwo.GetComponent<EditorPathing> ();
  61.             GetComponent<MoveOnPath> ().Speed = GetComponent<MoveOnPath> ().InitialSpeed;
  62.             foreach (GameObject tow in StageOneTowers) {
  63.                 Destroy (tow);
  64.             }
  65.             PathChangedOne = true;
  66.         }
  67.         //Find the finalgate
  68.         if (FinalGate == null) {
  69.             FinalGate = GameObject.FindGameObjectWithTag ("FinalGate");
  70.         }
  71.         //If the gate is dead and the second path hasn't been changed, change the path
  72.         if (FinalGate == null && PathChangedTwo == false) {
  73.             GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
  74.             GetComponent<MoveOnPath> ().PathToFollow = WayFour.GetComponent<EditorPathing> ();
  75.             GetComponent<MoveOnPath> ().Speed = 15f;
  76.             Player.GetComponent<PlayerStats> ().Low.SetActive (false);
  77.             Player.GetComponent<PlayerStats> ().High.SetActive (false);
  78.             PathChangedTwo = true;
  79.         }
  80.         //Tutorial Part One
  81.         if (GUI.GetComponent<GUIManager> ().TutorialStarted == true) {
  82.             if (GUI.GetComponent<GUIManager> ().TutorialPathOne == true) {
  83.                 GetComponent<MoveOnPath> ().PathToFollow = TutorialWayOne.GetComponent<EditorPathing> ();
  84.                 GetComponent<MoveOnPath> ().enabled = true;
  85.                 GetComponent<MinionRecaller> ().enabled = true;
  86.                 if (GetComponent<MoveOnPath> ().CurrentWaypointID == 2) {
  87.                     GetComponent<MoveOnPath> ().enabled = false;
  88.                     if (MinionsEnabled == false) {
  89.                         Instantiate (Min, MinionSpawnOne.transform.position, transform.rotation);
  90.                         Instantiate (Min, MinionSpawnTwo.transform.position, transform.rotation);
  91.                         Instantiate (Min, MinionSpawnThree.transform.position, transform.rotation);
  92.                         if (RLaser != null && LLaser != null) {
  93.                             RLaser.SetActive (true);
  94.                             LLaser.SetActive (true);
  95.                         }
  96.                         TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (true);
  97.                         TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
  98.                         TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
  99.                         TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
  100.                         TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
  101.                         MinionsEnabled = true;
  102.                     }
  103.                     Ammo.GetComponent<DropOffScript> ().BoulderCount = 20;
  104.                     TutorialInfoOne.SetActive (true);
  105.                     GUI.GetComponent<GUIManager> ().ControlPanel.SetActive (true);
  106.                     GUI.GetComponent<GUIManager> ().KillCounter.SetActive (true);
  107.                     GUI.GetComponent<GUIManager> ().CannonPanel.SetActive (true);
  108.                     GUI.GetComponent<GUIManager> ().AmmoCounter.SetActive (true);
  109.                     if (Right != null && Left != null) {
  110.                         Right.GetComponent<PlayerShoot> ().enabled = true;
  111.                         Left.GetComponent<DirectMinions> ().enabled = true;
  112.                     }
  113.                 }
  114.             }
  115.             //Tutorial requirments
  116.             if (BulletFired && !ChangeOne) {
  117.                 TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
  118.                 TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
  119.                 TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
  120.                 TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
  121.                 TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (true);
  122.                 ChangeOne = true;
  123.             }
  124.             if (BulletFired) {
  125.                 if (MinionDirected && !ChangeTwo) {
  126.                     TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
  127.                     TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
  128.                     TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
  129.                     TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
  130.                     TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (true);
  131.                     ChangeTwo = true;
  132.                 }
  133.             }
  134.             if (MinionDirected && BulletFired) {
  135.                 if (HealthTouched && !ChangeThree) {
  136.                     TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
  137.                     TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
  138.                     TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
  139.                     TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
  140.                     TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (true);
  141.                     ChangeThree = true;
  142.                 }
  143.             }
  144.             if (HealthTouched && BulletFired && MinionDirected) {
  145.                 if (!SoundOne) {
  146.                     Instantiate (Chime, transform.position, transform.rotation);
  147.                     SoundOne = true;
  148.                 }
  149.                 if (SummonMinionsTouched && !ChangeFour) {
  150.                     TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
  151.                     TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
  152.                     TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
  153.                     TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
  154.                     TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (true);
  155.                     ChangeFour = true;
  156.                 }
  157.             }
  158.             if (SummonMinionsTouched && HealthTouched && BulletFired && MinionDirected) {
  159.                 if (!SoundTwo) {
  160.                     Instantiate (Chime, transform.position, transform.rotation);
  161.                     SoundTwo = true;
  162.                 }
  163.                 if (CannonTouched && !ChangeFive) {
  164.                     TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
  165.                     TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
  166.                     TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
  167.                     TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
  168.                     TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
  169.                     ChangeFive = true;
  170.                 }
  171.             }
  172.             //When all the tutorial reqs are completed, change to the second tutorial path
  173.             if (CannonTouched && HealthTouched && SummonMinionsTouched && BulletFired && MinionDirected) {
  174.                 if (!SoundThree) {
  175.                     Instantiate (Chime, transform.position, transform.rotation);
  176.                     SoundThree = true;
  177.                 }
  178.                 if (PathChangedFromOneToTwo == false) {
  179.                     GUI.GetComponent<GUIManager> ().TutorialPathOne = false;
  180.                     GetComponent<MoveOnPath> ().enabled = true;
  181.                     GetComponent<MoveOnPath> ().PathToFollow = TutorialWayTwo.GetComponent<EditorPathing> ();
  182.                     GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
  183.                     GUI.GetComponent<GUIManager> ().TutorialPathTwo = true;
  184.                     PathChangedFromOneToTwo = true;
  185.                 }
  186.             }
  187.             if (GUI.GetComponent<GUIManager> ().TutorialPathTwo == true) {
  188.                 if (GetComponent<MoveOnPath> ().CurrentWaypointID == 2) {
  189.                     GetComponent<MoveOnPath> ().enabled = false;
  190.                     TutorialInfoTwo.SetActive (true);
  191.                     TutorialInfoOne.SetActive (false);
  192.                     if (MinionsSpawned == false) {
  193.                         Instantiate (Enemy, EnemyPositionOne.transform.position, transform.rotation);
  194.                         Instantiate (Enemy, EnemyPositionTwo.transform.position, transform.rotation);
  195.                         Instantiate (Enemy, EnemyPositionThree.transform.position, transform.rotation);
  196.                         MinionsSpawned = true;
  197.                     }
  198.                     if (Death >= 3) {
  199.                         AllEnemiesDead = true;
  200.                     }
  201.                     //Tutorial requirement
  202.                     if (AllEnemiesDead) {
  203.                         //Change to tutorial path 3
  204.                         if (PathChangedFromTwoToThree == false) {
  205.                             GUI.GetComponent<GUIManager> ().TutorialPathTwo = false;
  206.                             GetComponent<MoveOnPath> ().enabled = true;
  207.                             TutorialWall.GetComponent<Animation> ().Play ();
  208.                             GetComponent<MoveOnPath> ().PathToFollow = TutorialWayThree.GetComponent<EditorPathing> ();
  209.                             GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
  210.                             GUI.GetComponent<GUIManager> ().TutorialPathThree = true;
  211.                             PathChangedFromTwoToThree = true;
  212.                         }
  213.                     }
  214.                 }
  215.             }
  216.             if (GUI.GetComponent<GUIManager> ().TutorialPathThree == true) {
  217.                 if (GetComponent<MoveOnPath> ().CurrentWaypointID == 2) {
  218.                     TutorialInfoThree.SetActive (true);
  219.                     TutorialInfoTwo.SetActive (false);
  220.                     if (!TutorialInfoEnabled) {
  221.                         TutorialInfoThree.transform.Find ("Tut1").gameObject.SetActive (true);
  222.                         TutorialInfoThree.transform.Find ("Tut2").gameObject.SetActive (false);
  223.                         TutorialInfoThree.transform.Find ("Tut3").gameObject.SetActive (false);
  224.                         TutorialInfoEnabled = true;
  225.                     }
  226.                     //Tutorial requirments
  227.                     if (TowerDeath >= 1) {
  228.                         if (!SoundFour) {
  229.                             Instantiate (Chime, transform.position, transform.rotation);
  230.                             SoundFour = true;
  231.                         }
  232.                         TowerAttacked = true;
  233.                     }
  234.                     GetComponent<MoveOnPath> ().enabled = false;
  235.                     if (AmmoDetachCount == 2) {
  236.                         AmmoDetached = true;
  237.                     }
  238.                     if (TowerAttacked && !ChangeSix) {
  239.                         if (!SoundSix) {
  240.                             Instantiate (Chime, transform.position, transform.rotation);
  241.                             SoundSix = true;
  242.                         }
  243.                         TutorialInfoThree.transform.Find ("Tut1").gameObject.SetActive (false);
  244.                         TutorialInfoThree.transform.Find ("Tut3").gameObject.SetActive (false);
  245.                         TutorialInfoThree.transform.Find ("Tut2").gameObject.SetActive (true);
  246.                         ChangeSix = true;
  247.                     }
  248.                     //If all the reqs are completed
  249.                     if (TowerAttacked && AmmoDeposited && AmmoDetached) {
  250.                         if (!SoundFive) {
  251.                             Instantiate (Chime, transform.position, transform.rotation);
  252.                             SoundFive = true;
  253.                         }
  254.                         //Change the path to game path and cleanup tutorial objects
  255.                         if (PathChangedFromThreeToGamePath == false) {
  256.                             GUI.GetComponent<GUIManager> ().TutorialPathThree = false;
  257.                             GetComponent<MoveOnPath> ().enabled = true;
  258.                             GetComponent<MoveOnPath> ().PathToFollow = WayOne.GetComponent<EditorPathing> ();
  259.                             GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
  260.                             GameObject[] minos = GameObject.FindGameObjectsWithTag ("Minion");
  261.                             foreach (GameObject Min in minos) {
  262.                                 Destroy (Min);
  263.                             }
  264.                             Destroy (TutorialWall);
  265.                             Destroy (SkipButton);
  266.                             Player.GetComponent<PlayerStats> ().Health = 50f;
  267.                             GUI.GetComponent<GUIManager> ().TutorialPathGame = true;
  268.                             PathChangedFromThreeToGamePath = true;
  269.                             TutorialInfoThree.SetActive (false);
  270.                             TutorialInfoFour.SetActive (true);
  271.                             GUI.GetComponent<GUIManager> ().TutorialStarted = false;
  272.                             GUI.GetComponent<GUIManager> ().Started = true;
  273.                             Boulder.GetComponent<DropOffScript>().BoulderCount = 20;
  274.                         }
  275.                     }
  276.                 }
  277.             }
  278.         }
  279.         //Counts up for attract mode
  280.         Timer += Time.deltaTime;
  281.         if (!GUI.GetComponent<GUIManager> ().TutorialStarted && !GUI.GetComponent<GUIManager> ().Started && !GUI.GetComponent<GUIManager>().EndSequenceFinished && !GUI.GetComponent<GUIManager>().ResultsFinished) {
  282.             if (Rhand != null && Lhand != null) {
  283.                 //If the player presses trigger on either controller, exit attract mode/reset the timer
  284.                 if (Rhand.GetComponent<TriggerHeld> ().Held == true || Lhand.GetComponent<TriggerHeld> ().Held == true) {
  285.                     if (AttractMode == true) {
  286.                         GUI.GetComponent<GUIManager> ().MainMenu.SetActive (true);
  287.                         GetComponent<MoveOnPath> ().enabled = false;
  288.                         Timer = 0;
  289.                         AttractMode = false;
  290.                         transform.position = StartPosition;
  291.                         transform.rotation = Rotation;
  292.                     }
  293.                 }
  294.                 //Assign attract path and close GUI screens
  295.                 if (Timer >= TargetTime && AttractMode == false) {
  296.                     GetComponent<MoveOnPath> ().enabled = true;
  297.                     GetComponent<MoveOnPath> ().PathToFollow = AttractPath.GetComponent<EditorPathing> ();
  298.                     GUI.GetComponent<GUIManager> ().Title.SetActive (false);
  299.                     GUI.GetComponent<GUIManager> ().MainMenu.SetActive (false);
  300.                     GUI.GetComponent<GUIManager> ().About.SetActive (false);
  301.                     GUI.GetComponent<GUIManager> ().Credits.SetActive (false);
  302.                     GUI.GetComponent<GUIManager> ().Pause.SetActive (false);
  303.                     AttractMode = true;
  304.                 }
  305.             }
  306.         }
  307.     }
  308. }
Advertisement
Add Comment
Please, Sign In to add comment