Exemplo n.º 1
0
    public void Update()
    {
        if (Equiped)
        {
            BulletsNowText.text = BulletsCount.ToString();
            BulletsAllText.text = AllBulletsCount.ToString();

            if (BulletsCount == 0 && !reload)
            {
                Reload();
            }

            if (Input.GetKey(KeyCode.Mouse0) && !delay && !reload)
            {
                if (AllBulletsCount <= 0 && BulletsCount <= 0)
                {
                    if (!soundSource.isPlaying)
                    {
                        soundSource.PlayOneShot(TriggerSound);
                    }
                    return;
                }

                if (reloadInZoom)
                {
                    return;
                }

                Shoot();
            }


            if (Input.GetKeyDown(KeyCode.R) && !reload)
            {
                Reload();
            }

            if (Input.GetKeyDown(KeyCode.Mouse1))
            {
                scopeCam.enabled = true;

                aim.active = false;

                moveController.buf /= 2;
                animator.SetTrigger("Zoom");
            }
            if (Input.GetKeyUp(KeyCode.Mouse1))
            {
                scopeCam.enabled = false;

                aim.active = true;

                moveController.buf *= 2;
                animator.SetTrigger("DeZoom");
            }
        }
    }
Exemplo n.º 2
0
    public override void AddBullets(int b)
    {
        if (AllBulletsCount > maxBullets)
        {
            return;
        }

        AllBulletsCount++;

        BulletsCountText.text    = BulletsCount.ToString();
        AllBulletsCountText.text = AllBulletsCount.ToString();
    }
Exemplo n.º 3
0
    private void Reload()
    {
        if (BulletsCount == MagazineBulletsCount)
        {
            return;
        }

        if (AllBulletsCount == 0)
        {
            return;
        }

        if (zoom)
        {
            animator.SetTrigger("ReloadInZoom");
        }
        else
        {
            animator.SetTrigger("Reload");
        }


        soundSource.PlayOneShot(ReloadSound);


        int buf = MagazineBulletsCount - BulletsCount;

        if (buf > AllBulletsCount)
        {
            BulletsCount   += AllBulletsCount;
            AllBulletsCount = 0;
            return;
        }

        AllBulletsCount -= buf;
        BulletsCount    += buf;

        if (AllBulletsCount < 0)
        {
            AllBulletsCount = 0;
        }

        BulletsNowText.text = BulletsCount.ToString();
        BulletsAllText.text = AllBulletsCount.ToString();
    }
Exemplo n.º 4
0
    public void Update()
    {
        if (Equiped)
        {
            if (!anim.isPlaying)
            {
                anim.Play("Inactive");
            }

            BulletsNowText.text = BulletsCount.ToString();
            BulletsAllText.text = AllBulletsCount.ToString();

            if (BulletsCount == 0)
            {
                Reload();
            }

            if (Input.GetKeyDown(KeyCode.Mouse0) && !delay && !barrolAnimation.IsPlaying("Reload") && !anim.IsPlaying("Shoot"))
            {
                if (AllBulletsCount <= 0 && BulletsCount <= 0)
                {
                    soundSource.Stop();
                    soundSource.PlayOneShot(TriggerSound);
                    return;
                }


                anim.Play("Shoot");

                barrolAnimation.Play("BarrolRotation");
                Shoot();
            }


            if (Input.GetKeyDown(KeyCode.R) && !barrolAnimation.IsPlaying("Reload"))
            {
                Reload();
            }
        }
    }
Exemplo n.º 5
0
    private void Reload()
    {
        if (BulletsCount == 12)
        {
            return;
        }

        if (AllBulletsCount == 0)
        {
            return;
        }

        soundSource.PlayOneShot(ReloadSound);
        barrolAnimation.Play("Reload");

        int buf = 12 - BulletsCount;

        if (buf > AllBulletsCount)
        {
            BulletsCount   += AllBulletsCount;
            AllBulletsCount = 0;
            return;
        }


        AllBulletsCount -= buf;
        BulletsCount    += buf;

        if (AllBulletsCount < 0)
        {
            AllBulletsCount = 0;
        }

        BulletsNowText.text = BulletsCount.ToString();
        BulletsAllText.text = AllBulletsCount.ToString();
    }