BlastWaveController.cs 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. // Magica Cloth.
  2. // Copyright (c) MagicaSoft, 2020-2022.
  3. // https://magicasoft.jp
  4. using System.Collections;
  5. using UnityEngine;
  6. namespace MagicaCloth
  7. {
  8. public class BlastWaveController : MonoBehaviour
  9. {
  10. public MagicaAreaWind wind;
  11. public float attenuationStartTime = 1.0f;
  12. public float attenuationTime = 1.0f;
  13. IEnumerator Start()
  14. {
  15. if (wind)
  16. {
  17. float main = wind.Main;
  18. // Wait until attenuation starts.
  19. yield return new WaitForSeconds(attenuationStartTime);
  20. // Attenuation.
  21. float time = 0;
  22. while (time < attenuationTime)
  23. {
  24. float t = Mathf.Clamp01(1.0f - time / attenuationTime);
  25. wind.Main = main * t;
  26. time += Time.deltaTime;
  27. yield return null;
  28. }
  29. // destroy.
  30. Destroy(gameObject);
  31. }
  32. }
  33. }
  34. }