diff --git a/DungeonShooting_Godot/prefab/effect/common/Effect1.tscn b/DungeonShooting_Godot/prefab/effect/common/Effect1.tscn index 9f4e524..9159fe4 100644 --- a/DungeonShooting_Godot/prefab/effect/common/Effect1.tscn +++ b/DungeonShooting_Godot/prefab/effect/common/Effect1.tscn @@ -2,9 +2,9 @@ [ext_resource type="Material" uid="uid://c1chld6lkpgji" path="res://resource/material/SmokeParticleMaterial.tres" id="1_dxavj"] [ext_resource type="Texture2D" uid="uid://bs1lan5uwxyfg" path="res://resource/curve/Curve1.tres" id="1_s60r7"] -[ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/effects/Smoke.png" id="2_3kyig"] -[ext_resource type="Texture2D" uid="uid://csud4e6kc3iku" path="res://resource/sprite/effects/Effect1.png" id="3_1mceu"] -[ext_resource type="Script" path="res://src/game/effects/Effect1.cs" id="3_ax5u4"] +[ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/effects/common/Smoke.png" id="2_3kyig"] +[ext_resource type="Texture2D" uid="uid://csud4e6kc3iku" path="res://resource/sprite/effects/common/Effect1.png" id="3_1mceu"] +[ext_resource type="Script" path="res://src/game/effects/AutoDestroyParticles.cs" id="3_2tlhx"] [sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_ipadv"] particles_animation = true @@ -16,16 +16,14 @@ particle_flag_align_y = true particle_flag_disable_z = true spread = 180.0 -gravity = Vector3(0, 0, 0) initial_velocity_min = 40.0 initial_velocity_max = 70.0 -orbit_velocity_min = 0.0 -orbit_velocity_max = 0.0 +gravity = Vector3(0, 0, 0) scale_min = 0.2 scale_max = 0.3 scale_curve = ExtResource("1_s60r7") -[node name="Effect1" type="GPUParticles2D"] +[node name="Effect1" type="GPUParticles2D" node_paths=PackedStringArray("Particles2D")] modulate = Color(0.760784, 0.760784, 0.760784, 0.533333) z_index = 5 material = SubResource("CanvasItemMaterial_ipadv") @@ -37,10 +35,13 @@ one_shot = true explosiveness = 1.0 fixed_fps = 20 -script = ExtResource("3_ax5u4") +script = ExtResource("3_2tlhx") +Particles2D = [NodePath("GPUParticles2D")] [node name="GPUParticles2D" type="GPUParticles2D" parent="."] emitting = false +amount = 6 +amount_ratio = 0.8 process_material = SubResource("ParticleProcessMaterial_p8jst") texture = ExtResource("3_1mceu") lifetime = 0.5 diff --git a/DungeonShooting_Godot/prefab/effect/enemy/Effect0001.tscn b/DungeonShooting_Godot/prefab/effect/enemy/Effect0001.tscn index 4461145..3f4322b 100644 --- a/DungeonShooting_Godot/prefab/effect/enemy/Effect0001.tscn +++ b/DungeonShooting_Godot/prefab/effect/enemy/Effect0001.tscn @@ -1,10 +1,11 @@ [gd_scene load_steps=31 format=3 uid="uid://pr88a1phtxgb"] -[ext_resource type="Script" path="res://src/game/effects/EnemyDebris.cs" id="1_ttosm"] +[ext_resource type="Script" path="res://src/game/effects/enemy/EnemyDebris.cs" id="1_ttosm"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_h62s7"] [ext_resource type="Texture2D" uid="uid://cn64eauvwx1uj" path="res://resource/sprite/role/enemy0001/enemy0001_Debris.png" id="3_6ewaj"] [ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/effects/common/Smoke.png" id="4_wu0t6"] + [sub_resource type="ShaderMaterial" id="ShaderMaterial_s1mj2"] resource_local_to_scene = true shader = ExtResource("2_h62s7") diff --git a/DungeonShooting_Godot/prefab/effect/weapon/BulletDisappear.tscn b/DungeonShooting_Godot/prefab/effect/weapon/BulletDisappear.tscn index 6572e0c..0f40391 100644 --- a/DungeonShooting_Godot/prefab/effect/weapon/BulletDisappear.tscn +++ b/DungeonShooting_Godot/prefab/effect/weapon/BulletDisappear.tscn @@ -56,13 +56,11 @@ [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_r1yeu"] lifetime_randomness = 0.3 particle_flag_disable_z = true +angle_max = 360.0 spread = 180.0 -gravity = Vector3(0, 0, 0) initial_velocity_min = 45.0 initial_velocity_max = 65.0 -orbit_velocity_min = 0.0 -orbit_velocity_max = 0.0 -angle_max = 360.0 +gravity = Vector3(0, 0, 0) scale_min = 0.3 scale_max = 0.6 scale_curve = SubResource("CurveTexture_j77i6") @@ -74,7 +72,6 @@ z_index = -4 scale = Vector2(0.5, 0.5) sprite_frames = SubResource("SpriteFrames_ub3cw") -autoplay = "default" script = ExtResource("2_l2qlq") DelayTime = 0.3 Particles2D = [NodePath("GPUParticles2D")] diff --git a/DungeonShooting_Godot/prefab/effect/weapon/BulletSmoke.tscn b/DungeonShooting_Godot/prefab/effect/weapon/BulletSmoke.tscn index d13cf17..e34e5aa 100644 --- a/DungeonShooting_Godot/prefab/effect/weapon/BulletSmoke.tscn +++ b/DungeonShooting_Godot/prefab/effect/weapon/BulletSmoke.tscn @@ -1,8 +1,9 @@ -[gd_scene load_steps=9 format=3 uid="uid://b8ogu2l8pa70y"] +[gd_scene load_steps=7 format=3 uid="uid://b8ogu2l8pa70y"] [ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/effects/common/Smoke.png" id="1"] [ext_resource type="Texture2D" uid="uid://bs1lan5uwxyfg" path="res://resource/curve/Curve1.tres" id="1_8pe88"] -[ext_resource type="Texture2D" uid="uid://dwa4chrugc6b1" path="res://resource/sprite/effects/weapon/Collision1.png" id="2"] +[ext_resource type="SpriteFrames" uid="uid://pwg2tx7dmcvp" path="res://resource/spriteFrames/effect/weapon/Collision1.tres" id="1_r62v8"] +[ext_resource type="Script" path="res://src/game/effects/AutoDestroySprite.cs" id="2_r547d"] [sub_resource type="CanvasItemMaterial" id="1"] particles_animation = true @@ -13,116 +14,22 @@ [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_gpp81"] lifetime_randomness = 0.5 particle_flag_disable_z = true -spread = 25.0 -gravity = Vector3(0, 0, 0) -initial_velocity_max = 90.0 -orbit_velocity_min = 0.0 -orbit_velocity_max = 0.0 angle_max = 360.0 +spread = 25.0 +initial_velocity_max = 90.0 +gravity = Vector3(0, 0, 0) scale_curve = ExtResource("1_8pe88") color = Color(0.75, 0.75, 0.75, 0.470588) anim_offset_max = 1.0 -[sub_resource type="Animation" id="5"] -length = 0.001 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:emitting") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [false] -} -tracks/1/type = "value" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath("Sprite2D:frame") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [0] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Sprite2D:visible") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0), -"transitions": PackedFloat32Array(1), -"update": 0, -"values": [true] -} +[node name="BulletSmoke" type="AnimatedSprite2D" node_paths=PackedStringArray("Particles2D")] +sprite_frames = ExtResource("1_r62v8") +offset = Vector2(8, 0) +script = ExtResource("2_r547d") +Particles2D = [NodePath("GpuParticles2D")] -[sub_resource type="Animation" id="6"] -resource_name = "Smoke" -step = 0.05 -tracks/0/type = "value" -tracks/0/imported = false -tracks/0/enabled = true -tracks/0/path = NodePath(".:emitting") -tracks/0/interp = 1 -tracks/0/loop_wrap = true -tracks/0/keys = { -"times": PackedFloat32Array(0, 0.05), -"transitions": PackedFloat32Array(1, 1), -"update": 1, -"values": [true, false] -} -tracks/1/type = "method" -tracks/1/imported = false -tracks/1/enabled = true -tracks/1/path = NodePath(".") -tracks/1/interp = 1 -tracks/1/loop_wrap = true -tracks/1/keys = { -"times": PackedFloat32Array(1), -"transitions": PackedFloat32Array(1), -"values": [{ -"args": [], -"method": &"queue_free" -}] -} -tracks/2/type = "value" -tracks/2/imported = false -tracks/2/enabled = true -tracks/2/path = NodePath("Sprite2D:frame") -tracks/2/interp = 1 -tracks/2/loop_wrap = true -tracks/2/keys = { -"times": PackedFloat32Array(0, 0.05, 0.1, 0.15), -"transitions": PackedFloat32Array(1, 1, 1, 1), -"update": 1, -"values": [0, 1, 2, 3] -} -tracks/3/type = "value" -tracks/3/imported = false -tracks/3/enabled = true -tracks/3/path = NodePath("Sprite2D:visible") -tracks/3/interp = 1 -tracks/3/loop_wrap = true -tracks/3/keys = { -"times": PackedFloat32Array(0, 0.2), -"transitions": PackedFloat32Array(1, 1), -"update": 1, -"values": [true, false] -} - -[sub_resource type="AnimationLibrary" id="AnimationLibrary_uuiu7"] -_data = { -"RESET": SubResource("5"), -"Smoke": SubResource("6") -} - -[node name="BulletSmoke" type="GPUParticles2D"] +[node name="GpuParticles2D" type="GPUParticles2D" parent="."] +z_index = -1 material = SubResource("1") emitting = false process_material = SubResource("ParticleProcessMaterial_gpp81") @@ -131,15 +38,3 @@ one_shot = true explosiveness = 0.9 fixed_fps = 20 - -[node name="Sprite2D" type="Sprite2D" parent="."] -modulate = Color(1.6, 1.6, 1.6, 1) -texture = ExtResource("2") -offset = Vector2(8, 0) -hframes = 4 - -[node name="AnimationPlayer" type="AnimationPlayer" parent="."] -libraries = { -"": SubResource("AnimationLibrary_uuiu7") -} -autoplay = "Smoke" diff --git a/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack1.tscn b/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack1.tscn index 9d50730..b8b60dc 100644 --- a/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack1.tscn +++ b/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack1.tscn @@ -39,8 +39,8 @@ "speed": 20.0 }] -[node name="MeleeAttack1" type="AnimatedSprite2D"] +[node name="MeleeAttack1" type="AnimatedSprite2D" node_paths=PackedStringArray("Particles2D")] sprite_frames = SubResource("SpriteFrames_hkcv6") -autoplay = "default" script = ExtResource("2_bjagc") DelayTime = 0.2 +Particles2D = [] diff --git a/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack2.tscn b/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack2.tscn index 3796f4a..307a111 100644 --- a/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack2.tscn +++ b/DungeonShooting_Godot/prefab/effect/weapon/MeleeAttack2.tscn @@ -3,8 +3,8 @@ [ext_resource type="SpriteFrames" uid="uid://dj8o7ws03bik4" path="res://resource/spriteFrames/effect/KnifeHit1.tres" id="1_ds7pw"] [ext_resource type="Script" path="res://src/game/effects/AutoDestroySprite.cs" id="2_hl3gp"] -[node name="MeleeAttack2" type="AnimatedSprite2D"] +[node name="MeleeAttack2" type="AnimatedSprite2D" node_paths=PackedStringArray("Particles2D")] sprite_frames = ExtResource("1_ds7pw") -autoplay = "default" script = ExtResource("2_hl3gp") DelayTime = 0.12 +Particles2D = [] diff --git a/DungeonShooting_Godot/prefab/effect/weapon/ShotFire.tscn b/DungeonShooting_Godot/prefab/effect/weapon/ShotFire.tscn index 8a03b47..2e53592 100644 --- a/DungeonShooting_Godot/prefab/effect/weapon/ShotFire.tscn +++ b/DungeonShooting_Godot/prefab/effect/weapon/ShotFire.tscn @@ -42,7 +42,6 @@ [node name="ShotFire" type="AnimatedSprite2D" node_paths=PackedStringArray("Particles2D")] modulate = Color(1.6, 1.6, 1.6, 1) sprite_frames = SubResource("SpriteFrames_73j16") -autoplay = "default" offset = Vector2(8, 0) script = ExtResource("2_lnwju") DelayTime = 0.2 diff --git a/DungeonShooting_Godot/prefab/effect/weapon/ShotFire2.tscn b/DungeonShooting_Godot/prefab/effect/weapon/ShotFire2.tscn index d2c9f8b..7073dc9 100644 --- a/DungeonShooting_Godot/prefab/effect/weapon/ShotFire2.tscn +++ b/DungeonShooting_Godot/prefab/effect/weapon/ShotFire2.tscn @@ -42,7 +42,6 @@ [node name="ShotFire2" type="AnimatedSprite2D" node_paths=PackedStringArray("Particles2D")] modulate = Color(1.6, 1.6, 1.6, 1) sprite_frames = SubResource("SpriteFrames_rry1m") -autoplay = "default" offset = Vector2(5.5, 0) script = ExtResource("2_4ecjw") DelayTime = 0.2 diff --git a/DungeonShooting_Godot/resource/spriteFrames/effect/weapon/Collision1.tres b/DungeonShooting_Godot/resource/spriteFrames/effect/weapon/Collision1.tres new file mode 100644 index 0000000..f0b7085 --- /dev/null +++ b/DungeonShooting_Godot/resource/spriteFrames/effect/weapon/Collision1.tres @@ -0,0 +1,42 @@ +[gd_resource type="SpriteFrames" load_steps=6 format=3 uid="uid://pwg2tx7dmcvp"] + +[ext_resource type="Texture2D" uid="uid://dwa4chrugc6b1" path="res://resource/sprite/effects/weapon/Collision1.png" id="1_fwdya"] + +[sub_resource type="AtlasTexture" id="AtlasTexture_howuv"] +atlas = ExtResource("1_fwdya") +region = Rect2(0, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_4qx75"] +atlas = ExtResource("1_fwdya") +region = Rect2(16, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_n6ula"] +atlas = ExtResource("1_fwdya") +region = Rect2(32, 0, 16, 16) + +[sub_resource type="AtlasTexture" id="AtlasTexture_5lumy"] +atlas = ExtResource("1_fwdya") +region = Rect2(48, 0, 16, 16) + +[resource] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_howuv") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_4qx75") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_n6ula") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_5lumy") +}, { +"duration": 1.0, +"texture": null +}], +"loop": false, +"name": &"default", +"speed": 25.0 +}] diff --git a/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs b/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs index ed410f7..cc9122b 100644 --- a/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs +++ b/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs @@ -298,10 +298,11 @@ activityObject.StartCoroutine(OnActivityObjectBirth(activityObject)); activityObject.PutDown(GetDefaultLayer(activityMark)); - var effect1 = ObjectPool.GetItem(ResourcePath.prefab_effect_common_Effect1_tscn); - effect1.Position = activityObject.Position + new Vector2(0, -activityMark.Altitude); - effect1.AddToActivityRoot(RoomLayerEnum.YSortLayer); - effect1.PlayEffect(); + var effect = ObjectManager.GetPoolItem(ResourcePath.prefab_effect_common_Effect1_tscn); + var node = (Node2D)effect; + node.Position = activityObject.Position + new Vector2(0, -activityMark.Altitude); + node.AddToActivityRoot(RoomLayerEnum.YSortLayer); + effect.PlayEffect(); } i++; diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index d033acc..72864cb 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -115,12 +115,13 @@ if (CurrentBounce > BulletData.BounceCount) //反弹次数超过限制 { //创建粒子特效 - var packedScene = ResourceManager.Load(ResourcePath.prefab_effect_weapon_BulletSmoke_tscn); - var smoke = packedScene.Instantiate(); + var effect = ObjectManager.GetPoolItem(ResourcePath.prefab_effect_weapon_BulletSmoke_tscn); + var smoke = (Node2D)effect; var rotated = AnimatedSprite.Position.Rotated(Rotation); smoke.GlobalPosition = collision.GetPosition() + new Vector2(0, rotated.Y); smoke.GlobalRotation = collision.GetNormal().Angle(); smoke.AddToActivityRoot(RoomLayerEnum.YSortLayer); + effect.PlayEffect(); DoReclaim(); } } @@ -197,10 +198,11 @@ /// public virtual void PlayDisappearEffect() { - var packedScene = ResourceManager.Load(ResourcePath.prefab_effect_weapon_BulletDisappear_tscn); - var node = packedScene.Instantiate(); + var effect = ObjectManager.GetPoolItem(ResourcePath.prefab_effect_weapon_BulletDisappear_tscn); + var node = (Node2D)effect; node.GlobalPosition = AnimatedSprite.GlobalPosition; node.AddToActivityRoot(RoomLayerEnum.YSortLayer); + effect.PlayEffect(); } protected override void Process(float delta) diff --git a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs index 54e4657..9ec8e03 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/buff/BuffPropProp0010.cs @@ -27,7 +27,7 @@ private void CalcBulletCountEvent(Weapon weapon, int originCount, RefValue refValue) { - refValue.Value += originCount * 10; + refValue.Value += originCount; } private void CalcBulletDeviationAngleEvent(Weapon weapon, float originAngle, RefValue refValue) diff --git a/DungeonShooting_Godot/src/game/effects/AutoDestroyParticles.cs b/DungeonShooting_Godot/src/game/effects/AutoDestroyParticles.cs index e93d63e..05ed68f 100644 --- a/DungeonShooting_Godot/src/game/effects/AutoDestroyParticles.cs +++ b/DungeonShooting_Godot/src/game/effects/AutoDestroyParticles.cs @@ -1,5 +1,6 @@  using Godot; +using Godot.Collections; /// /// 到期自动销毁的粒子特效 @@ -12,6 +13,12 @@ [Export] public float DelayTime { get; set; } = 1f; + /// + /// 子节点包含的例子特效, 在创建完成后自动播放 + /// + [Export] + public Array Particles2D { get; set; } + public bool IsDestroyed { get; private set; } public bool IsRecycled { get; set; } public string Logotype { get; set; } @@ -22,6 +29,13 @@ public virtual void PlayEffect() { Emitting = true; + if (Particles2D != null) + { + foreach (var gpuParticles2D in Particles2D) + { + gpuParticles2D.Emitting = true; + } + } _timer = 0; _isPlay = true; } @@ -36,6 +50,13 @@ if (_timer >= DelayTime) { Emitting = false; + if (Particles2D != null) + { + foreach (var gpuParticles2D in Particles2D) + { + gpuParticles2D.Emitting = false; + } + } _isPlay = false; ObjectPool.Reclaim(this); } diff --git a/DungeonShooting_Godot/src/game/effects/AutoDestroySprite.cs b/DungeonShooting_Godot/src/game/effects/AutoDestroySprite.cs index e3d24f9..ad8d15d 100644 --- a/DungeonShooting_Godot/src/game/effects/AutoDestroySprite.cs +++ b/DungeonShooting_Godot/src/game/effects/AutoDestroySprite.cs @@ -7,11 +7,17 @@ public partial class AutoDestroySprite : AnimatedSprite2D, IEffect { /// + /// 播放的动画名称 + /// + [Export] + public string AnimationName { get; set; } = "default"; + + /// /// 延时销毁时间 /// [Export] public float DelayTime { get; set; } = 1f; - + /// /// 子节点包含的例子特效, 在创建完成后自动播放 /// @@ -36,6 +42,7 @@ } _timer = 0; _isPlay = true; + Play(AnimationName); } public override void _Process(double delta) diff --git a/DungeonShooting_Godot/src/game/effects/Effect1.cs b/DungeonShooting_Godot/src/game/effects/Effect1.cs deleted file mode 100644 index 3d1902e..0000000 --- a/DungeonShooting_Godot/src/game/effects/Effect1.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Godot; - -public partial class Effect1 : AutoDestroyParticles -{ - private GpuParticles2D _particles2D; - private bool _init; - - public override void PlayEffect() - { - if (!_init) - { - _particles2D = GetNode("GPUParticles2D"); - _init = true; - } - - _particles2D.Amount = Utils.Random.RandomRangeInt(2, 6); - _particles2D.Emitting = true; - base.PlayEffect(); - } -} diff --git a/DungeonShooting_Godot/src/game/effects/EnemyDebris.cs b/DungeonShooting_Godot/src/game/effects/EnemyDebris.cs deleted file mode 100644 index d96d1c2..0000000 --- a/DungeonShooting_Godot/src/game/effects/EnemyDebris.cs +++ /dev/null @@ -1,48 +0,0 @@ - -using System.Collections; -using Godot; - -/// -/// 敌人死亡碎片 -/// -[Tool] -public partial class EnemyDebris : ActivityObject -{ - - private GpuParticles2D _gpuParticles2D; - private bool _playOver = false; - - public override void OnInit() - { - var frameCount = AnimatedSprite.SpriteFrames.GetFrameCount(AnimatorNames.Default); - AnimatedSprite.Frame = Utils.Random.RandomRangeInt(0, frameCount - 1); - - Throw( - Utils.Random.RandomRangeInt(0, 16), - Utils.Random.RandomRangeInt(10, 60), - new Vector2(Utils.Random.RandomRangeInt(-25, 25), Utils.Random.RandomRangeInt(-25, 25)), - Utils.Random.RandomRangeInt(-360, 360) - ); - - StartCoroutine(EmitParticles()); - } - - protected override void Process(float delta) - { - if (_playOver && !IsThrowing && Altitude <= 0 && MoveController.IsMotionless()) - { - MoveController.SetAllVelocity(Vector2.Zero); - Freeze(); - } - } - - public IEnumerator EmitParticles() - { - var gpuParticles2D = GetNode("GPUParticles2D"); - gpuParticles2D.Emitting = true; - yield return new WaitForSeconds(Utils.Random.RandomRangeFloat(1f, 2.5f)); - gpuParticles2D.Emitting = false; - yield return new WaitForSeconds(1); - _playOver = true; - } -} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/effects/enemy/EnemyDebris.cs b/DungeonShooting_Godot/src/game/effects/enemy/EnemyDebris.cs new file mode 100644 index 0000000..d96d1c2 --- /dev/null +++ b/DungeonShooting_Godot/src/game/effects/enemy/EnemyDebris.cs @@ -0,0 +1,48 @@ + +using System.Collections; +using Godot; + +/// +/// 敌人死亡碎片 +/// +[Tool] +public partial class EnemyDebris : ActivityObject +{ + + private GpuParticles2D _gpuParticles2D; + private bool _playOver = false; + + public override void OnInit() + { + var frameCount = AnimatedSprite.SpriteFrames.GetFrameCount(AnimatorNames.Default); + AnimatedSprite.Frame = Utils.Random.RandomRangeInt(0, frameCount - 1); + + Throw( + Utils.Random.RandomRangeInt(0, 16), + Utils.Random.RandomRangeInt(10, 60), + new Vector2(Utils.Random.RandomRangeInt(-25, 25), Utils.Random.RandomRangeInt(-25, 25)), + Utils.Random.RandomRangeInt(-360, 360) + ); + + StartCoroutine(EmitParticles()); + } + + protected override void Process(float delta) + { + if (_playOver && !IsThrowing && Altitude <= 0 && MoveController.IsMotionless()) + { + MoveController.SetAllVelocity(Vector2.Zero); + Freeze(); + } + } + + public IEnumerator EmitParticles() + { + var gpuParticles2D = GetNode("GPUParticles2D"); + gpuParticles2D.Emitting = true; + yield return new WaitForSeconds(Utils.Random.RandomRangeFloat(1f, 2.5f)); + gpuParticles2D.Emitting = false; + yield return new WaitForSeconds(1); + _playOver = true; + } +} \ No newline at end of file