Inheritance: MonoBehaviour
Exemplo n.º 1
0
 // Use this for initialization
 void Start()
 {
     if (instanceRef == null)
     {
         instanceRef = this;
         DontDestroyOnLoad(gameObject);
         Src = GetComponent <AudioSource> ();
         otherSoundPlaying = false;
         startVol          = 0.54f;
     }
     else
     {
         DestroyImmediate(gameObject);
     }
 }
Exemplo n.º 2
0
 void Awake()
 {
     if (instance != null && instance.name != this.name)
     {
         GameObject.Destroy(GameObject.Find(instance.name));
     }
     else if (instance != null)
     {
         GameObject.Destroy(gameObject);
     }
     else
     {
         instance = this;
         GameObject.DontDestroyOnLoad(gameObject);
     }
 }
Exemplo n.º 3
0
 void Awake()
 {
     if (_instance == null)
     {
         //If I am the first instance, make me the Singleton
         _instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         //If a Singleton already exists and you find
         //another reference in scene, destroy it!
         if (this != _instance)
             Destroy(this.gameObject);
     }
 }
Exemplo n.º 4
0
    // Use this for initialization
    void Awake()
    {
        if (instanceRef == null)
        {
            instanceRef = this;
            DontDestroyOnLoad(gameObject);
            levelNum.value = 0;
        }
        else
        {
            DestroyImmediate(gameObject);
        }
        GameObject music = GameObject.Find("Audio Source");

        _musicloop = music.GetComponent <MusicLoop> ();
        updateLevelParams(levelParamsArray [levelNum.value]);
    }
Exemplo n.º 5
0
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        DontDestroyOnLoad(gameObject);

        audioSource = GetComponent <AudioSource>();
        audioSource.PlayOneShot(StartMusic);
        StartCoroutine(PlayLoop());
    }
Exemplo n.º 6
0
    protected override void Awake()
    {
        base.Awake();
        cam = UnityEngine.Camera.main.GetComponent <Camera> ();
        GameObject music = GameObject.Find("Audio Source");

        _musicloop     = music.GetComponent <MusicLoop> ();
        spriteRenderer = GetComponentInChildren <SpriteRenderer>();
        _anim          = GetComponentInChildren <Animator>();

        AudioSource[] audio = GetComponents <AudioSource>();
        _spacedeathaudio = audio[0];
        _deathaudio      = audio[1];
        _hurtaudio       = audio[2];
        _walkaudio       = audio[3];
        _dashaudio       = audio[4];
        _winaudio        = audio[5];

        playerHealth.value = 100;
        playerWonRef.value = false;
    }