コード例 #1
0
    // 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();
        }
    }
コード例 #2
0
ファイル: Program.cs プロジェクト: nullhtp/HashcodePizza
        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}");
            }
        }