Ejemplo n.º 1
0
 public void ReloadBullets()
 {
     bullets       = magSize;
     canShoot      = true;
     currentState  = ShooterStates.Idle;
     ammoText.text = bullets.ToString();
 }
Ejemplo n.º 2
0
        // Update is called once per frame
        void Update()
        {
            if (currentState == ShooterStates.Idle || currentState == ShooterStates.Running)
            {
                if (walker.GetCurrentState() == MovementStates.Running)
                {
                    anim.SetBool("Sprint", true);
                    currentState = ShooterStates.Running;
                }
                else
                {
                    anim.SetBool("Sprint", false);
                    currentState = ShooterStates.Idle;
                }
            }
            switch (currentState)
            {
            case ShooterStates.Idle:
            case ShooterStates.Shooting:
                if (canShoot)
                {
                    if (Input.GetKey(KeyCode.Mouse0))
                    {
                        if (bullets > 1)
                        {
                            AudioManager.PlaySound(FPSExampleSounds.Gunshot);
                            StartCoroutine(ShootDelay());
                            anim.SetTrigger("Fire");
                            bullets--;
                            ammoText.text = bullets.ToString();
                        }
                        else if (bullets == 1)
                        {
                            anim.SetTrigger("FireFinal");
                            StartCoroutine(ShootDelay());
                            bullets--;
                            ammoText.text = bullets.ToString();
                            AudioManager.PlaySound(FPSExampleSounds.AKDryFire);
                        }
                    }
                    else if (Input.GetKeyUp(KeyCode.Mouse0))
                    {
                        anim.SetTrigger("FireStop");
                    }
                }
                if (Input.GetMouseButton(1))
                {
                    adsProgress = Mathf.Clamp(adsProgress + Time.deltaTime, 0, aimDownSightsTime);
                }
                if (Input.GetKeyDown(KeyCode.R) && adsProgress == 0)
                {
                    anim.SetInteger("Ammo", bullets);
                    anim.SetTrigger("Reload");
                    canShoot     = false;
                    currentState = ShooterStates.Reloading;
                }
                break;

            case ShooterStates.Reloading:
                break;
            }
            if (!Input.GetMouseButton(1))
            {
                adsProgress = Mathf.Clamp(adsProgress - Time.deltaTime, 0, aimDownSightsTime);
            }
            anim.SetFloat("AimDownSights", adsProgress / aimDownSightsTime);
        }
Ejemplo n.º 3
0
 public void ReloadBullets()
 {
     bullets      = magSize;
     canShoot     = true;
     currentState = ShooterStates.Idle;
 }