| | |
| | | public GenerateTileMap generateTileMap; |
| | | [NonSerialized] |
| | | public List<Vector3Int> destroyedTiles = new List<Vector3Int>(); |
| | | public GameObject pickups; |
| | | |
| | | private void Awake() |
| | | { |
| | |
| | | //Debug.Log(tilemap.HasTile(cellCoord)); |
| | | if (tilemap.HasTile(cellCoord)) |
| | | { |
| | | if (tilemap.GetInstantiatedObject(cellCoord)?.GetComponent<Drillable>()?.isDrillable ?? false) |
| | | GameObject tileGameObject = tilemap.GetInstantiatedObject(cellCoord); |
| | | if (tileGameObject?.GetComponent<Drillable>()?.isDrillable ?? false) |
| | | { |
| | | Vector3 cellWorldPosition = grid.CellToWorld(cellCoord); |
| | | // middle of tile |
| | | cellWorldPosition.x += 0.5f; |
| | | cellWorldPosition.y += 0.5f; |
| | | if (tileGameObject?.GetComponent<Dropable>()?.isDropable ?? false) |
| | | { |
| | | // Change no drops, only inventory |
| | | Instantiate(tileGameObject?.GetComponent<Dropable>().dropable, cellWorldPosition, Quaternion.identity, pickups.transform); |
| | | //Debug.Log(.name); |
| | | |
| | | } |
| | | tilemap.SetTile(cellCoord, null); |
| | | destroyedTiles.Add(cellCoord); |
| | | Vector3 moveToPosition = grid.CellToWorld(cellCoord); |
| | | moveToPosition.x += 0.5f; |
| | | moveToPosition.y += 0.5f; |
| | | CharacterEvents.characterDrillingToPosition.Invoke(moveToPosition, drillDirection); |
| | | } |
| | | CharacterEvents.characterDrillingToPosition.Invoke(cellWorldPosition, drillDirection); |
| | | } |
| | | else |
| | | { |
| | | //CharacterEvents.characterDrillingToPositionAbort.Invoke(moveToPosition); |