// Update is called once per frame
    void Update()
    {
        switch (clampState)
        {
        case (int)ClampStates.OPEN:
            transform.localRotation = openRotation;
            if (Input.GetButtonDown("Block Clamp") || xInput.GetButtonDown("Block Clamp"))
            {
                clampState = (int)ClampStates.CLOSING;
            }
            break;

        case (int)ClampStates.CLOSING:
            transform.localRotation = Quaternion.RotateTowards(transform.localRotation, closedRotation, closingSpeed * Time.deltaTime);
            if (Mathf.Abs(closedRotation.eulerAngles.x - transform.localRotation.eulerAngles.x) < 0.1f)
            {
                clampState = (int)ClampStates.CLOSED;
            }
            break;

        case (int)ClampStates.CLOSED:
            transform.localRotation = closedRotation;
            if (Input.GetButtonDown("Block Clamp") || xInput.GetButtonDown("Block Clamp"))
            {
                clampState = (int)ClampStates.OPENING;
            }
            break;

        case (int)ClampStates.OPENING:
            transform.localRotation = Quaternion.RotateTowards(transform.localRotation, openRotation, openingSpeed * Time.deltaTime);
            if (Mathf.Abs(openRotation.eulerAngles.x - transform.localRotation.eulerAngles.x) < 0.1f)
            {
                clampState = (int)ClampStates.OPEN;
            }
            break;

        default:
            break;
        }

        if (hasBlock)
        {
            //lock block to the clamp's transform
            capturedBlock.transform.position = blockTarget.position;
            capturedBlock.transform.rotation = blockTarget.rotation;

            if (clampState == (int)ClampStates.OPENING || clampState == (int)ClampStates.OPEN)
            {
                ReleaseBlock();
            }
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(1) || xInput.GetButtonDown("Camera View"))
        {
            currentView++;
            if (currentView >= (int)CameraViews.NUM_CAMERA_VIEWS)
            {
                currentView = 0;
            }
        }

        switch (currentView)
        {
        case (int)CameraViews.OBJECTIVE:
            chaser.enabled     = false;
            transform.position = initialPosition;
            transform.rotation = initialRotation;
            break;

        case (int)CameraViews.BACK:
            chaser.enabled = true;
            break;

        default:
            break;
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        switch (clampState)
        {
        case (int)ClampStates.OPEN:
            transform.localRotation = openRotation;
            transform.localPosition = openPosition;
            if (Input.GetButtonDown("Skyrise Clamp") || xInput.GetButtonDown("Skyrise Clamp"))
            {
                clampState = (int)ClampStates.CLOSING;
            }
            break;

        case (int)ClampStates.CLOSING:
            transform.localRotation = Quaternion.RotateTowards(transform.localRotation, closedRotation, closingSpeed * angleConversion * Time.deltaTime);
            transform.localPosition = Vector3.MoveTowards(transform.localPosition, closedPosition, closingSpeed * Time.deltaTime);
            if (Mathf.Abs(closedPosition.y - transform.localPosition.y) < 0.00001f)
            {
                clampState = (int)ClampStates.CLOSED;
            }
            break;

        case (int)ClampStates.CLOSED:
            transform.localRotation = closedRotation;
            transform.localPosition = closedPosition;
            if (Input.GetButtonDown("Skyrise Clamp") || xInput.GetButtonDown("Skyrise Clamp"))
            {
                clampState = (int)ClampStates.OPENING;
            }
            break;

        case (int)ClampStates.OPENING:
            transform.localRotation = Quaternion.RotateTowards(transform.localRotation, openRotation, openingSpeed * angleConversion * Time.deltaTime);
            transform.localPosition = Vector3.MoveTowards(transform.localPosition, openPosition, openingSpeed * Time.deltaTime);
            if (Mathf.Abs(openPosition.y - transform.localPosition.y) < 0.01f)
            {
                clampState = (int)ClampStates.OPEN;
            }
            break;

        default:
            break;
        }

        localPosition = transform.localPosition;
    }
Esempio n. 4
0
 // Update is called once per frame
 void Update()
 {
     if (Application.loadedLevel == 1 || Application.loadedLevel == 2)
     {
         xInput = GameObject.FindWithTag("Xbox Input").GetComponent <XboxInput>();
         if (Input.GetButtonDown("Pause") || xInput.GetButtonDown("Start"))
         {
             Application.LoadLevel(0);
         }
     }
 }
Esempio n. 5
0
    private bool GetButtonDown(ButtonSet.ButtonCascade buttonCascade)
    {
        try
        {
            if (UnityEngine.Input.GetButtonDown(buttonCascade.pcName))
            {
                return(true);
            }
        }
        catch (System.Exception) { }

        if (XboxInput.GetButtonDown(_inputId, buttonCascade.xboxButton))
        {
            return(true);
        }
        if (UIInput.GetButtonDown(buttonCascade.uIButton))
        {
            return(true);
        }
        return(false);
    }