void Update() { if (Input.GetMouseButtonDown(0) && ammoSlot.GetCurrentAmount(ammoType) > 0 && canShoot == true) { StartCoroutine(Shoot()); } DisplayAmmo(); }
//------------------------------------------------------------------------------------------------------------------------ // Process the different firing types private void ProcessAutoFire() { if (Input.GetButtonDown("Fire1")) { firingCorutine = StartCoroutine(FireContinuously()); } if (Input.GetButtonUp("Fire1")) { gunAnimator.SetBool(FIRING_BOOL, false); // To protect against null reference if (ammoSlot.GetCurrentAmount(ammoType) > 0) { StopCoroutine(firingCorutine); } } }
private void DisplayAmmo() { int currentAmmo = ammoSlot.GetCurrentAmount(AmmoType.Bullets); ammoText.text = currentAmmo.ToString(); }