Ejemplo n.º 1
0
    void PlaceItem()     //Fires when user is in placing state
    {
        if (Input.GetAxis("Mouse ScrollWheel") > 0f)
        {
            selection.GetComponent <SelectionController>().RotateSelectionBy(90);            //Rotate item
        }
        else if (Input.GetAxis("Mouse ScrollWheel") < 0f)
        {
            selection.GetComponent <SelectionController>().RotateSelectionBy(-90);            //Rotate item
        }

        if (!placeholderCollider.isSomethingWithin)
        {
            placeholder.GetComponent <MeshRenderer>().material = placeholderPossibleMaterial; //Set material to green
            if (Input.GetButtonDown("Fire1") && selection.activeSelf)                         //Place item and leave placing state
            {
                selectionController.PlaceItem();
                ChangeState(false, State.isPlacing);
            }
            else if (Input.GetButtonDown("Fire2"))             //Abandon placing state
            {
                selectionController.DiscardPlacing();
                ChangeState(false, State.isPlacing);
            }
        }
        else if (Input.GetButtonDown("Fire2"))         //Abandon placing state
        {
            selectionController.DiscardPlacing();
            ChangeState(false, State.isPlacing);
        }
        else
        {
            placeholder.GetComponent <MeshRenderer>().material = placeholderImpossibleMaterial;            //Set material to red
        }
    }