public void Delete() { TileAreaActionHandler.Instance.DeselectTileAreaEntry(this); TileAreaActionHandler.Instance.TileAreaEntries.Remove(this); GameManager.Instance.CurrentEditorLevel.TileAreas.Remove(TileArea.Id); //Delete this tile area from any existing enemy spawnpoints for (int i = 0; i < MazeLevelGameplayManager.Instance.EnemyCharacterSpawnpoints.Count; i++) { Logger.Warning("remove tile area"); EnemySpawnpoint enemySpawnpoint = MazeLevelGameplayManager.Instance.EnemyCharacterSpawnpoints[i]; enemySpawnpoint.RemoveTileArea(TileArea); } GameObject.Destroy(gameObject); GameObject.Destroy(this); }
private void AddTileAreaToSpawnpoint() { if (_tileAreaNamesDropdown.value == 0) { return; } MazeTile selectedTile = EditorTileSelector.Instance.CurrentlySelectedTile as MazeTile; EnemySpawnpoint enemySpawnpoint = selectedTile?.TryGetEnemySpawnpoint(); if (enemySpawnpoint == null) { Logger.Log("could not find enemySpawnpoint on the selected tile"); return; } string currentlySelectedTileAreaId = GetIdCurrentSelectedTileArea(); TileArea tileAreaInList = enemySpawnpoint.TileAreas.FirstOrDefault(tileArea => tileArea.Id == currentlySelectedTileAreaId); TileArea tileArea = GameManager.Instance.CurrentEditorLevel.TileAreas[currentlySelectedTileAreaId]; if (tileAreaInList == null) { Logger.Log("did not find the area in the list, so we add it"); enemySpawnpoint.AddTileArea(tileArea); } else { Logger.Log($"The currently selected tile area is {tileAreaInList.Name}"); enemySpawnpoint.RemoveTileArea(tileArea); } _assignedAreasText.text = GenerateAssignedAreasText(enemySpawnpoint); RedrawDropdownOptions(); _tileAreaNamesDropdown.value = 0; }