private Slider GetSliderOnTile(Tile tile, SideName side) { if (tile != null) { if (tile.GetType() == typeof(Slider)) { Slider slider = (Slider)tile; //slider moves left/right if left side is not attachable, so it moves on this rail if (!RobuzzleUtilities.IsTileAttachableOnSide(slider, side)) { return(slider); } } else if (tile.GetType() == typeof(SliderRail)) { SliderRail rail = (SliderRail)tile; if (RobuzzleUtilities.IsTileAttachableOnOppositeSide(rail, side)) { return(GetSliderOnTile( grid.GetTileAtPosition(tile.Position + RobuzzleUtilities.GetSideVector(side)), side)); } } } return(null); }
private Vector3Int GetExtremeBoundNIgnoreCollision(Slider slider, SliderRail rail, SideName side) { Physics.IgnoreCollision(slider.transform.GetChild(0).GetComponent <Collider>(), rail.transform.GetChild(0).GetComponent <Collider>(), true); grid.RemoveTile(rail); if (RobuzzleUtilities.IsTileAttachableOnSide(rail, side)) { Tile tile = grid.GetTileAtPosition(rail.Position + RobuzzleUtilities.GetSideVector(side)); if (tile != null && tile.GetType() == typeof(SliderRail)) { SliderRail rail2 = (SliderRail)tile; if (RobuzzleUtilities.IsTileAttachableOnOppositeSide(rail2, side)) { return(GetExtremeBoundNIgnoreCollision(slider, rail2, side)); } } return(rail.Position); } return(Vector3Int.zero); }