예제 #1
0
 /// <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);
     }
 }
예제 #2
0
    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]);
    }
예제 #3
0
 public void SetMaxReloads(GunManagement.Guns gunType, int numReloads)
 {
     gunMaxReloads[gunType]     = numReloads;
     gunCurrentReloads[gunType] = numReloads;
     reloadIcons[gunType].SetReloads(numReloads);
 }