Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / effects / EnemyDebris.cs
  1.  
  2. using System.Collections;
  3. using Godot;
  4.  
  5. [Tool]
  6. public partial class EnemyDebris : ActivityObject
  7. {
  8.  
  9. private GpuParticles2D _gpuParticles2D;
  10. public override void OnInit()
  11. {
  12. var frameCount = AnimatedSprite.SpriteFrames.GetFrameCount(AnimatorNames.Default);
  13. AnimatedSprite.Frame = Utils.Random.RandomRangeInt(0, frameCount - 1);
  14.  
  15. Throw(
  16. Utils.Random.RandomRangeInt(0, 16),
  17. Utils.Random.RandomRangeInt(10, 60),
  18. new Vector2(Utils.Random.RandomRangeInt(-25, 25), Utils.Random.RandomRangeInt(-25, 25)),
  19. Utils.Random.RandomRangeInt(-360, 360)
  20. );
  21.  
  22. StartCoroutine(EmitParticles());
  23. }
  24.  
  25. public IEnumerator EmitParticles()
  26. {
  27. var gpuParticles2D = GetNode<GpuParticles2D>("GPUParticles2D");
  28. gpuParticles2D.Emitting = true;
  29. yield return new WaitForSeconds(Utils.Random.RandomRangeFloat(1f, 2.5f));
  30. gpuParticles2D.Emitting = false;
  31. yield return new WaitForSeconds(1);
  32. BecomesStaticImage();
  33. }
  34. }