Exemple #1
0
    private IEnumerator WaitScene(string scene)
    {
        _screenFader.Fade(1, _change);
        if (_audioFader != null)
        {
            _audioFader.Fade(-1);
        }
        yield return(new WaitForSeconds(_wait));

        GameManager.GetInstance().EnableControl(true);
        GameManager.GetInstance().LoadScene(scene);
    }
Exemple #2
0
 private void HandleFadeFinshed()
 {
     if (_exiting || _reloading)
     {
         audioFader.fadeDirection = AudioFader.FadeDirection.FadeOut;
         audioFader.Fade();
     }
 }
Exemple #3
0
    private void OnLevelChange(Level level, Level previous)
    {
        var crossfadeDuration = CrossfadeDuration;

        if (previous == null || level.info.act != previous.info.act)
        {
            crossfadeDuration = 0;
        }
        AudioSource song;

        if (previous != null)
        {
            song = songs.GetValueOrDefault(previous.info);
            if (song != null)
            {
                AudioFader.Fade(song, previous.info.soundEnv.song.volume, 0, crossfadeDuration);
            }
        }
        song = songs.GetValueOrDefault(level.info);
        if (song == null)
        {
            song              = Play(level.info.soundEnv.song);
            song.volume       = 0;
            songs[level.info] = song;
        }
        AudioFader.Fade(song, 0, level.info.soundEnv.song.volume, crossfadeDuration);

        if (ambient == null)
        {
            ambient = Create("Ambient sound");
        }
        Play(level.info.soundEnv.dayAmbience, ambient);

        if (eventsCoroutine != null)
        {
            StopCoroutine(eventsCoroutine);
        }
        if (level != null)
        {
            eventsCoroutine = StartCoroutine(PlayEnvEvents());
        }
        else
        {
            eventsCoroutine = null;
        }
    }
    void FixedUpdate()
    {
        if (!canMove)
        {
            return;
        }

        //Move
        //Target direction
        _targetPosition  = target.position + _offsetVector - _cachedTransform.position;
        _targetDirection = _targetPosition.normalized;

        //Check if reached limit
        if (_cachedTransform.position.x < maximumXPosition)
        {
            //check if reached target
            if (_targetPosition.sqrMagnitude > 1 && !_isAttacking)
            {
                //Accelerate
                if (_currentSpeed < maxSpeed)
                {
                    _currentSpeed += Mathf.Min(maxSpeed * Time.deltaTime, maxSpeed - _currentSpeed);
                }

                //Move only forward
                if (_targetDirection.x > 0)
                {
                    _cachedTransform.Translate(_targetDirection * _currentSpeed * Time.deltaTime);
                }
            }
            else if (target.position.x < _cachedTransform.position.x + minimumHorizontalOffset)
            {
                //Death
                canMove               = false;
                _canAttack            = false;
                _eventHandler.enabled = false;
                _platformerControl.DoStop();
                StartCoroutine(DoKill());
            }
            else if (_canAttack)
            {
                //Play roar
                //audioSource.PlayOneShot (roarSound);

                //Reduce speed
                _currentSpeed = attackSpeed;
                if (_targetDirection.x > 0)
                {
                    _cachedTransform.Translate(_targetDirection * _currentSpeed * Time.deltaTime);
                }
                //Attack
                if (!_isInAttack)
                {
                    StartCoroutine(DoAttack());
                }
            }
        }
        else
        {
            if (!_playedRoar)
            {
                _playedRoar = true;
                audioSource.PlayOneShot(roarSound);
                audioFader.fadeDirection = AudioFader.FadeDirection.FadeOut;
                audioFader.Fade();
            }
        }
    }