Advertisement
Guest User

Untitled

a guest
Dec 9th, 2014
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.34 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class BumpyScene : MonoBehaviour {
  5.  
  6.     public bool isReady = false;
  7.     public int Scene;
  8.     public SoundManager sm;
  9.     public bool SoundHasStarted = false;
  10.     public ScreenFadeInOut sfio;
  11.     private bool soundPlaying = false;
  12.     private bool otherSoundPlayed = false;
  13.  
  14.     void Start ()
  15.     {
  16.         Screen.lockCursor = true; //locks cursor
  17.         Screen.showCursor = false; //hides cursor
  18.         sm = GetComponent<SoundManager>(); //gets sound manager
  19.         GetComponent<ScreenFadeInOut>(); //calls ScreenFadeinOut script
  20.     }
  21.    
  22.     void Update ()
  23.     {
  24.         if (sfio.Ready) //if the bool "Ready" in "ScreenFadeInOut" is true...
  25.         {
  26.             sm.PlaySound("DreamScene1"); //...play sound 1 and...
  27.             otherSoundPlayed = true; //...set "otherSoundPlayed" to true.
  28.  
  29.             if (!soundPlaying && otherSoundPlayed) //if "soundPlaying" is false and "otherSoundPlayed" is true...
  30.             {
  31.                 sm.PlaySound("DreamScene2"); //...play sound 2, and...
  32.                 whenDone(); //...call the "whenDone" function.
  33.             }
  34.         }
  35.     }
  36.  
  37.     public void whenDone()
  38.     {
  39.         if (isReady) //when everything is done...
  40.         {
  41.             Application.LoadLevel(Scene); //...load the scene defined in the variable.
  42.         }
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement