Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / activity / bullet / normal / BrushBullet.cs
  1.  
  2. using Godot;
  3.  
  4. /// <summary>
  5. /// 带笔刷的子弹
  6. /// </summary>
  7. [Tool]
  8. public partial class BrushBullet : Bullet
  9. {
  10. /// <summary>
  11. /// 笔刷 id
  12. /// </summary>
  13. [Export]
  14. public string BrushId { get; set; }
  15.  
  16. /// <summary>
  17. /// 生效高度, 当物体离地高度小于这个值时生效, 当值小于 0 时一直生效
  18. /// </summary>
  19. [Export]
  20. public float EffectiveAltitude { get; set; } = -1;
  21.  
  22. private BrushImageData _brushData;
  23.  
  24. public override void OnInit()
  25. {
  26. base.OnInit();
  27. _brushData = LiquidBrushManager.GetBrush(BrushId);
  28. }
  29.  
  30. protected override void Process(float delta)
  31. {
  32. base.Process(delta);
  33. //测试笔刷
  34. if (EffectiveAltitude < 0 || Altitude <= EffectiveAltitude)
  35. {
  36. DrawLiquid(_brushData);
  37. }
  38. else
  39. {
  40. BrushPrevPosition = null;
  41. }
  42. }
  43.  
  44. public override void OnPlayDisappearEffect()
  45. {
  46. PlayDisappearEffect(ResourcePath.prefab_effect_bullet_BulletDisappear0002_tscn);
  47. }
  48.  
  49. public override void OnPlayCollisionEffect(KinematicCollision2D collision)
  50. {
  51. //测试笔刷
  52. DrawLiquid(_brushData);
  53. PlayCollisionEffect(collision, ResourcePath.prefab_effect_bullet_BulletSmoke0002_tscn);
  54. }
  55.  
  56. public override void OnLeavePool()
  57. {
  58. base.OnLeavePool();
  59. BrushPrevPosition = null;
  60. }
  61. }