Exemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        Lazer.enabled = IsFiring;
        UpdateRecoilTime();

        SetFiringMode();
        SetValuesByFiringMode(FiringMode);

        if (currentEnergy < maxEnergy && !IsFiring)
        {
            currentEnergy += ChargeSpeed * Time.deltaTime;
        }

        if (device.GetPressDown(SteamVR_Controller.ButtonMask.Trigger))
        {
            if (FullAuto)
            {
                StartCoroutine(Auto());
                device.TriggerHapticPulse(3999);
            }
            else
            {
                StartCoroutine(Burst());
                device.TriggerHapticPulse(3999);
            }
            if (!_gunDisplay.GunMode)
            {
                _gunDisplay.HandleAction();
            }
        }
        else if (device.GetPressUp(SteamVR_Controller.ButtonMask.Trigger))
        {
            IsFiring = false;
        }

        CheckTouchpad();
    }
    void Update()
    {
        UpdateRecoilTime();
        _xRot -= Input.GetAxis("Mouse Y") * Sens;
        _yRot += Input.GetAxis("Mouse X") * Sens;
        transform.rotation = Quaternion.Euler(_xRot, _yRot, 0);

        _gunDisplay.ChangeMenuAction();
        SetFiringMode();
        SetValuesByFiringMode(FiringMode);

        if (currentEnergy < maxEnergy && !IsFiring)
        {
            currentEnergy += ChargeSpeed * Time.deltaTime;
        }


        if (!FullAuto)
        {
            if (Input.GetMouseButtonDown(0))
            {
                StartCoroutine(Burst());
            }
        }
        if (FullAuto)
        {
            if (Input.GetMouseButtonDown(0))
            {
                StartCoroutine(Auto());
            }
            if (Input.GetMouseButtonUp(0))
            {
                IsFiring = false;
            }
        }

        if (Input.GetKeyDown(KeyCode.W))
        {
            if (_gunDisplay.GunMode)
            {
                FiringMode--;
            }
            else
            {
                _gunDisplay.MenuAction--;
            }
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            if (_gunDisplay.GunMode)
            {
                FiringMode++;
            }
            else
            {
                _gunDisplay.MenuAction++;
            }
        }
        if (Input.GetKeyDown(KeyCode.R))
        {
            _gunDisplay.GunMode = !_gunDisplay.GunMode;
        }
        if (!_gunDisplay.GunMode && Input.GetKeyDown(KeyCode.F))
        {
            _gunDisplay.HandleAction();
        }
    }