protected override void OnLeave(ProcedureOwner procedureOwner, bool isShutdown)
        {
            base.OnLeave(procedureOwner, isShutdown);

            GameEntry.Event.Unsubscribe(ChangeSceneEventArgs.EventId, OnChangeScene);
            GameEntry.Event.Unsubscribe(LoadLevelEventArgs.EventId, OnLoadLevel);
            GameEntry.Event.Unsubscribe(LevelStateChangeEventArgs.EventId, OnLevelStateChange);
            GameEntry.Event.Unsubscribe(ReloadLevelEventArgs.EventId, OnReloadLevel);
            GameEntry.Event.Unsubscribe(GameoverEventArgs.EventId, OnGameOver);
            GameEntry.Event.Unsubscribe(ShowPreviewTowerEventArgs.EventId, OnShowPreviewTower);
            GameEntry.Event.Unsubscribe(BuildTowerEventArgs.EventId, OnBuildTower);
            GameEntry.Event.Unsubscribe(HideTowerInLevelEventArgs.EventId, OnSellTower);
            GameEntry.Event.Unsubscribe(StartWaveEventArgs.EventId, OnStartWave);
            GameEntry.Event.Unsubscribe(SpawnEnemyEventArgs.EventId, OnSpawnEnemy);
            GameEntry.Event.Unsubscribe(HideEnemyEventArgs.EventId, OnHideEnemyEntity);
            GameEntry.Event.Unsubscribe(ShowEntityInLevelEventArgs.EventId, OnShowEntityInLevel);
            GameEntry.Event.Unsubscribe(HideEntityInLevelEventArgs.EventId, OnHideEntityInLevel);

            levelControl.Quick();

            GameEntry.Sound.StopMusic();

            ReferencePool.Release(levelControl);
            levelControl = null;
        }
        public static LevelControl Create(Level level, LevelManager levelPathManager, CameraInput cameraInput)
        {
            LevelControl levelControl = ReferencePool.Acquire <LevelControl>();

            levelControl.level        = level;
            levelControl.levelManager = levelPathManager;
            levelControl.cameraInput  = cameraInput;
            return(levelControl);
        }
        protected override void OnEnter(ProcedureOwner procedureOwner)
        {
            base.OnEnter(procedureOwner);

            DataLevel dataLevel = GameEntry.Data.GetData <DataLevel>();

            LevelManager levelPathManager = UnityEngine.GameObject.Find("LevelManager").GetComponent <LevelManager>();

            if (levelPathManager == null)
            {
                Log.Error("Can not find LevelPathManager instance in scene");
                return;
            }

            CameraInput cameraInput = UnityEngine.GameObject.Find("GameCamera").GetComponent <CameraInput>();

            if (cameraInput == null)
            {
                Log.Error("Can not find CameraInput instance in scene");
                return;
            }

            levelControl = LevelControl.Create(dataLevel.CurrentLevel, levelPathManager, cameraInput);

            GameEntry.Event.Subscribe(ChangeSceneEventArgs.EventId, OnChangeScene);
            GameEntry.Event.Subscribe(LoadLevelEventArgs.EventId, OnLoadLevel);
            GameEntry.Event.Subscribe(LevelStateChangeEventArgs.EventId, OnLevelStateChange);
            GameEntry.Event.Subscribe(ReloadLevelEventArgs.EventId, OnReloadLevel);
            GameEntry.Event.Subscribe(GameoverEventArgs.EventId, OnGameOver);
            GameEntry.Event.Subscribe(ShowPreviewTowerEventArgs.EventId, OnShowPreviewTower);
            GameEntry.Event.Subscribe(BuildTowerEventArgs.EventId, OnBuildTower);
            GameEntry.Event.Subscribe(HideTowerInLevelEventArgs.EventId, OnSellTower);
            GameEntry.Event.Subscribe(StartWaveEventArgs.EventId, OnStartWave);
            GameEntry.Event.Subscribe(SpawnEnemyEventArgs.EventId, OnSpawnEnemy);
            GameEntry.Event.Subscribe(HideEnemyEventArgs.EventId, OnHideEnemyEntity);
            GameEntry.Event.Subscribe(ShowEntityInLevelEventArgs.EventId, OnShowEntityInLevel);
            GameEntry.Event.Subscribe(HideEntityInLevelEventArgs.EventId, OnHideEntityInLevel);

            this.procedureOwner = procedureOwner;
            this.changeScene    = false;

            GameEntry.Sound.PlayMusic(EnumSound.GameBGM);

            GameEntry.UI.OpenDownloadForm();

            levelControl.OnEnter();
        }