/// <summary> /// Start the reload process for a gun, assuming we have any reloads left for this gun. /// </summary> /// <param name="gunType"></param> public void StartReload(GunManagement.Guns gunType) { print("Trying to reload " + gunType); // Check if there are reloads left for this gun if (gunCurrentReloads[gunType] > 0) { print("Reloading " + gunType); gunCurrentReloads[gunType]--; StartCoroutine("ReloadGun", gunType); } }
IEnumerator ReloadGun(GunManagement.Guns gun) { float currentTime = 0; // Wait for time, filling up the reload feedback image while (currentTime < timeToReload) { currentTime += Time.deltaTime; gunReloadImages[gun].fillAmount = currentTime / timeToReload; yield return(null); } // Actuall reload gunClips[gun].Reload(); gunReloadImages[gun].fillAmount = 0; reloadIcons[gun].UseOneReload(gunCurrentReloads[gun]); }
public void SetMaxReloads(GunManagement.Guns gunType, int numReloads) { gunMaxReloads[gunType] = numReloads; gunCurrentReloads[gunType] = numReloads; reloadIcons[gunType].SetReloads(numReloads); }