public override void Erase(GridLayout grid, GameObject layer, Vector3Int position) { BrushUtility .GetLayer(layerName) .GetComponent <Tilemap>() .SetTile(position, null); }
public override void Paint(GridLayout grid, GameObject layer, Vector3Int position) { // Get all LevelExits in grid LevelExit[] levelExits = BrushUtility.GetRootGrid().GetComponentsInChildren <LevelExit>(); for (int i = 0; i < levelExits.Length; ++i) { // If a LevelExit already exists at the current position, exit if (position == grid.WorldToCell(levelExits[i].transform.position)) { return; } } LevelExit le = BrushUtility.Instantiate <LevelExit>( prefab, BrushUtility.GetWorldPos(grid, position + prefabOffset), BrushUtility.GetLayer(layerName)); Tilemap tm = BrushUtility .GetLayer(layerName) .GetComponent <Tilemap>(); if (tm == null) { return; } le.SetGridAndTilemap(grid, tm); BrushUtility.RegisterUndo(tm, $"Add LevelExit tile to Grid"); tm.SetTile(grid.WorldToCell(le.transform.position), closedDoor); }
public override void Erase(GridLayout grid, GameObject layer, Vector3Int position) { SpawnPoint[] spawnPoints = BrushUtility.GetLayer(layerName).GetComponentsInChildren <SpawnPoint>(); for (int i = 0; i < spawnPoints.Length; ++i) { if (position != grid.WorldToCell(spawnPoints[i].transform.position)) { continue; } BrushUtility.Destroy(spawnPoints[i].gameObject); } }
public override void Paint(GridLayout grid, GameObject layer, Vector3Int position) { Tilemap tm = BrushUtility .GetLayer(layerName) .GetComponent <Tilemap>(); Killer killer = tm.gameObject.GetComponent <Killer>() ?? layer.AddComponent <Killer>(); killer.SetOnKilledEvent(onKilledEvent); killer.SetLayerMask(killerMask); tm.SetTile(position, tile); }
public override void Paint(GridLayout grid, GameObject layer, Vector3Int position) { // Get all SpawnPoints in layer SpawnPoint[] spawnPoints = BrushUtility.GetLayer(layerName).GetComponentsInChildren <SpawnPoint>(); for (int i = 0; i < spawnPoints.Length; ++i) { // If a SpawnPoint already exists at the current position, exit if (position == grid.WorldToCell(spawnPoints[i].transform.position)) { return; } } BrushUtility.Instantiate <SpawnPoint>( prefab, BrushUtility.GetWorldPos(grid, position + prefabOffset), BrushUtility.GetLayer(layerName)); }