Exemple #1
0
        public void UnloadResources()
        {
            _loadRequestsCDC.Clear();

            if (CurrentScene != null)
            {
                CurrentScene.Dispose();
                CurrentScene = null;
            }

            if (CurrentObject != null)
            {
                CurrentObject.Dispose();
                CurrentObject = null;
            }

            while (Resources.Count > 1)
            {
                RenderResource resource = Resources[Resources.Keys[1]];
                Resources.Remove(Resources.Keys[1]);
                CurrentObject?.UpdateModels();
                CurrentScene?.UpdateModels();
                resource.Dispose();
            }
        }
Exemple #2
0
 public void PrepareNextScene(ISceneBase Caller, ISceneBase nextscene, Dictionary <string, object> param, Dictionary <string, object> previousparam)
 {
     NextScene               = nextscene;
     NextScene.Device        = Device;
     NextScene.Sprite        = Sprite;
     NextScene.Sound         = Sound;
     NextScene.SceneManager  = this;
     NextScene.Param         = param == null ? new Dictionary <string, object>() : param;
     NextScene.PreviousParam = GlobalPool.ContainsKey(NextScene.GetType()) ? GlobalPool[NextScene.GetType()] : new Dictionary <string, object>();
     if (previousparam != null)
     {
         if (GlobalPool.ContainsKey(Caller.GetType()))
         {
             GlobalPool[Caller.GetType()] = previousparam;
         }
         else
         {
             GlobalPool.Add(Caller.GetType(), previousparam);
         }
     }
     LoadingThread = new Thread(new ThreadStart(nextscene.Load));
     LoadingThread.Start();
     CurrentScene.Dispose();
     CurrentScene = null;
 }
        public override void Dispose()
        {
            if (CurrentScene != null)
            {
                CurrentScene.Dispose();
            }

            base.Dispose();
        }
Exemple #4
0
        protected override async void Update()
        {
            //読み込み画面が必要な場合
            if (IsNeedLoadingScreen)
            {
                //読み込み画面へ移行
                CurrentState = RenderState.FadeToLoadScreen;
                await SkipTick(FadingAnimation, FadeTime);

                //読み込み待機
                CurrentState    = RenderState.LoadScreen;
                Overlay.IsShown = true;
                await SkipTick(Task.Run(() =>
                {
                    CurrentScene?.Dispose();
                    CurrentScene = null;
                    NextScene    = (Scene)Container.Resolve(NextSceneType);
                    Container.GameWindow.SetActionAndWaitNextFrame(() => NextScene.UpdateDevice(Container));                     //todo FormsのDLLを使用しないといけないのはいささか不本意である。
                }));

                Overlay.IsShown = false;

                //新しい画面へ移行
                CurrentState = RenderState.FadeFromLoadScreen;
                await SkipTick(FadingAnimation, FadeTime);

                //移行完了で役目は終了
                Container.CurrentScene = NextScene;
                return;
            }

            //ロード画面を必要としないのであればインスタンスを生成する
            Overlay.IsShown = true;
            await SkipTick(Task.Run(() =>
            {
                NextScene = (Scene)Container.Resolve(NextSceneType);
                Container.GameWindow.SetActionAndWaitNextFrame(() => NextScene.UpdateDevice(Container));                 //todo FormsのDLLを使用しないといけないのはいささか不本意である。
            }));

            //(読み込み画面が必要ないときに)読み込みが完了したので移行開始
            CurrentState    = RenderState.FadeFromPreviousSceneToNextScene;
            Overlay.IsShown = false;
            await SkipTick(FadingAnimation, FadeTime);

            //移行完了したら役目は終了 昔のシーンは破棄する
            ThreadPool.QueueUserWorkItem(s =>
            {
                CurrentScene.Dispose();
                CurrentScene = null;
            });
            Container.CurrentScene = NextScene;
        }
Exemple #5
0
        public void SetCurrentScene(string sceneName)
        {
            if (CurrentScene != null)
            {
                CurrentScene.Dispose();
                CurrentScene = null;
            }

            if (sceneName != "" && Resources.ContainsKey(sceneName))
            {
                RenderResourceCDC renderResource = (RenderResourceCDC)Resources[sceneName];
                CurrentScene = new SceneCDC(renderResource.File, true);
            }
        }
Exemple #6
0
        /// <summary>
        /// 終了処理を行う。
        /// </summary>
        public static void Terminate()
        {
            if (core == null)
            {
                return;
            }

            if (CurrentScene != null)
            {
                CurrentScene.Dispose();
            }

            if (nextScene != null)
            {
                nextScene.Dispose();
            }

            if (previousScene != null)
            {
                previousScene.Dispose();
            }


            CurrentScene  = null;
            nextScene     = null;
            previousScene = null;
            transition    = null;

            GC.Terminate();

            core.Terminate();
            core.Release();
            core = null;

            Mouse = null;

            var refCount = swig.asd_core.GetGlobalReferenceCount__();

            if (refCount > 0)
            {
                Particular.Helper.ThrowUnreleasedInstanceException(refCount);
            }
        }
Exemple #7
0
        public void UnloadResource(string resourceName)
        {
            if (resourceName != "" && Resources.ContainsKey(resourceName))
            {
                RenderResource renderResource = Resources[resourceName];
                Resources.Remove(resourceName);
                CurrentObject?.UpdateModels();
                CurrentScene?.UpdateModels();
                renderResource.Dispose();

                if (CurrentScene != null && CurrentScene.Name == resourceName)
                {
                    CurrentScene.Dispose();
                    CurrentScene = null;
                }

                if (CurrentObject != null && CurrentObject.Name == resourceName)
                {
                    CurrentObject.Dispose();
                    CurrentObject = null;
                }
            }
        }
Exemple #8
0
        /// <summary>
        /// イベントを実行し、進行可否を判断する。
        /// </summary>
        /// <returns>進行可能か?</returns>
        public static bool DoEvents()
        {
            if (core == null)
            {
                return(false);
            }

            GC.Update();

            bool mes = core.DoEvents();

            if (Mouse != null)
            {
                Mouse.RefreshAllState();
            }

            if (transition != null)
            {
                if (transition.SwigObject.GetIsSceneChanged() && nextScene != null)
                {
                    if (CurrentScene != null)
                    {
                        CurrentScene.CallChanging();
                    }
                    previousScene = CurrentScene;
                    CurrentScene  = nextScene;
                    core.ChangeScene(nextScene.CoreScene);
                    nextScene.Start();
                    nextScene = null;
                }

                if (transition.SwigObject.GetIsFinished())
                {
                    if (previousScene != null)
                    {
                        previousScene.Dispose();
                        previousScene = null;
                    }

                    transition = null;
                    CurrentScene.CallTransitionFinished();
                }
            }
            else
            {
                if (nextScene != null)
                {
                    if (CurrentScene != null)
                    {
                        CurrentScene.CallChanging();
                        CurrentScene.Dispose();
                    }

                    CurrentScene = nextScene;
                    core.ChangeScene(nextScene.CoreScene);
                    nextScene.Start();
                    nextScene = null;
                }
            }

            return(mes);
        }