Ejemplo n.º 1
0
    void Update()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        if (Pause.IsOn)
        {
            if (Cursor.lockState != CursorLockMode.None)
            {
                Cursor.lockState = CursorLockMode.None;
                Cursor.visible   = true;
            }
            return;
        }
        if (Cursor.lockState != CursorLockMode.Locked)
        {
            Cursor.lockState = CursorLockMode.Locked;
            Cursor.visible   = false;
        }

        if (Input.GetKeyDown(KeyCode.E) && (Time.time - powerUpRefreshTime > 5f))
        {
            print("HAVE POWER UP!");
            powerUpActive = true;
        }
        if (Input.GetMouseButton(0))
        {
            if (increaseSpeed < 125)
            {
                increaseSpeed += pullbackSpeed * Time.deltaTime;
            }
            else
            {
                if (!playedAudioOnce)
                {
                    playedAudioOnce = true;
                    firstPerson.PlayPulledBackFull();
                }
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            if (powerUpActive)
            {
                powerUpRefreshTime = Time.time;
                increaseSpeed      = 125f;
                hitScan            = true;
                Shoot();
                spawnVFX(hitScan);
                usedPowerUp   = true;
                powerUpActive = false;
                firstPerson.PlayKnockbackShootSound();
            }
            else
            {
                hitScan = false;
                spawnVFX(hitScan);
                firstPerson.PlayShootSound();
            }
            increaseSpeed   = speed;
            playedAudioOnce = false;
        }
    }