Beispiel #1
0
    IEnumerator PlayMusic()
    {
        dAudio.CrossFade(backgroundMusic[getNotUsedID()], 1, 0);
        yield return(new WaitForSecondsRealtime(5));

        float w8time = 0;

        while (true)
        {
            if (!muteAll && !muteMusic)
            {
                int       id   = getNotUsedID();
                AudioClip clip = backgroundMusic[id];
                w8time = clip.length;
                if (w8time < 25f)
                {
                    w8time *= Random.value * 2 + 2f;
                    w8time  = Mathf.Clamp(w8time, 18f, 26f);
                    dAudio.CrossFade(clip, 1, w8time * 0.75f);
                }
                yield return(new WaitForSecondsRealtime(w8time));
            }
            else
            {
                yield return(new WaitForSecondsRealtime(2f));
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        splineFollower    = GetComponent <SplineFollower>();
        doubleAudioSource = GetComponent <DoubleAudioSource>();
        if (doubleAudioSource != null && normalAudioClip != null)
        {
            doubleAudioSource.CrossFade(normalAudioClip, 1.0f, 2.0f);
        }
        splineFollower.speed = normalSpeed;

        GameObject.Find("BezierSplineFilipe").transform.localScale = new Vector3(2, 3, 4);
    }
Beispiel #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(PauseKey) && Ui_Inventory.active == false)
        {
            if (GamePaused == false && DelayDone == true)
            {
                StartCoroutine(Delay(InventoryInputDelaySeconds));
                PauseGame();
                GamePaused = true;
            }
            else if (GamePaused == true && DelayDone == true)
            {
                StartCoroutine(Delay(InventoryInputDelaySeconds));
                GamePaused = false;
                ResumeGame();
            }
        }

        if (DayNightCycle.StateIndex == 1 || DayNightCycle.StateIndex >= 9)
        {
            IsDay = false;
        }
        else
        {
            IsDay = true;
        }
        if (IsDay != previousValue)
        {
            if (IsDay == true)
            {
                AmbientMusic.CrossFade(DayAmbient, 0.2f, 2);
            }
            if (IsDay == false)
            {
                AmbientMusic.CrossFade(NightAmbient, 0.2f, 2);
            }
        }
        previousValue = IsDay;
    }
    private void OnTriggerEnter(Collider other)
    {
        print("OnTriggerEnter " + other.tag);
        previousSpeedMode = speedMode;

        if (other.CompareTag("Normal"))
        {
            speedMode   = NORMAL_SPEED_MODE;
            changeSpeed = true;
            print("Change to normal speed");

            if (doubleAudioSource != null && normalAudioClip != null)
            {
                doubleAudioSource.CrossFade(normalAudioClip, 1.0f, 2.0f);
            }
        }
        else if (other.CompareTag("Drop"))
        {
            speedMode   = DROP_SPEED_MODE;
            changeSpeed = true;
            print("Change to drop speed");

            if (doubleAudioSource != null && fastAudioClip != null)
            {
                doubleAudioSource.CrossFade(fastAudioClip, 1.0f, 2.0f);
            }
        }
        else if (other.CompareTag("Climb up"))
        {
            speedMode   = CLIMB_UP_SPEED_MODE;
            changeSpeed = true;
            print("Change to climb up speed");
            if (doubleAudioSource != null && slowAudioClip != null)
            {
                doubleAudioSource.CrossFade(slowAudioClip, 1.0f, 2.0f);
            }
        }
    }
Beispiel #5
0
 public void SwitchMusic(int turn)
 {
     if (turn == 5)
     {
         das.CrossFade(Loop1, volume, 10, 0);
     }
     else if (turn == 10)
     {
         das.CrossFade(Loop2, volume, 10, 0);
     }
     else if (turn == 15)
     {
         das.CrossFade(Loop3, volume, 10, 0);
     }
     else if (turn == 20)
     {
         das.CrossFade(Loop4, volume, 10, 0);
     }
     else if (turn == 25)
     {
         das.CrossFade(Loop5, volume, 10, 0);
     }
 }
Beispiel #6
0
    public float highPitchRange = 1.05f;            //The highest a sound effect will be randomly pitched.

    // Use this for initialization
    void Awake()
    {
        if (instance == null)
        {
            instance = this;
        }
        else
        {
            Destroy(gameObject);
        }

        musicSource = gameObject.AddComponent(typeof(DoubleAudioSource)) as DoubleAudioSource;
        uiSource    = gameObject.AddComponent(typeof(AudioSource)) as AudioSource;

        musicSource.CrossFade(initialBackgroundMusic, 1, 0);

        DontDestroyOnLoad(this);
    }
Beispiel #7
0
    void PlayMusic(AudioClip clip)
    {
        DoubleAudioSource player = GetComponent <DoubleAudioSource>();

        player.CrossFade(clip, 1.0f, 2.0f);
    }
 public void PlaySound()
 {
     currentIdx = RandomRangeExceptCurrent();
     doubleAudioSource.CrossFade(GameMusic[currentIdx], maxVol, 1, 0);
 }
Beispiel #9
0
 public void PlayMenuSound()
 {
     audioSource.CrossFade(menuSound, 1, CrossFadeTime, CrossFadeDelay);
 }
Beispiel #10
0
 void Start()
 {
     audioSource = GetComponent <DoubleAudioSource>();
     audioSource.CrossFade(menuSound, 1, 0);
 }