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(); }
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(); }