public void Clear() { level = null; levelManager = null; cameraInput = null; if (entityLoader != null) { ReferencePool.Release(entityLoader); } entityLoader = null; uiMaskFormSerialId = null; dataPlayer = null; dataTower = null; previewTowerData = null; previewTowerEntity = null; previewTowerEntityLogic = null; isBuilding = false; dicTowerInfo.Clear(); dicEntityEnemy.Clear(); }
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(); }
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); }