Пример #1
0
        public void Update(GameTime gameTime)
        {
            float seconds = Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds);

            elapsedTime += seconds;

            if (elapsedTime >= 0.2f)
            {
                if (IsLoading)
                {
                }
                else
                {
                    if (LoadScreenEvent == null)
                    {
                    }
                    else
                    {
                        IsLoading = true;

                        if (Session.MainGame.mainGameScreen != null)
                        {
                            Session.MainGame.mainGameScreen.mainMapLayer.StopThreads();

                            Session.MainGame.mainGameScreen.DisposeMapTileMemory(false, true);

                            Session.MainGame.mainGameScreen.Dispose();

                            Session.MainGame.mainGameScreen = null;

                            GameScenario.ProcessCommonData(CommonData.Current);
                        }

                        Session.Current.Clear();

                        CacheManager.Clear(CacheType.Live);

                        GC.Collect();

                        new Platforms.PlatformTask(() =>
                        {
                            try
                            {
                                LoadScreenEvent.Invoke(null, null);
                            }
                            catch (Exception e)
                            {
                                throw new Exception("加載出錯:" + e);
                                //Program.PrintError(e);
                                //Environment.Exit(1);
                            }

                            ClearEvent();
                            IsComplete = true;
                            Session.MainGame.loadingScreen = null;
                        }).Start();
                    }
                }
            }
        }
Пример #2
0
        public void Update(GameTime gameTime)
        {
            float seconds = Convert.ToSingle(gameTime.ElapsedGameTime.TotalSeconds);

            elapsedTime += seconds;

            if (Mode == "Start")
            {
                if (pause)
                {
                    btPlay.Visible  = true;
                    btPause.Visible = false;
                }
                else
                {
                    btPlay.Visible  = false;
                    btPause.Visible = true;

                    if (page < maps.Length)
                    {
                        pageTime += seconds;

                        if (pageTime >= Session.globalVariablesBasic.ScenarioMapPerTime)
                        {
                            page++;
                            pageTime -= Session.globalVariablesBasic.ScenarioMapPerTime;
                        }
                    }
                }

                if (IsComplete)
                {
                    btLoad.Visible  = false;
                    btStart.Visible = true;
                }
                else
                {
                    btLoad.Visible  = true;
                    btStart.Visible = false;
                }

                btPre.Enable = btNext.Enable = true;

                if (page <= 1)
                {
                    btPre.Enable = false;
                }

                if (page >= maps.Length)
                {
                    btNext.Enable = false;
                }

                btPre.Update();

                btPlay.Update();

                btPause.Update();

                btNext.Update();

                btLoad.Update();

                btStart.Update();
            }
            else
            {
            }

            if (elapsedTime >= 0.2f)
            {
                if (IsLoading)
                {
                }
                else
                {
                    if (LoadScreenEvent == null)
                    {
                    }
                    else
                    {
                        IsLoading = true;

                        if (Session.MainGame.mainGameScreen != null)
                        {
                            Session.MainGame.mainGameScreen.mainMapLayer.StopThreads();

                            Session.MainGame.mainGameScreen.DisposeMapTileMemory(false, true);

                            Session.MainGame.mainGameScreen.Dispose();

                            Session.MainGame.mainGameScreen = null;

                            GameScenario.ProcessCommonData(CommonData.Current);
                        }

                        Session.Current.Clear();

                        CacheManager.Clear(CacheType.Live);

                        GC.Collect();

#if DEBUG
                        try
                        {
                            LoadScreenEvent.Invoke(null, null);
                        }
                        catch (Exception e)
                        {
                            throw new Exception("加載出錯:" + e);
                            //Program.PrintError(e);
                            //Environment.Exit(1);
                        }
                        ClearEvent();
                        IsComplete = true;
                        if (Mode == "Start")
                        {
                        }
                        else
                        {
                            Session.MainGame.loadingScreen = null;
                        }
#else
                        new Platforms.PlatformTask(() =>
                        {
                            try
                            {
                                LoadScreenEvent.Invoke(null, null);
                            }
                            catch (Exception e)
                            {
                                throw new Exception("加載出錯:" + e);
                                //Program.PrintError(e);
                                //Environment.Exit(1);
                            }

                            ClearEvent();
                            IsComplete = true;
                            if (Mode == "Start")
                            {
                            }
                            else
                            {
                                Session.MainGame.loadingScreen = null;
                            }
                        }).Start();
#endif
                    }
                }
            }
        }