public IEnumerator ClearMonsterSpawnCells(int fightId) { MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition; if (null == monsterSpawnCellDefinition) { yield break; } FightMapDefinition definition = m_definition; FightMapRegionDefinition obj = definition.regions[fightId]; Vector2Int sizeMin = obj.sizeMin; Vector2Int sizeMax = obj.sizeMax; List <int> indicesToRemove = ListPool <int> .Get(); foreach (KeyValuePair <int, GameObject> item in m_monsterSpawnCellDictionary) { int key = item.Key; Vector2Int cellCoords = definition.GetCellCoords(key); if (cellCoords.get_x() >= sizeMin.get_x() && cellCoords.get_y() >= sizeMin.get_y() && cellCoords.get_x() < sizeMax.get_x() && cellCoords.get_y() < sizeMax.get_y()) { Transform transform = item.Value.get_transform(); if (AudioManager.isReady) { AudioReference disappearanceSound = monsterSpawnCellDefinition.disappearanceSound; if (disappearanceSound.get_isValid()) { AudioManager.PlayOneShot(disappearanceSound, transform); } } VisualEffect disappearanceEffect = monsterSpawnCellDefinition.disappearanceEffect; if (null != disappearanceEffect) { Object.Instantiate <VisualEffect>(disappearanceEffect, transform.get_position(), transform.get_rotation(), transform.get_parent()); } indicesToRemove.Add(key); } } int indicesToRemoveCount = indicesToRemove.Count; if (indicesToRemoveCount > 0) { float disappearanceDelay = monsterSpawnCellDefinition.disappearanceDelay; if (disappearanceDelay > 0f) { yield return((object)new WaitForTime(disappearanceDelay)); } for (int i = 0; i < indicesToRemoveCount; i++) { int key2 = indicesToRemove[i]; if (m_monsterSpawnCellDictionary.TryGetValue(key2, out GameObject value)) { monsterSpawnCellDefinition.DestroyInstance(value); } } } ListPool <int> .Release(indicesToRemove); }
public IEnumerator RemoveMonsterSpawnCell(int x, int y) { MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition; if (null == monsterSpawnCellDefinition) { yield break; } int cellIndex = m_mapDefinition.GetCellIndex(x, y); if (!m_monsterSpawnCellDictionary.TryGetValue(cellIndex, out GameObject instance)) { yield break; } m_monsterSpawnCellDictionary.Remove(cellIndex); Transform transform = instance.get_transform(); if (AudioManager.isReady) { AudioReference disappearanceSound = monsterSpawnCellDefinition.disappearanceSound; if (disappearanceSound.get_isValid()) { AudioManager.PlayOneShot(disappearanceSound, transform); } } VisualEffect disappearanceEffect = monsterSpawnCellDefinition.disappearanceEffect; if (null != disappearanceEffect) { Object.Instantiate <VisualEffect>(disappearanceEffect, transform.get_position(), transform.get_rotation(), transform.get_parent()); float disappearanceDelay = monsterSpawnCellDefinition.disappearanceDelay; if (disappearanceDelay > 0f) { yield return((object)new WaitForTime(disappearanceDelay)); } } monsterSpawnCellDefinition.DestroyInstance(instance); }
public void Release() { CameraHandler.RemoveMapRotationListener(OnMapRotationChanged); if (FightLogicExecutor.isValid) { int regionCount = m_mapDefinition.regionCount; for (int i = 0; i < regionCount; i++) { FightStatus fightStatus = FightLogicExecutor.GetFightStatus(i); if (fightStatus != null) { fightStatus.EntitiesChanged -= OnEntitiesChanged; } } } MonsterSpawnCellDefinition monsterSpawnCellDefinition = m_bossFightMapResources.monsterSpawnCellDefinition; if (null != monsterSpawnCellDefinition) { foreach (GameObject value in m_monsterSpawnCellDictionary.Values) { monsterSpawnCellDefinition.DestroyInstance(value); } m_monsterSpawnCellDictionary.Clear(); m_monsterSpawnCellDictionary = null; monsterSpawnCellDefinition.Release(); } if (AudioManager.isReady) { m_audioContext.Release(); } m_worldMusicRequest = null; m_movementContexts = null; m_localMovementContext = null; m_activeMovementContext = null; m_targetContext = null; }