Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.51 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class TrackTriggerScript : MonoBehaviour
  6. {
  7. public GameObject zombie01;
  8. public GameObject zombie02;
  9. public GameObject kid;
  10.  
  11. private void OnTriggerEnter(Collider other)
  12. {
  13. gameObject.GetComponent<Collider>().enabled = false;
  14. void PopUp(GameObject z, float delayTime)
  15. {
  16. if (z.transform.GetChild(0).tag != "IsDead")
  17. {
  18. iTween.RotateTo(z, iTween.Hash(
  19. "x", 0f,
  20. "time", 0.5f,
  21. "easetype", "spring",
  22. "delay", delayTime,
  23. "islocal", true
  24. ));
  25. }
  26. }
  27.  
  28.  
  29. PopUp(zombie01, 0.01f);
  30. StartCoroutine(Slide(zombie01, "Right"));
  31. PopUp(zombie02, 0.5f);
  32. StartCoroutine(Slide(zombie02, "Left"));
  33. PopUp(kid, 1f);
  34. StartCoroutine(Slide(kid, "Left"));
  35.  
  36. StartCoroutine(DelayedSounds());
  37.  
  38. IEnumerator DelayedSounds()
  39. {
  40. gameObject.GetComponent<AudioSource>().Play();
  41. yield return new WaitForSeconds(0.5f);
  42. gameObject.GetComponent<AudioSource>().Play();
  43. yield return new WaitForSeconds(0.5f);
  44. gameObject.GetComponent<AudioSource>().Play();
  45. }
  46.  
  47. IEnumerator Slide(GameObject board, string direction)
  48. {
  49. var multiplier = 1f;
  50. if (direction == "Right")
  51. {
  52. multiplier = -1f; //Set to other way when starting right
  53. }
  54. while (board.transform.GetChild(0).tag != "IsDead")
  55. {
  56. if (board.transform.GetChild(0).tag != "IsDead") //Keep Checking
  57. {
  58. iTween.MoveBy(board, iTween.Hash(
  59. "x", -7.439f * multiplier,
  60. "time", 2f,
  61. "easetype", "linear",
  62. "islocal", true
  63. ));
  64. }
  65. yield return new WaitForSeconds(2.1f);
  66. if (board.transform.GetChild(0).tag != "IsDead") // Just incase
  67. {
  68. iTween.MoveBy(board, iTween.Hash(
  69. "x", 7.439f * multiplier,
  70. "time", 2f,
  71. "easetype", "linear",
  72. "islocal", true
  73. ));
  74. }
  75. yield return new WaitForSeconds(2.1f);
  76. }
  77. }
  78. }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement