Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (captureFrame)
        {
            captureFrame = false;
            //Debug.Log(Time.deltaTime);
        }
        //pressing Y opens the Toolmenu, this blocks all other input
        if (Input.GetButtonDown("Y"))
        {
            _toolMenu.Activate();
            activeTool.Deactivate();
        }

        if (Input.GetButtonUp("Y"))
        {
            int toolIndex = _toolMenu.Deactivate();
            switch (toolIndex)
            {
            case 0:
                activeTool = splineTool;
                break;

            case 1:
                activeTool = stampTool;
                break;

            case 2:
                activeTool = meterTool;
                break;

            case 3:
                activeTool = eraserTool;
                break;
            }
            activeTool.Activate();
        }

        //If the Toolmenu is not open, process other inputs
        if (!Input.GetButton("Y"))
        {
            //The Left-Stick movement is used for CursorMovement
            float h = Input.GetAxis("Horizontal");
            float v = Input.GetAxis("Vertical");
            UpdateCursorPosition(h, v);

            offsetCursor = new Vector3(_cursor.position.x, _cursor.position.y, _cursor.position.z + 0.1f);

            //All a,b,x button inputs are delegated to the active tool
            activeTool.Update(offsetCursor, _cursor.localRotation, _cursor.localScale.x);
            if (Input.GetButton("A"))
            {
                activeTool.ButtonA();
            }
            if (Input.GetButtonDown("A"))
            {
                activeTool.ButtonADown();
            }
            if (Input.GetButtonUp("A"))
            {
                activeTool.ButtonAUp();
            }
            if (Input.GetButton("B"))
            {
                activeTool.ButtonB();
            }
            if (Input.GetButtonDown("B"))
            {
                activeTool.ButtonBDown();
            }
            if (Input.GetButtonUp("B"))
            {
                activeTool.ButtonBUp();
            }

            if (Input.GetButton("X"))
            {
                activeTool.ButtonX();
            }
            if (Input.GetButtonDown("X"))
            {
                activeTool.ButtonXDown();
            }
            if (Input.GetButtonUp("X"))
            {
                activeTool.ButtonXUp();
            }

            if (Input.GetButtonDown("LB"))
            {
                Undo();
            }

            if (Input.GetButtonDown("RB"))
            {
                Redo();
            }


            //The Right-Stick movement is used for CursorRotation(xAxis) and -Scaling(yAxis) MOVETO:StampTool
            float rX = Input.GetAxis("RightStickX");
            float rY = Input.GetAxis("RightStickY");
            if (Mathf.Abs(rX) > 0.3f || Mathf.Abs(rY) > 0.3f)
            {
                activeTool.RightStick(rX, rY);
            }
        }

        speed *= 0.75f;//friction
    }