Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class TrackTriggerScript : MonoBehaviour
- {
- public GameObject zombie01;
- public GameObject zombie02;
- public GameObject kid;
- private void OnTriggerEnter(Collider other)
- {
- gameObject.GetComponent<Collider>().enabled = false;
- void PopUp(GameObject z, float delayTime)
- {
- if (z.transform.GetChild(0).tag != "IsDead")
- {
- iTween.RotateTo(z, iTween.Hash(
- "x", 0f,
- "time", 0.5f,
- "easetype", "spring",
- "delay", delayTime,
- "islocal", true
- ));
- }
- }
- PopUp(zombie01, 0.01f);
- StartCoroutine(Slide(zombie01, "Right"));
- PopUp(zombie02, 0.5f);
- StartCoroutine(Slide(zombie02, "Left"));
- PopUp(kid, 1f);
- StartCoroutine(Slide(kid, "Left"));
- StartCoroutine(DelayedSounds());
- IEnumerator DelayedSounds()
- {
- gameObject.GetComponent<AudioSource>().Play();
- yield return new WaitForSeconds(0.5f);
- gameObject.GetComponent<AudioSource>().Play();
- yield return new WaitForSeconds(0.5f);
- gameObject.GetComponent<AudioSource>().Play();
- }
- IEnumerator Slide(GameObject board, string direction)
- {
- var multiplier = 1f;
- if (direction == "Right")
- {
- multiplier = -1f; //Set to other way when starting right
- }
- while (board.transform.GetChild(0).tag != "IsDead")
- {
- if (board.transform.GetChild(0).tag != "IsDead") //Keep Checking
- {
- iTween.MoveBy(board, iTween.Hash(
- "x", -7.439f * multiplier,
- "time", 2f,
- "easetype", "linear",
- "islocal", true
- ));
- }
- yield return new WaitForSeconds(2.1f);
- if (board.transform.GetChild(0).tag != "IsDead") // Just incase
- {
- iTween.MoveBy(board, iTween.Hash(
- "x", 7.439f * multiplier,
- "time", 2f,
- "easetype", "linear",
- "islocal", true
- ));
- }
- yield return new WaitForSeconds(2.1f);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement