diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn index 1c50d95..99852ed 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn @@ -60,12 +60,12 @@ color = Color(0.619608, 0.619608, 0.619608, 1) anim_offset_max = 1.0 -[node name="Bullet0003" type="CharacterBody2D" node_paths=PackedStringArray("Particles", "CollisionArea", "CollisionShape2D", "ShadowSprite", "AnimatedSprite", "Collision")] +[node name="Bullet0003" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 script = ExtResource("1_1jbgr") -Particles = NodePath("AnimatedSprite/GPUParticles2D") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") +Particles2D = [NodePath("AnimatedSprite/GPUParticles2D")] ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn index 499d04b..e5f968f 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn @@ -60,13 +60,14 @@ color = Color(0.95, 0.70965, 0.6365, 0.392157) anim_offset_max = 1.0 -[node name="Bullet0005" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "ShadowSprite", "AnimatedSprite", "Collision")] +[node name="Bullet0005" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 script = ExtResource("1_13wdl") BrushId = "0004" EffectiveAltitude = 1.0 CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") +Particles2D = [NodePath("AnimatedSprite/GPUParticles2D")] ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") diff --git a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs index f516e71..20db6e4 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs @@ -2,12 +2,19 @@ using System.Collections; using System.Collections.Generic; using Godot; +using Godot.Collections; /// /// 激光子弹 /// public partial class Laser : Area2D, IBullet { + /// + /// 子节点包含的例子特效, 在创建完成后自动播放 + /// + [Export] + public Array Particles2D { get; set; } + public CollisionShape2D Collision { get; private set; } public Sprite2D LineSprite { get; private set; } public RectangleShape2D Shape { get; private set; } @@ -117,6 +124,14 @@ DoReclaim(); })); _tween.Play(); + + if (Particles2D != null) + { + foreach (var particles2D in Particles2D) + { + particles2D.Restart(); + } + } } public override void _Process(double delta) @@ -176,6 +191,13 @@ public virtual void OnReclaim() { + if (Particles2D != null) + { + foreach (var particles2D in Particles2D) + { + particles2D.Emitting = false; + } + } if (OnReclaimEvent != null) { OnReclaimEvent(); diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs index c3285e5..e4ea58d 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs @@ -7,21 +7,6 @@ [Tool] public partial class BoomBullet : Bullet { - /// - /// 轨迹粒子 - /// - [Export] - public GpuParticles2D Particles; - - public override void InitData(BulletData data, uint attackLayer) - { - base.InitData(data, attackLayer); - if (Particles != null) - { - Particles.Restart(); - } - } - public override void OnLimeOver() { PlayBoom(); diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index 646ab05..4d5bf69 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -2,6 +2,7 @@ using System; using System.Collections; using Godot; +using Godot.Collections; /// /// 子弹类 @@ -11,7 +12,6 @@ { public event Action OnReclaimEvent; public event Action OnLeavePoolEvent; - public bool IsRecycled { get; set; } public string Logotype { get; set; } @@ -26,6 +26,12 @@ /// [Export, ExportFillNode] public CollisionShape2D CollisionShape2D { get; set; } + + /// + /// 子节点包含的例子特效, 在创建完成后自动播放 + /// + [Export] + public Array Particles2D { get; set; } /// /// 攻击的层级 @@ -108,6 +114,14 @@ { this.CallDelay(data.LifeTime, OnLimeOver); } + + if (Particles2D != null) + { + foreach (var particles2D in Particles2D) + { + particles2D.Restart(); + } + } } public override void OnMoveCollision(KinematicCollision2D collision) @@ -253,6 +267,13 @@ public virtual void OnReclaim() { + if (Particles2D != null) + { + foreach (var particles2D in Particles2D) + { + particles2D.Emitting = false; + } + } if (OnReclaimEvent != null) { OnReclaimEvent();