public IEnumerator LaunchTadpole() { if (ammo.Count > 0) { Bullet bullet = PopAmmo(); float timer = Time.time; bullet.Bind(targetTransform); if (OnStartAiming != null) { OnStartAiming.Invoke(); } yield return(new WaitUntil(() => { targetTransform.position = Target.normalized * Vector3.Distance(targetTransform.position, transform.position); return !IsAiming || IsTossing; } )); if (IsTossing) { Toss(Mathf.Clamp01((Time.time - timer) / maxDelayTime), bullet); IsTossing = false; } else if (OnStopAiming != null) { OnStopAiming.Invoke(); if (ammo.Count < ammoMax) { AddAmmo(bullet); } else { bullet.Release(); } } IsAiming = false; } }
public void AddAmmo(Bullet bullet) { bullet.Bind(ammoSlots[ammo.Count]); ammo.Add(bullet); }