private void PlaceLevelElement(Vector3 position, IPlacedObject objectToPlace, ILevelElement levelElement, bool cloneObject) { ISet <ILevelTile> levelTiles = objectInformationModule.GetLevelTilesOfLevelElement(objectToPlace, position); IList <IPlacedObject> placedObjects = objectInformationModule.GetInScenePlacedObjectsForLevelTiles(levelTiles); if (placedObjects.Count > 0) { objectDeletionModule.DeletePlacedObjects(placedObjects, false, true); } Vector2 worldPosition = objectInformationModule.GetPositionOfLevelTile(position); // The initialized placedObjects will be deleted automatically by garbage collector due to no reference at the end of this method // It is only important that the gameObjects are not visible anymore at this moment and will be deleted in the next time InstantiatePlacedObject(worldPosition, objectToPlace, cloneObject, levelElement); }
public void UpdateLevelTiles(IPlacedObject selectedObject) { Vector2 position = ((PlacedObject)selectedObject).gameObject.transform.position; if (selectedObject.Type == PrefabType.LEVELELEMENT) { ISet <ILevelTile> levelTiles = objectInformationModule.GetLevelTilesOfLevelElement(selectedObject, position); selectedObject.LevelTiles = levelTiles.ToList(); } else { ILevelTile levelTile = objectInformationModule.GetLevelTile(position); IList <ILevelTile> levelTiles = new List <ILevelTile>(); levelTiles.Add(levelTile); selectedObject.LevelTiles = levelTiles; } }