// Update is called once per frame void Update() { if (Input.GetMouseButton(0) && !isMouseDown) { HandleOnClickDown(); } else if (Input.GetMouseButtonUp(0)) { HandleOnClickUp(); Vector3 endPositionScreen = Input.mousePosition; Ray ray = cam.ScreenPointToRay(endPositionScreen); Ray ray1 = cam.ScreenPointToRay(startPositionScreen); Vector3 normal = Vector3.Cross(ray.direction, ray1.direction).normalized; List <GameObject> objects = FindObjects(startPositionScreen, endPositionScreen); foreach (GameObject obj in objects) { Slicer.Cut(obj, startPosition, normal); } } else if (Input.GetMouseButton(0) && isMouseDown) { // Draw from start position to mouse DrawLine(); } }
static void Main(string[] args) { var pizzaData = PizzaHelper.LoadPizzaFromFile("Data/big.in"); var slicer = new Slicer(pizzaData.MinIngridients, pizzaData.MaxPieces); var cuttedPizza = slicer.Cut(pizzaData.Pizza); PizzaHelper.SaveSlicesToFile(cuttedPizza.Slices, "big.out"); System.Console.WriteLine(cuttedPizza.Slices.Count); foreach (var slice in cuttedPizza.Slices) { System.Console.WriteLine( $"{slice.Coords.RowStart} {slice.Coords.ColumnStart} {slice.Coords.RowEnd} {slice.Coords.ColumnEnd}"); } }