Пример #1
0
        static MyTrailerXml LoadTrailerXml()
        {
            MyTrailerXml res = null;
            StreamReader str = null;

            try
            {
                //  Filename ends with "xmlx" because "xml" is already used by XNA content pipeline
                str = new StreamReader(MyMinerGame.Static.RootDirectory + "\\Trailer\\Trailer.xmlx");
                System.Xml.Serialization.XmlSerializer xSerializer = new System.Xml.Serialization.XmlSerializer(typeof(MyTrailerXml));
                res = (MyTrailerXml)xSerializer.Deserialize(str);
            }
            catch (Exception ex)
            {
                //  Log this exception, but game will continue. Of course no trailer animation can run.
                MyMwcLog.WriteLine("Exception during reading and deserializing xml: " + ex.ToString());
                m_isEnabled = false;
            }
            finally
            {
                if (str != null)
                {
                    str.Close();
                }
            }

            return(res);
        }
Пример #2
0
        public static void LoadAnimation()
        {
            MyMwcLog.WriteLine("MyTrailerLoad.LoadContent() - START");
            MyMwcLog.IncreaseIndent();
            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().StartProfilingBlock("MyTrailerLoad::LoadAnimation");

            if (!AnimationSelectedFromMenu)
            {
                MyTrailerXml res = LoadTrailerXml();
                Animations = res.Animation;

                if (MyGuiScreenGamePlay.Static.IsMainMenuActive())
                {
                    SetTrailerAnimation(res.MainMenuAnimation);
                }
                else if (MyGuiScreenGamePlay.Static.IsGameActive())
                {
                    SetTrailerAnimation(res.GameAnimation);
                }
                else if (MyGuiScreenGamePlay.Static.IsFlyThroughActive())
                {
                    if (string.IsNullOrEmpty(res.FlyThroughOrCreditsAnimation))
                    {
                        //  Pick random animation
                        if ((res.Animation != null) && (Animations.Length > 0))
                        {
                            TrailerAnimation = res.Animation[MyMwcUtils.GetRandomInt(0, Animations.Length)];
                        }
                    }
                    else
                    {
                        SetTrailerAnimation(res.FlyThroughOrCreditsAnimation);
                    }
                }
            }
            AnimationSelectedFromMenu = false;

            MinerWars.AppCode.Game.Render.MyRender.GetRenderProfiler().EndProfilingBlock();
            MyMwcLog.DecreaseIndent();
            MyMwcLog.WriteLine("MyTrailerLoad.LoadContent() - END");
        }