Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / buffComp / active / Prop5003Area.cs
  1.  
  2. using System;
  3. using Godot;
  4.  
  5. public partial class Prop5003Area : Area2D
  6. {
  7. [Export]
  8. public Sprite2D CircleSprite;
  9. [Export]
  10. public CollisionShape2D Collision;
  11.  
  12. public CircleShape2D CircleShape;
  13. public GradientTexture2D Gradient;
  14. public override void _Ready()
  15. {
  16. CircleShape = (CircleShape2D)Collision.Shape;
  17. Gradient = (GradientTexture2D)CircleSprite.Texture;
  18. SetEnable(false);
  19. }
  20.  
  21. public void PlayEffect(int startRadius, int endRadius, float time)
  22. {
  23. var tween = CreateTween();
  24. tween.SetParallel();
  25. tween.TweenCallback(Callable.From(() =>
  26. {
  27. SetEnable(true);
  28. Modulate = Colors.White;
  29. }));
  30. tween.Chain();
  31. tween.TweenMethod(Callable.From<int>(SetRadius), startRadius, endRadius * 0.75f, time * 0.2f);
  32. tween.Chain();
  33.  
  34. tween.TweenInterval(time * 0.55f);
  35. tween.Chain();
  36. tween.TweenMethod(Callable.From<int>(SetRadius), endRadius * 0.75f, endRadius, time * 0.25f);
  37. tween.TweenProperty(this, "modulate", new Color(1, 1, 1, 0), time * 0.25f);
  38. tween.Chain();
  39. tween.TweenCallback(Callable.From(() =>
  40. {
  41. SetEnable(false);
  42. }));
  43. tween.Play();
  44. }
  45.  
  46. private void SetRadius(int radius)
  47. {
  48. Gradient.Width = radius * 2;
  49. Gradient.Height = radius * 2;
  50. CircleShape.Radius = radius;
  51. }
  52.  
  53. private void SetEnable(bool value)
  54. {
  55. Monitoring = value;
  56. CircleSprite.Visible = value;
  57. }
  58. }