Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class SwitchPath : MonoBehaviour {
- 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;
- 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;
- public float Death, TowerDeath, Timer, TargetTime = 60f;
- public int AmmoDetachCount;
- public Vector3 StartPosition;
- public GameObject[] StageOneTowers;
- public Quaternion Rotation;
- void Start () {
- WayOne = GameObject.FindGameObjectWithTag ("WayOne");
- WayTwo = GameObject.FindGameObjectWithTag ("WayTwo");
- WayFour = GameObject.FindGameObjectWithTag ("WayFour");
- Ammo = GameObject.FindGameObjectWithTag ("Ammo");
- TutorialWayOne = GameObject.FindGameObjectWithTag ("Tut1");
- TutorialWayTwo = GameObject.FindGameObjectWithTag ("Tut2");
- TutorialWayThree = GameObject.FindGameObjectWithTag ("Tut3");
- Player = GameObject.FindGameObjectWithTag ("Player");
- MinionSpawnOne = transform.Find ("DropOffPoint").gameObject.transform.Find ("spawn1").gameObject;
- MinionSpawnTwo = transform.Find ("DropOffPoint").gameObject.transform.Find ("spawn2").gameObject;
- MinionSpawnThree = transform.Find ("DropOffPoint").gameObject.transform.Find ("spawn3").gameObject;
- GUI = transform.Find ("3DGUI").gameObject;
- SkipButton = transform.Find ("CyberMonitorControls").gameObject.transform.Find ("ControlPanelPadArrowSkip").gameObject;
- EnemyPositionOne = transform.Find ("EneTutSpawn1").gameObject;
- EnemyPositionTwo = transform.Find ("EneTutSpawn2").gameObject;
- EnemyPositionThree = transform.Find ("EneTutSpawn3").gameObject;
- TutorialInfoOne = transform.Find ("TutorialInfoOne").gameObject;
- TutorialInfoTwo = transform.Find ("TutorialInfoTwo").gameObject;
- TutorialInfoThree = transform.Find ("TutorialInfoThree").gameObject;
- TutorialInfoFour = transform.Find ("TutorialInfoFour").gameObject;
- TutorialInfoOne.SetActive (false);
- TutorialInfoTwo.SetActive (false);
- TutorialInfoThree.SetActive (false);
- TutorialInfoFour.SetActive (false);
- TutorialWall = GameObject.FindGameObjectWithTag("Barrier");
- AttractPath = GameObject.FindGameObjectWithTag("AttractPath");
- StartPosition = transform.position;
- Rotation = transform.rotation;
- Boulder = transform.Find ("DropOffPoint").gameObject;
- }
- void Update () {
- //Search for the left and right hands until they are found
- if (Rhand == null && Lhand == null) {
- Rhand = GameObject.FindGameObjectWithTag ("Directing");
- Lhand = GameObject.FindGameObjectWithTag ("Gun");
- }
- //Find the gate
- if (Gate == null) {
- Gate = GameObject.FindGameObjectWithTag ("Gate");
- }
- //If the gate dies and the path hasn't been changed, change the path
- if (Gate == null && PathChangedOne == false) {
- GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
- GetComponent<MoveOnPath> ().PathToFollow = WayTwo.GetComponent<EditorPathing> ();
- GetComponent<MoveOnPath> ().Speed = GetComponent<MoveOnPath> ().InitialSpeed;
- foreach (GameObject tow in StageOneTowers) {
- Destroy (tow);
- }
- PathChangedOne = true;
- }
- //Find the finalgate
- if (FinalGate == null) {
- FinalGate = GameObject.FindGameObjectWithTag ("FinalGate");
- }
- //If the gate is dead and the second path hasn't been changed, change the path
- if (FinalGate == null && PathChangedTwo == false) {
- GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
- GetComponent<MoveOnPath> ().PathToFollow = WayFour.GetComponent<EditorPathing> ();
- GetComponent<MoveOnPath> ().Speed = 15f;
- Player.GetComponent<PlayerStats> ().Low.SetActive (false);
- Player.GetComponent<PlayerStats> ().High.SetActive (false);
- PathChangedTwo = true;
- }
- //Tutorial Part One
- if (GUI.GetComponent<GUIManager> ().TutorialStarted == true) {
- if (GUI.GetComponent<GUIManager> ().TutorialPathOne == true) {
- GetComponent<MoveOnPath> ().PathToFollow = TutorialWayOne.GetComponent<EditorPathing> ();
- GetComponent<MoveOnPath> ().enabled = true;
- GetComponent<MinionRecaller> ().enabled = true;
- if (GetComponent<MoveOnPath> ().CurrentWaypointID == 2) {
- GetComponent<MoveOnPath> ().enabled = false;
- if (MinionsEnabled == false) {
- Instantiate (Min, MinionSpawnOne.transform.position, transform.rotation);
- Instantiate (Min, MinionSpawnTwo.transform.position, transform.rotation);
- Instantiate (Min, MinionSpawnThree.transform.position, transform.rotation);
- if (RLaser != null && LLaser != null) {
- RLaser.SetActive (true);
- LLaser.SetActive (true);
- }
- TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (true);
- TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
- MinionsEnabled = true;
- }
- Ammo.GetComponent<DropOffScript> ().BoulderCount = 20;
- TutorialInfoOne.SetActive (true);
- GUI.GetComponent<GUIManager> ().ControlPanel.SetActive (true);
- GUI.GetComponent<GUIManager> ().KillCounter.SetActive (true);
- GUI.GetComponent<GUIManager> ().CannonPanel.SetActive (true);
- GUI.GetComponent<GUIManager> ().AmmoCounter.SetActive (true);
- if (Right != null && Left != null) {
- Right.GetComponent<PlayerShoot> ().enabled = true;
- Left.GetComponent<DirectMinions> ().enabled = true;
- }
- }
- }
- //Tutorial requirments
- if (BulletFired && !ChangeOne) {
- TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (true);
- ChangeOne = true;
- }
- if (BulletFired) {
- if (MinionDirected && !ChangeTwo) {
- TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (true);
- ChangeTwo = true;
- }
- }
- if (MinionDirected && BulletFired) {
- if (HealthTouched && !ChangeThree) {
- TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (true);
- ChangeThree = true;
- }
- }
- if (HealthTouched && BulletFired && MinionDirected) {
- if (!SoundOne) {
- Instantiate (Chime, transform.position, transform.rotation);
- SoundOne = true;
- }
- if (SummonMinionsTouched && !ChangeFour) {
- TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (true);
- ChangeFour = true;
- }
- }
- if (SummonMinionsTouched && HealthTouched && BulletFired && MinionDirected) {
- if (!SoundTwo) {
- Instantiate (Chime, transform.position, transform.rotation);
- SoundTwo = true;
- }
- if (CannonTouched && !ChangeFive) {
- TutorialInfoOne.transform.Find ("Tut1").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut4").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut5").gameObject.SetActive (false);
- TutorialInfoOne.transform.Find ("Tut6").gameObject.SetActive (false);
- ChangeFive = true;
- }
- }
- //When all the tutorial reqs are completed, change to the second tutorial path
- if (CannonTouched && HealthTouched && SummonMinionsTouched && BulletFired && MinionDirected) {
- if (!SoundThree) {
- Instantiate (Chime, transform.position, transform.rotation);
- SoundThree = true;
- }
- if (PathChangedFromOneToTwo == false) {
- GUI.GetComponent<GUIManager> ().TutorialPathOne = false;
- GetComponent<MoveOnPath> ().enabled = true;
- GetComponent<MoveOnPath> ().PathToFollow = TutorialWayTwo.GetComponent<EditorPathing> ();
- GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
- GUI.GetComponent<GUIManager> ().TutorialPathTwo = true;
- PathChangedFromOneToTwo = true;
- }
- }
- if (GUI.GetComponent<GUIManager> ().TutorialPathTwo == true) {
- if (GetComponent<MoveOnPath> ().CurrentWaypointID == 2) {
- GetComponent<MoveOnPath> ().enabled = false;
- TutorialInfoTwo.SetActive (true);
- TutorialInfoOne.SetActive (false);
- if (MinionsSpawned == false) {
- Instantiate (Enemy, EnemyPositionOne.transform.position, transform.rotation);
- Instantiate (Enemy, EnemyPositionTwo.transform.position, transform.rotation);
- Instantiate (Enemy, EnemyPositionThree.transform.position, transform.rotation);
- MinionsSpawned = true;
- }
- if (Death >= 3) {
- AllEnemiesDead = true;
- }
- //Tutorial requirement
- if (AllEnemiesDead) {
- //Change to tutorial path 3
- if (PathChangedFromTwoToThree == false) {
- GUI.GetComponent<GUIManager> ().TutorialPathTwo = false;
- GetComponent<MoveOnPath> ().enabled = true;
- TutorialWall.GetComponent<Animation> ().Play ();
- GetComponent<MoveOnPath> ().PathToFollow = TutorialWayThree.GetComponent<EditorPathing> ();
- GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
- GUI.GetComponent<GUIManager> ().TutorialPathThree = true;
- PathChangedFromTwoToThree = true;
- }
- }
- }
- }
- if (GUI.GetComponent<GUIManager> ().TutorialPathThree == true) {
- if (GetComponent<MoveOnPath> ().CurrentWaypointID == 2) {
- TutorialInfoThree.SetActive (true);
- TutorialInfoTwo.SetActive (false);
- if (!TutorialInfoEnabled) {
- TutorialInfoThree.transform.Find ("Tut1").gameObject.SetActive (true);
- TutorialInfoThree.transform.Find ("Tut2").gameObject.SetActive (false);
- TutorialInfoThree.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoEnabled = true;
- }
- //Tutorial requirments
- if (TowerDeath >= 1) {
- if (!SoundFour) {
- Instantiate (Chime, transform.position, transform.rotation);
- SoundFour = true;
- }
- TowerAttacked = true;
- }
- GetComponent<MoveOnPath> ().enabled = false;
- if (AmmoDetachCount == 2) {
- AmmoDetached = true;
- }
- if (TowerAttacked && !ChangeSix) {
- if (!SoundSix) {
- Instantiate (Chime, transform.position, transform.rotation);
- SoundSix = true;
- }
- TutorialInfoThree.transform.Find ("Tut1").gameObject.SetActive (false);
- TutorialInfoThree.transform.Find ("Tut3").gameObject.SetActive (false);
- TutorialInfoThree.transform.Find ("Tut2").gameObject.SetActive (true);
- ChangeSix = true;
- }
- //If all the reqs are completed
- if (TowerAttacked && AmmoDeposited && AmmoDetached) {
- if (!SoundFive) {
- Instantiate (Chime, transform.position, transform.rotation);
- SoundFive = true;
- }
- //Change the path to game path and cleanup tutorial objects
- if (PathChangedFromThreeToGamePath == false) {
- GUI.GetComponent<GUIManager> ().TutorialPathThree = false;
- GetComponent<MoveOnPath> ().enabled = true;
- GetComponent<MoveOnPath> ().PathToFollow = WayOne.GetComponent<EditorPathing> ();
- GetComponent<MoveOnPath> ().CurrentWaypointID = 0;
- GameObject[] minos = GameObject.FindGameObjectsWithTag ("Minion");
- foreach (GameObject Min in minos) {
- Destroy (Min);
- }
- Destroy (TutorialWall);
- Destroy (SkipButton);
- Player.GetComponent<PlayerStats> ().Health = 50f;
- GUI.GetComponent<GUIManager> ().TutorialPathGame = true;
- PathChangedFromThreeToGamePath = true;
- TutorialInfoThree.SetActive (false);
- TutorialInfoFour.SetActive (true);
- GUI.GetComponent<GUIManager> ().TutorialStarted = false;
- GUI.GetComponent<GUIManager> ().Started = true;
- Boulder.GetComponent<DropOffScript>().BoulderCount = 20;
- }
- }
- }
- }
- }
- //Counts up for attract mode
- Timer += Time.deltaTime;
- if (!GUI.GetComponent<GUIManager> ().TutorialStarted && !GUI.GetComponent<GUIManager> ().Started && !GUI.GetComponent<GUIManager>().EndSequenceFinished && !GUI.GetComponent<GUIManager>().ResultsFinished) {
- if (Rhand != null && Lhand != null) {
- //If the player presses trigger on either controller, exit attract mode/reset the timer
- if (Rhand.GetComponent<TriggerHeld> ().Held == true || Lhand.GetComponent<TriggerHeld> ().Held == true) {
- if (AttractMode == true) {
- GUI.GetComponent<GUIManager> ().MainMenu.SetActive (true);
- GetComponent<MoveOnPath> ().enabled = false;
- Timer = 0;
- AttractMode = false;
- transform.position = StartPosition;
- transform.rotation = Rotation;
- }
- }
- //Assign attract path and close GUI screens
- if (Timer >= TargetTime && AttractMode == false) {
- GetComponent<MoveOnPath> ().enabled = true;
- GetComponent<MoveOnPath> ().PathToFollow = AttractPath.GetComponent<EditorPathing> ();
- GUI.GetComponent<GUIManager> ().Title.SetActive (false);
- GUI.GetComponent<GUIManager> ().MainMenu.SetActive (false);
- GUI.GetComponent<GUIManager> ().About.SetActive (false);
- GUI.GetComponent<GUIManager> ().Credits.SetActive (false);
- GUI.GetComponent<GUIManager> ().Pause.SetActive (false);
- AttractMode = true;
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment