示例#1
0
        private static void UpdateShouts()
        {
            // check for new shout to start
            if (m_actualShoutCue == null || !m_actualShoutCue.Value.IsPlaying)
            {
                // check if we can start new shout
                if (m_nextShoutTime < MyMinerGame.TotalGamePlayTimeInMilliseconds)
                {
                    // gets random faction to shout (from detected factions by radar)
                    MyMwcObjectBuilder_FactionEnum?factionToShout = GetRandomDetectedFaction();
                    if (factionToShout != null)
                    {
                        MySoundCuesEnum shoutCue = GetRandomShout(factionToShout.Value);
                        m_actualShoutCue = MyAudio.AddCue2D(shoutCue);
                        if (m_actualShoutCue != null)
                        {
                            // because shouts can be ambient cues, so we must set correct volume for these cues
                            if (m_actualShoutCue.Value.IsAmbientSound)
                            {
                                MyAudio.UpdateCueAmbVolume(m_actualShoutCue, 100f);
                            }
                            else
                            {
                                MyAudio.UpdateCueVolume(m_actualShoutCue, 0.9f);
                            }
                            m_actualShoutFaction = factionToShout;
                            m_lastShoutCue       = shoutCue;

                            // calculate new time for next shout
                            m_nextShoutTime = MyMinerGame.TotalGamePlayTimeInMilliseconds + MyMwcUtils.GetRandomInt(INTERVAL_BETWEEN_SHOUTS_MIN, INTERVAL_BETWEEN_SHOUTS_MAX);
                        }
                    }
                }
            }
            // check for old shout to stop
            else
            {
                if (!m_detectedFactions.Contains(m_actualShoutFaction.Value))
                {
                    StopShout();
                }
            }
        }
        protected void ChangeSound(float influenceStrength)
        {
            Debug.Assert(IsSound);
            Volume = influenceStrength * (MyFakes.ENABLE_DEBUG_INFLUENCE_SPHERES_SOUNDS ? m_maxVolume : 100.0f);
            if (m_volume <= 0.0f)
            {
                if (m_cue.HasValue)
                {
                    m_cue.Value.Stop(SharpDX.XACT3.StopFlags.Release);
                }
            }
            else
            {
                if ((m_cue.HasValue == false) || (m_cue.Value.IsPlaying == false))
                {
                    m_cue = MyAudio.AddCue2D(m_cueEnum, m_volume);
                }

                MyAudio.UpdateCueAmbVolume(m_cue, m_volume);
            }
        }