Пример #1
0
    void Start()
    {
        Cursor.lockState = CursorLockMode.Locked;
        HealthText.text  = "HP: " + Health.ToString();
        AmmoText.text    = "Magazine: " + CurrentMagazine.ToString() + "/ Ammo:" + Ammo.ToString();


        MyBody = GetComponent <Rigidbody>();
        Col    = GetComponent <Collider>();

        GroundDistance = Col.bounds.extents.y;
    }
Пример #2
0
    IEnumerator Fire()
    {
        if (CanAttack && CurrentMagazine > 0 && !Reload)
        {
            CanAttack = false;
            CurrentMagazine--;

            AmmoText.text = "Magazine: " + CurrentMagazine.ToString() + "/ Ammo:" + Ammo.ToString();

            Instantiate(Bullet, StartBullet.transform.position, StartBullet.transform.rotation);

            if (CurrentMagazine <= 0)
            {
                StartCoroutine(StartReload());
                Reload = true;
            }
            CanAttack = true;
            yield return(new WaitForSeconds(1f));
        }
    }
Пример #3
0
    IEnumerator StartReload()
    {
        yield return(new WaitForSeconds(1f));

        if (Ammo > Magazine)
        {
            int Num = Magazine;
            Num             = Num - CurrentMagazine;
            Ammo           -= Num;
            CurrentMagazine = Magazine;
        }
        else
        {
            CurrentMagazine = Ammo;
            Ammo            = 0;
        }

        AmmoText.text = "Magazine: " + CurrentMagazine.ToString() + "/ Ammo:" + Ammo.ToString();

        Reload = false;
    }