Esempio n. 1
0
    void Start()
    {
        // disable all weapon
        haveMainWpn = haveSecondWpn = havePistol = haveMeleeWpn = false;
        if (mainWeapon != null)
        {
            mainWeapon.NonActivate();
        }
        if (secondWeapon != null)
        {
            secondWeapon.NonActivate();
        }
        if (pistol != null)
        {
            pistol.NonActivate();
        }
        if (meleeWeapon != null)
        {
            meleeWeapon.NonActivate();
        }

        backpack = GetComponent <BackPack>();

        UIStart();
    }
Esempio n. 2
0
    IEnumerator ChangeWeapon(WeaponInstance weaponSelected)
    {
        canAttack = false;
        if (weaponSelected == currentWeapon)   // unhold weapon
        {
            animator.SetTrigger("ChangeWeapon");
            yield return(new WaitForSeconds(.4f));

            animator.SetLayerWeight(1, 0f);
            weaponSelected.NonActivate();
            currentWeapon = null;
            if (audioChangeWeapon != null)
            {
                audioSource.PlayOneShot(audioChangeWeapon);
            }
        }
        else
        {
            animator.SetLayerWeight(1, 1f);
            animator.SetTrigger("ChangeWeapon");
            if (currentWeapon != null)
            {
                currentWeapon.NonActivate();
            }
            yield return(new WaitForSeconds(.2f));

            currentWeapon = weaponSelected;
            currentWeapon.Use();
            UIAmmoWeapon(currentWeapon);
            if (audioChangeWeapon != null)
            {
                audioSource.PlayOneShot(audioChangeWeapon);
            }
        }
        canAttack = true;
        UIChangeWeapon();
    }