Пример #1
0
 public void SetMesh()
 {
     if (isCircleToggle.isOn)
     {
         changeToCircle();
     }
     else
     {
         changeToCube();
     }
     trashBin.hide();
 }
Пример #2
0
    // Update is called once per frame
    void Update()
    {
        if (!canPlaceGear && !showGearToPlace)
        {
            exampleGear.transform.position = new Vector3(0, -10, 0);
        }
        //Toggle pausepanel on esc
        if (Input.GetKeyDown(KeyCode.Escape))
        {
            if (showPausePanel)
            {
                Resume();
            }
            else
            {
                Pause();
            }
        }

        //Dont place gears if paused
        if (showPausePanel)
        {
            return;
        }



        if (Input.GetMouseButtonUp(0))
        {
            RaycastHit hit;
            if (!Physics.Raycast(exampleGear.transform.position, Vector3.down, out hit))
            {
                return;
            }

            if (hit.collider.gameObject.name == "trashbin")
            {
                canPlaceGear    = false;
                showGearToPlace = false;
                exampleGear.transform.position = new Vector3(0, -10, 0);
            }

            if (showGearToPlace && canPlaceGear)
            {
                Gear gear = SpawnGear(placeGearPoint);
                activeGears.Add(gear);
                showGearToPlace = false;
                canPlaceGear    = false;
                RotationBehaviour.instance.Rotate();
            }
            trashCan.hide();
        }

        if (Input.GetMouseButton(0))
        {
        }
        if (Input.GetMouseButtonDown(0))
        {
            RaycastHit hit;
            exampleGear.SetActive(false);
            //Only place gear if mouse is over wood
            if (!Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
            {
                canPlaceGear = false;
                exampleGear.SetActive(true);
                exampleGear.transform.position = new Vector3(0, -10, 0);
                return;
            }

            exampleGear.SetActive(true);

            if (!showGearToPlace)
            {
                for (int i = 0; i < activeGears.Count; i++)
                {
                    if ((activeGears[i].position - hit.point).magnitude < activeGears[i].radius)
                    {
                        SelectGear(activeGears[i]);
                        removeGear(i);
                        showGearToPlace = true;
                        trashCan.show();
                    }
                }
                return;
            }

            //If gear can be placed, instantiate new gear
            if (canPlaceGear)
            {
                Gear gear = SpawnGear(placeGearPoint);
                activeGears.Add(gear);
                showGearToPlace = false;
                canPlaceGear    = false;
                RotationBehaviour.instance.Rotate();
            }
        }
        CalculateGearPlacePoint();
    }