Пример #1
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(1))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                Vector3 clickPosition = hit.point;
                grid.highlightSquare(clickPosition);

                GameObject selectedPlane = hit.collider.gameObject;
                Grid.selectedPlane = selectedPlane;
                Debug.Log(Grid.selectedPlane.name);

                DrawLines(clickPosition, selectedPlane);
            }
        }
        else if (Input.GetMouseButtonDown(0))
        {
            Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit))
            {
                PotatoPlot potatoPlot = hit.collider.gameObject.GetComponent <PotatoPlot>();
                if (potatoPlot != null)
                {
                    potatoPlot.Harvest();
                }
            }
        }
    }
Пример #2
0
    public void harvestPotatos()
    {
        PotatoPlot potatoPlot = Grid.selectedPlane.GetComponent <PotatoPlot>();

        if (potatoPlot != null)
        {
            potatoPlot.Harvest();
        }
    }