public IEnumerator Supply(UnitBase target, int fuel, int ammo, int metal) { var elapsedTime = Mathf.Max((fuel * Settings.Replay.FuelMultiplier + ammo * Settings.Replay.AmmoMultiplier + metal * Settings.Replay.MetalMultiplier) / Settings.Replay.SupplyRate, 0.1f); StartCoroutine(Beam(target, elapsedTime, BeamType.Supply)); yield return new WaitForSeconds((target.transform.WorldCenterOfElement() - Beamer.position).magnitude / Settings.Replay.BeamSpeed); target.FlashingOn(); var effectedFuel = 0; var effectedAmmo = 0; var effectedMetal = 0; for (float t, startTime = Time.time; (t = (Time.time - startTime) / elapsedTime) < 1;) { if (!Data.GamePaused) { var deltaFuel = Mathf.RoundToInt(fuel * t - effectedFuel); if (deltaFuel > 0) { targetFuel -= deltaFuel; target.targetFuel += deltaFuel; effectedFuel += deltaFuel; } var deltaAmmo = Mathf.RoundToInt(ammo * t - effectedAmmo); if (deltaAmmo > 0) { targetAmmo -= deltaAmmo; target.targetAmmo += deltaAmmo; effectedAmmo += deltaAmmo; } var deltaMetal = Mathf.RoundToInt(metal * t - effectedMetal); if (deltaMetal > 0) { targetMetal -= deltaMetal; target.targetMetal += deltaMetal; effectedMetal += deltaMetal; } } yield return null; } targetFuel -= fuel - effectedFuel; target.targetFuel += fuel - effectedFuel; targetAmmo -= ammo - effectedAmmo; target.targetAmmo += ammo - effectedAmmo; targetMetal -= metal - effectedMetal; target.targetMetal += metal - effectedMetal; target.FlashingOff(); string message; if (metal == 0) if (ammo == 0) message = fuel > 0 ? "F: +" + fuel : "0"; else message = (fuel > 0 ? "F: +" + fuel + " " : "") + "A: +" + ammo; else message = (fuel > 0 ? "F: +" + fuel + " " : "") + (ammo > 0 ? "A: +" + ammo + " " : "") + "M: +" + metal; yield return StartCoroutine(Data.Replay.Instance.ShowMessageAt(target, message)); --Data.Replay.SuppliesLeft; }