Beispiel #1
0
    protected override IEnumerator <float> _Reload(IClip clip, Func <int> getReserveAmmo, Action <int> callback)
    {
        while (true)
        {
            yield return(Timing.WaitForSeconds(reloadDurationPerPump));

            if (getReserveAmmo() <= 0)
            {
                yield break;
            }

            int ammoUsed = clip.TryFillAmmo(Mathf.Min(getReserveAmmo(), ammoReloadedPerPump));
            callback(ammoUsed);

            if (clip.IsFull())
            {
                yield break;
            }
        }
    }
Beispiel #2
0
 //onReloaded not to be confused with UnityEvent onReloadFinished. onReloaded is called internally 
 protected override IEnumerator<float> _Reload(IClip clip, Func<int> ammoInReserve, System.Action<int> callback) {
     yield return Timing.WaitForSeconds(reloadDuration);
     int ammoUsed = clip.TryFillAmmo(ammoInReserve());
     callback(ammoUsed);
 }