private IEnumerator reloadRocket() { if (currentRockets > 0) { // Play Sound of rocket launcher reloading rocketSound.PlayOneShot(rocketReloadClip); //call brokers method weapon is reloading ReloadWeaponBroker.CallWeaponIsReloading(); yield return(new WaitForSecondsRealtime(rocketReloadSpeed)); currentRockets--; launcherIsReloading = false; rocketsInMagazine = 1; //Update bullet and magazines count on HUD AmmoDisplayBroker.CallUpdateAmmoOnHud(rocketsInMagazine, rocketsInMagazine); AmmoDisplayBroker.CallUpdateMagazinesOnHud(currentRockets); AmmoDisplayBroker.CallUpdateMagazinesOnStore(weaponIndex, currentRockets); ReloadWeaponBroker.CallWeaponFinishedReloading(); } else { Debug.Log("NO AMMO LEFT. RUN !!!"); ReloadWeaponBroker.CallWeaponFinishedReloading(); AmmoDisplayBroker.CallUpdateMagazinesOnStore(weaponIndex, currentRockets); } }
//Coroutine that reloads smg private IEnumerator ChangeMagazine() { if (currentMagazineCount > 0) { //call the method in the broker to invoke the reload event for the hud controller ReloadWeaponBroker.CallWeaponIsReloading(); //Play Reload Sound smgSound.PlayOneShot(smgReloadClip); yield return(new WaitForSecondsRealtime(smgReloadSpeed)); currentMagazineCount--; smgIsReloading = false; bulletsInMagazine = 30; //Update bullet and magazine count on HUD AmmoDisplayBroker.CallUpdateAmmoOnHud(bulletsInMagazine, smgMagazineSize); AmmoDisplayBroker.CallUpdateMagazinesOnHud(currentMagazineCount); AmmoDisplayBroker.CallUpdateMagazinesOnStore(weaponIndex, currentMagazineCount); // Debug.LogError("SMG RELOADED"); ReloadWeaponBroker.CallWeaponFinishedReloading(); } else { Debug.LogError("SMG OUT OF AMMO"); ReloadWeaponBroker.CallWeaponFinishedReloading(); AmmoDisplayBroker.CallUpdateMagazinesOnStore(weaponIndex, currentMagazineCount); } }
private IEnumerator ChangeMagazine() { if (currentMagazineCount > 0) { //Pistol reload SOUND pistolSound.PlayOneShot(pistolReloadClip); //Update the HUD to notify the player that the gun is reloading ReloadWeaponBroker.CallWeaponIsReloading(); currentMagazineCount--; AmmoDisplayBroker.CallUpdateMagazinesOnStore(weaponIndex, currentMagazineCount); //Wait for reload time yield return(new WaitForSecondsRealtime(pistolReloadSpeed)); pistolIsReloading = false; bulletsInMagazine = magazineSize; AmmoDisplayBroker.CallUpdateAmmoOnHud(bulletsInMagazine, magazineSize); AmmoDisplayBroker.CallUpdateMagazinesOnHud(currentMagazineCount); ReloadWeaponBroker.CallWeaponFinishedReloading(); } else { Debug.Log("NO AMMO LEFT. RUN !!!"); ReloadWeaponBroker.CallWeaponFinishedReloading(); AmmoDisplayBroker.CallUpdateMagazinesOnStore(weaponIndex, currentMagazineCount); } }