示例#1
0
 public void SetAmbianceZone(AmbianceZone newZone)
 {
     if (_currentZone.Equals(newZone))
     {
         //nothing happens
     }
     else
     {
         _nextZone  = newZone;
         _switching = true;
     }
 }
示例#2
0
        public void Update(GameTime gameTime)
        {
            if (!_death.Equals(TypeOfDeath.None))
            {
                if (gameTime.TotalGameTime.TotalMilliseconds - _transitionTimer > 5 * 1000)
                {
                    _transitionDone = true;
                    _death          = TypeOfDeath.None;
                }

                if (gameTime.TotalGameTime.TotalMilliseconds - _lastTick > _heartbeat * 1000)
                {
                    _lastTick = gameTime.TotalGameTime.TotalMilliseconds;
                    if (!_muteHeart)
                    {
                        PlayHeartbeat();
                    }
                }
            }
            else
            {
                _transitionTimer = gameTime.TotalGameTime.TotalMilliseconds;
                if (_guideSound.Equals(GuideSound.None))
                {
                    _lastGuide = gameTime.TotalGameTime.TotalMilliseconds;
                }
                else if (gameTime.TotalGameTime.TotalMilliseconds - _lastGuide > 20 * 1000)
                {
                    _lastGuide = gameTime.TotalGameTime.TotalMilliseconds;
                    PlayGuide();
                }

                if (gameTime.TotalGameTime.TotalMilliseconds - _lastTick > _heartbeat * 1000)
                {
                    _lastTick = gameTime.TotalGameTime.TotalMilliseconds;
                    if (_heartbeat < 0.4f)
                    {
                        _heartbeat = 0.4f;
                    }
                    if (_heartbeat < 0.8f)
                    {
                        _heartbeat += 0.01f;
                    }
                    HB_pace newPace = GetPace();
                    if (_currentPace.Equals(newPace))
                    {
                        _currentPace = newPace;
                    }
                    if (!_muteHeart)
                    {
                        PlayHeartbeat();
                    }
                }
                if (_switching)
                {
                    if (!_nextZone.Equals(_currentZone))
                    {
                        if (_audioManager.MusicVolume > 0f)
                        {
                            _audioManager.MusicVolume -= 0.01f;
                        }
                        if (_audioManager.MusicVolume == 0f)
                        {
                            _currentZone = _nextZone;
                            PlayAmbianceMusic();
                        }
                    }
                    else
                    {
                        float max_volume = 0.5f;
                        if (_currentZone.Equals(AmbianceZone.Stairs) || _currentZone.Equals(AmbianceZone.Room))
                        {
                            max_volume = 0.4f;
                        }
                        if (_audioManager.MusicVolume < max_volume)
                        {
                            _audioManager.MusicVolume += 0.01f;
                        }
                        if (_audioManager.MusicVolume == max_volume)
                        {
                            _switching = false;
                        }
                    }
                }
            }
        }