public void DestroyOneTile(Vector3 position) { Vector3 tilePosition = tilemapCollider2D.ClosestPoint(position); tilePositionInt = tilemap.WorldToCell(tilePosition); Invoke("DestroyLater", 0.05f); }
public void Exit(Collider2D col) { if (!isProcessing) { isProcessing = true; if (col.tag == "Player") { Vector3Int collisionPoint = map.WorldToCell(tileMapCollider2D.ClosestPoint(col.transform.position)); TileBase hasTile = map.GetTile(collisionPoint); if (hasTile != null) { if (!isLastDoor[(Vector2Int)collisionPoint]) { int door = doors[(Vector2Int)collisionPoint]; DirectorManager.DirectorInstance.UpdateState(door); SceneTransistionManager.SceneInstance.TransitionToScene(typeOfScene.Game); } else { UIManager.UiInstance.ChangeStateTo(UIState.InScoreboard); } } } isProcessing = false; } else { UIManager.UiInstance.ChangeStateTo(UIState.InScoreboard); } }
void SelectCell() { if (Input.GetKeyDown(KeyCode.Mouse0)) { Vector3 wp = Camera.main.ScreenToWorldPoint(Input.mousePosition); var touchPos = new Vector2(wp.x, wp.y); Vector2 tilePos = collider.ClosestPoint(touchPos); Cell tile = (Cell)tilemap.GetTile(new Vector3Int((int)tilePos.x, (int)tilePos.y, 0)); tile.alive = !tile.alive; } }