Esempio n. 1
0
 /// <summary>
 /// Updates the scene flow
 /// </summary>
 /// <param name="game">Game manager</param>
 public void Update(Game game)
 {
     // If the next scene is the current scene
     if (_CurrentScene == NextScene)
     {
         // Then just keep it updated
         if (_CurrentScene != null)
         {
             _CurrentScene.Update(game);
         }
     }
     // If the next scene is something different, but the current one has started
     else if (_HasStarted)
     {
         // Then first terminates the current one
         _CurrentScene.Terminate(game);
         _HasStarted = false;
     }
     // If the next scene is something different and the current one hasn't started or just terminated
     else
     {
         // Goes to the next one
         _CurrentScene = NextScene;
         // And start it
         if (_CurrentScene != null)
         {
             _CurrentScene.Start(game);
         }
         _HasStarted = true;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// ホームまでポップします
 /// </summary>
 public void PopToHome()
 {
     while (sceneStack.Count > 0)
     {
         if (CurrentScene != null)
         {
             previousScene = CurrentScene;
             CurrentScene  = sceneStack.Pop();
         }
         if (previousScene != null)
         {
             previousScene.Dispose();
             if (!PPDSetting.Setting.AllowedToUseMuchMemory && previousScene.ResourceManager != null)
             {
                 previousScene.ResourceManager.Dispose();
                 previousScene.Dispose();
                 previousScene = null;
             }
         }
     }
     if (previousScene != null && previousScene.ResourceManager != null)
     {
         previousScene.ResourceManager.Dispose();
         previousScene.Dispose();
         previousScene = null;
     }
 }
Esempio n. 3
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;
 }
Esempio n. 4
0
 /// <summary>
 /// Creates a new console game manager
 /// </summary>
 /// <param name="width">Screen width</param>
 /// <param name="height">Screen height</param>
 /// <param name="firstScene">First scene</param>
 public ConsoleGame(
     int width,
     int height,
     ISceneBase firstScene
     ) : base(firstScene)
 {
     Screen = new ConsoleScreen(width, height);
 }
Esempio n. 5
0
 /// <summary>
 /// Creates a new console game manager
 /// </summary>
 /// <param name="width">Screen width</param>
 /// <param name="height">Screen height</param>
 /// <param name="firstScene">First scene</param>
 public ConsoleGame(
     int width,
     int height,
     ISceneBase firstScene
 )
     : base(firstScene)
 {
     Screen = new ConsoleScreen(width, height);
 }
Esempio n. 6
0
 public void Previous(ISceneBase caller)
 {
     currentSceneIndex--;
     if (currentSceneIndex < 0)
     {
         currentSceneIndex = sceneTypes.Count - 1;
     }
     ChangeScene(caller);
 }
Esempio n. 7
0
 public void Next(ISceneBase caller)
 {
     currentSceneIndex++;
     if (currentSceneIndex >= sceneTypes.Count)
     {
         currentSceneIndex = 0;
     }
     ChangeScene(caller);
 }
Esempio n. 8
0
 /// <summary>
 /// 現在のシーンをポップします
 /// </summary>
 public void PopCurrentScene(Dictionary <string, object> param)
 {
     if (CurrentScene != null && CurrentScene.IsInSceneStack && sceneStack.Count > 0)
     {
         previousScene = CurrentScene;
         CurrentScene  = sceneStack.Pop();
         CurrentScene.SceneStackPoped(param);
     }
 }
Esempio n. 9
0
 private void SetPropertyToScene(ISceneBase scene)
 {
     if (scene == null)
     {
         return;
     }
     scene.Sound        = sound;
     scene.SceneManager = sceneManager;
     scene.GameHost     = this;
 }
Esempio n. 10
0
        /// <summary>
        /// 更新する
        /// </summary>
        /// <param name="inputInfo">入力の情報</param>
        /// <param name="mouseInfo">マウスの情報</param>
        /// <param name="sound">サウンド</param>
        public void Update(InputInfoBase inputInfo, MouseInfo mouseInfo, ISound sound)
        {
            Sound = sound;
            if (previousScene != null)
            {
                previousScene.Dispose();
                if (!previousSceneResourceUsing && !PPDSetting.Setting.AllowedToUseMuchMemory && previousScene.ResourceManager != null)
                {
                    previousScene.ResourceManager.Dispose();
                }
                previousScene = null;
                device.GetModule <CharCacheManager>().ClearUnUsed();
            }
            if (nextScene != null)
            {
                if (LoadFinished)
                {
#if DEBUG
                    Console.WriteLine("LoadTime is:" + (Environment.TickCount - lastTime));
#if BENCHMARK
                    Benchmark.Instance.EndCategory();
#endif
#endif
                    loadingThread.Join();
                    loadingThread = null;
                    device.GetModule <CharCacheManager>().ClearUnUsed();
                    if (loadResult)
                    {
                        CurrentScene = nextScene;
                    }
                    else
                    {
                        previousScene = nextScene;
                        CurrentScene  = sceneStack.Pop();
                        CurrentScene.SceneStackPoped(new Dictionary <string, object>
                        {
                            { "Failed to initialize", "" }
                        });
                    }
                    nextScene = null;
                    if (LeaveLoading != null)
                    {
                        LeaveLoading.Invoke(this, EventArgs.Empty);
                    }
                }
            }
            if (CurrentScene != null)
            {
                CurrentScene.Update(inputInfo, mouseInfo);
            }
            if (loadingThread != null && LoadingScene != null)
            {
                LoadingScene.Update(inputInfo, mouseInfo);
            }
        }
Esempio n. 11
0
        /// <summary> 加算シーンをアンロード </summary>
        public void UnloadAppendScene(ISceneBase scene, bool deactivateSceneObjects = true)
        {
            var sceneInstance = appendSceneInstances.FirstOrDefault(x => x.Instance == scene);

            if (sceneInstance == null)
            {
                return;
            }

            UnloadAppendScene(sceneInstance, deactivateSceneObjects);
        }
Esempio n. 12
0
 private void DisposeScene(ISceneBase scene)
 {
     if (scene != null)
     {
         scene.Dispose();
         if (scene.ResourceManager != null)
         {
             scene.ResourceManager.Dispose();
         }
     }
 }
Esempio n. 13
0
        //----- method -----

        public SceneInstance(Scenes?identifier, ISceneBase instance, Scene?scene)
        {
            this.scene = scene;

            Identifier = identifier;
            Instance   = instance;

            var rootObjects = scene.Value.GetRootGameObjects();

            activeRoots = rootObjects
                          .Where(x => !UnityUtility.IsNull(x))
                          .Where(x => UnityUtility.IsActive(x))
                          .ToArray();
        }
Esempio n. 14
0
        public SuperAutoCreator(ISceneBase scene, MarkManager markManager, EventManager eventManager, FlowScriptManager scriptManager, float startTime,
                                float endTime, ItemType autoType, int[] evaPoint, bool includeFine)
        {
            this.scene         = scene;
            this.markManager   = markManager;
            this.eventManager  = eventManager;
            this.scriptManager = scriptManager;
            this.startTime     = startTime;
            this.endTime       = endTime;
            this.autoType      = autoType;
            this.evaPoint      = evaPoint;
            this.includeFine   = includeFine;
            buttons            = new ButtonType[10];
            for (int i = 0; i < buttons.Length; i++)
            {
                buttons[i] = (ButtonType)i;
            }
            safeCoolArea = PPDSetting.Setting.CoolArea - 0.001f;
            safeGoodArea = PPDSetting.Setting.GoodArea - 0.001f;
            switch (autoType)
            {
            case ItemType.Auto1:
                doJust        = true;
                doPermutation = false;
                doDumpNotes   = false;
                break;

            case ItemType.Auto2:
                doJust        = true;
                doPermutation = true;
                doDumpNotes   = false;
                break;

            case ItemType.Auto3:
                doJust        = false;
                doPermutation = true;
                doDumpNotes   = false;
                break;

            case ItemType.Auto4:
                doJust        = false;
                doPermutation = true;
                doDumpNotes   = true;
                break;
            }
        }
Esempio n. 15
0
        private ISceneBase FindSceneObject(Scene scene)
        {
            ISceneBase sceneBase = null;

            if (!scene.isLoaded || !scene.IsValid())
            {
                return(null);
            }

            var rootObjects = scene.GetRootGameObjects();

            foreach (var rootObject in rootObjects)
            {
                sceneBase = UnityUtility.FindObjectOfInterface <ISceneBase>(rootObject);

                if (sceneBase != null)
                {
                    break;
                }
            }

            return(sceneBase);
        }
Esempio n. 16
0
 public void Update(int[] presscount, bool[] released, Device device, Sprite sprite, ExSound sound)
 {
     Device = device;
     Sprite = sprite;
     Sound  = sound;
     if (CurrentScene != null)
     {
         CurrentScene.Update(presscount, released);
     }
     if (NextScene != null)
     {
         if (LoadingThread.ThreadState == ThreadState.Stopped)
         {
             LoadingThread.Join();
             LoadingThread = null;
             CurrentScene  = NextScene;
             NextScene     = null;
         }
     }
     if (LoadingThread != null)
     {
         LoadingScene.Update(presscount, released);
     }
 }
Esempio n. 17
0
 /// <summary>
 /// Creates a new scene manager
 /// </summary>
 /// <param name="firstScene">First scene</param>
 public SceneManager(ISceneBase firstScene)
 {
     NextScene = firstScene;
 }
Esempio n. 18
0
 /// <summary>
 /// ゲームを変更します。
 /// </summary>
 /// <param name="scene"></param>
 /// <param name="param"></param>
 /// <param name="spriteResourceManager"></param>
 public void ChangeGame(ISceneBase scene, Dictionary <string, object> param, SpriteResourceManager spriteResourceManager)
 {
     InnerPrepareNextScene(null, scene, param, null, true, spriteResourceManager);
 }
Esempio n. 19
0
 /// <summary>
 /// 次のシーンを非同期で用意する
 /// </summary>
 /// <param name="caller">呼び出しシーン</param>
 /// <param name="nextScene">次のシーン</param>
 /// <param name="param">次のシーンに渡すパラメーター</param>
 /// <param name="previousParam">呼び出し側のシーンの次の生成時に渡すパラメーター</param>
 public void PrepareNextScene(ISceneBase caller, ISceneBase nextScene, Dictionary <string, object> param, Dictionary <string, object> previousParam)
 {
     PrepareNextScene(caller, nextScene, param, previousParam, false);
 }
Esempio n. 20
0
 /// <summary>
 /// 次のシーンを非同期で用意する
 /// </summary>
 /// <param name="caller">呼び出しシーン</param>
 /// <param name="nextScene">次のシーン</param>
 /// <param name="param">次のシーンに渡すパラメーター</param>
 /// <param name="previousParam">呼び出し側のシーンの次の生成時に渡すパラメーター</param>
 /// <param name="useStack">スタックを使うかどうか</param>
 public void PrepareNextScene(ISceneBase caller, ISceneBase nextScene, Dictionary <string, object> param, Dictionary <string, object> previousParam, bool useStack)
 {
     InnerPrepareNextScene(caller, nextScene, param, previousParam, useStack, null);
 }
Esempio n. 21
0
        private void ChangeScene(ISceneBase caller)
        {
            var scene = CreateScene();

            sceneManager.PrepareNextScene(caller, scene, null, null);
        }
Esempio n. 22
0
        private void InnerPrepareNextScene(ISceneBase caller, ISceneBase nextScene, Dictionary <string, object> param, Dictionary <string, object> previousParam, bool useStack, ResourceManager resourceManager)
        {
            this.nextScene             = nextScene;
            nextScene.Sound            = Sound;
            nextScene.SceneManager     = this;
            nextScene.GameHost         = GameHost;
            previousSceneResourceUsing = false;
            if (resourceManager != null)
            {
                nextScene.ResourceManager = resourceManager;
            }
            else
            {
                if (String.IsNullOrEmpty(nextScene.SpriteDir))
                {
                    if (caller != null)
                    {
                        nextScene.ResourceManager  = caller.ResourceManager;
                        previousSceneResourceUsing = true;
                    }
                    else
                    {
                        nextScene.ResourceManager = new ResourceManager();
                    }
                }
                else
                {
                    nextScene.ResourceManager = new ResourceManager(new Tuple <ResourceManager, bool>[] {
                        new Tuple <ResourceManager, bool>(new SpriteResourceManager(device, nextScene.SpriteDir), true),
                        new Tuple <ResourceManager, bool>(caller.ResourceManager, false)
                    });
                    previousSceneResourceUsing = true;
                }
            }
            nextScene.Param         = param ?? new Dictionary <string, object>();
            nextScene.PreviousParam = globalPool.ContainsKey(nextScene.GetType()) ? globalPool[nextScene.GetType()] : new Dictionary <string, object>();
            if (previousParam != null && caller != null)
            {
                if (globalPool.ContainsKey(caller.GetType()))
                {
                    globalPool[caller.GetType()] = previousParam;
                }
                else
                {
                    globalPool.Add(caller.GetType(), previousParam);
                }
            }

            if (useStack)
            {
                nextScene.IsInSceneStack = true;
                sceneStack.Push(CurrentScene);
            }
            else
            {
                previousScene = CurrentScene;
            }

            CurrentScene  = null;
            lastTime      = Environment.TickCount;
            loadingThread = ThreadManager.Instance.GetThread(() =>
            {
                loadResult = nextScene.Load();
            });
            loadingThread.Start();
            if (LoadingScene != null)
            {
                LoadingScene.EnterLoading();
            }
            if (EnterLoading != null)
            {
                EnterLoading.Invoke(this, EventArgs.Empty);
            }
        }
Esempio n. 23
0
 /// <summary>
 /// Creates a new game manager
 /// </summary>
 /// <param name="firstScene">First scene</param>
 public Game(ISceneBase firstScene)
 {
     _SceneManager    = new SceneManager(firstScene);
     _KeyboardManager = new KeyboardManager(this);
 }
Esempio n. 24
0
 private void InnerStruct(ISceneBase baseScene)
 {
     stack          = new List <IFocusable>();
     this.baseScene = baseScene;
 }
Esempio n. 25
0
 /// <summary>
 /// コンストラクタです
 /// </summary>
 /// <param name="baseScene">フォーカスマネージャを管理するシーン</param>
 public FocusManager(ISceneBase baseScene)
 {
     InnerStruct(baseScene);
 }
Esempio n. 26
0
 /// <summary>
 /// Updates the scene flow
 /// </summary>
 /// <param name="game">Game manager</param>
 public void Update(Game game)
 {
     // If the next scene is the current scene
     if (_CurrentScene == NextScene)
     {
         // Then just keep it updated
         if (_CurrentScene != null)
             _CurrentScene.Update(game);
     }
     // If the next scene is something different, but the current one has started
     else if (_HasStarted)
     {
         // Then first terminates the current one
         _CurrentScene.Terminate(game);
         _HasStarted = false;
     }
     // If the next scene is something different and the current one hasn't started or just terminated
     else
     {
         // Goes to the next one
         _CurrentScene = NextScene;
         // And start it
         if (_CurrentScene != null)
             _CurrentScene.Start(game);
         _HasStarted = true;
     }
 }
Esempio n. 27
0
 /// <summary>
 /// Creates a new scene manager
 /// </summary>
 /// <param name="firstScene">First scene</param>
 public SceneManager(ISceneBase firstScene)
 {
     NextScene = firstScene;
 }
Esempio n. 28
0
 /// <summary>
 /// Creates a new game manager
 /// </summary>
 /// <param name="firstScene">First scene</param>
 public Game(ISceneBase firstScene)
 {
     _SceneManager    = new SceneManager(firstScene);
     _KeyboardManager = new KeyboardManager(this);
 }