Пример #1
0
 public void PlayMusic(MyMusicTrack? track = null, int priorityForRandom = 0)
 {
     if (!m_canPlay || !m_musicAllowed)
         return;
     Mute = false;
     bool playRandom = false;
     if (track.HasValue)
     {
         if (HasAnyTransition())
             m_nextTransitions.Clear();
         if(!m_cueBank.IsValidTransitionCategory(track.Value.TransitionCategory, track.Value.MusicCategory))
             playRandom = true;
         else
             ApplyTransition(track.Value.TransitionCategory, 1, track.Value.MusicCategory, false);
     }
     else if ((m_musicState == MyMusicState.Stopped) && /*(GetMusicCue() == null) &&*/ !HasAnyTransition())
     {
         playRandom = true;
     }
     if (playRandom)
     {
         var transition = GetRandomTransitionEnum();
         if (transition.HasValue)
             ApplyTransition(transition.Value, priorityForRandom, null, false);
     }
 }
Пример #2
0
 void IMyAudio.PlayMusic(MyMusicTrack? track, int priorityForRandom) { }
Пример #3
0
 void IMyAudio.PlayMusic(MyMusicTrack? track) { }
        public override void UpdateAfterSimulation()
        {
            base.UpdateAfterSimulation();

            m_waitForUpdate--;
            if (m_waitForUpdate > 0)
            {
                return;
            }
            m_waitForUpdate = UPDATE_DELAY;


            Vector3D position = MySector.MainCamera.Position;


            MyPlanet planet = MyGravityProviderSystem.GetNearestPlanet(position);

            if (planet != null)
            {
                var distanceFromPlanet = Vector3D.Distance(planet.PositionComp.GetPosition(), position);
                if (distanceFromPlanet > planet.MaximumRadius + Math.Max(100, planet.MaximumRadius)) ;
                planet = null; //too far planet
            }

            if (m_closestPlanet != planet)
            {
                m_closestPlanet = planet;

                if (m_closestPlanet != null)
                {
                    MyStringId category = MyStringId.GetOrCompute(m_closestPlanet.Generator.Id.SubtypeId.ToString());
                    MyStringId transition = MyStringId.GetOrCompute(m_closestPlanet.Generator.Id.SubtypeId.ToString());

                    if (!MyAudio.Static.IsValidTransitionCategory(transition, category))
                    {
                        category = MyStringId.GetOrCompute("OtherPlanet");
                        transition = MyStringId.GetOrCompute("OtherPlanet");
                    }

                    MyMusicTrack mt = new MyMusicTrack()
                    {
                        MusicCategory = category,
                        TransitionCategory = transition
                    };

                    MyAudio.Static.PlayMusic(mt);
                }
                else
                {
                    //random
                    MyMusicTrack mt = new MyMusicTrack()
                    {
                    };
                    MyAudio.Static.PlayMusic(mt, 1);
                }
            }

        }