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