diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn index fc85de2..fd3989d 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=12 format=3 uid="uid://cjgnw37tqiqh7"] -[ext_resource type="Script" path="res://src/game/activity/bullet/normal/Bullet.cs" id="1_lpj81"] +[ext_resource type="Script" path="res://src/game/activity/bullet/normal/RandomFrameBullet.cs" id="1_56g2p"] [ext_resource type="Shader" path="res://resource/shader/Blend.gdshader" id="2_v0al6"] [ext_resource type="SpriteFrames" uid="uid://jj8oh76pi53j" path="res://resource/spriteFrames/bullet/Bullet0005.tres" id="3_mmvqn"] [ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/common/Smoke.png" id="4_esjg6"] @@ -64,10 +64,10 @@ collision_layer = 2 collision_mask = 0 platform_wall_layers = 512 -script = ExtResource("1_lpj81") +script = ExtResource("1_56g2p") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") -Particles2D = [] +Particles2D = [NodePath("AnimatedSprite/GPUParticles2D")] ShadowSprite = NodePath("ShadowSprite") AnimatedSprite = NodePath("AnimatedSprite") Collision = NodePath("Collision") diff --git a/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0005.tres b/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0005.tres index 49e5677..e51180c 100644 --- a/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0005.tres +++ b/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0005.tres @@ -1,14 +1,39 @@ -[gd_resource type="SpriteFrames" load_steps=2 format=3 uid="uid://jj8oh76pi53j"] +[gd_resource type="SpriteFrames" load_steps=6 format=3 uid="uid://jj8oh76pi53j"] [ext_resource type="Texture2D" uid="uid://cwk72cqlmii5b" path="res://resource/sprite/bullet/normal/bullet0005.png" id="1_qmb1b"] +[sub_resource type="AtlasTexture" id="AtlasTexture_07dy3"] +atlas = ExtResource("1_qmb1b") +region = Rect2(0, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_th8do"] +atlas = ExtResource("1_qmb1b") +region = Rect2(8, 0, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_gp16h"] +atlas = ExtResource("1_qmb1b") +region = Rect2(0, 8, 8, 8) + +[sub_resource type="AtlasTexture" id="AtlasTexture_e5slo"] +atlas = ExtResource("1_qmb1b") +region = Rect2(8, 8, 8, 8) + [resource] animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("1_qmb1b") +"texture": SubResource("AtlasTexture_07dy3") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_th8do") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_gp16h") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_e5slo") }], -"loop": true, +"loop": false, "name": &"default", -"speed": 5.0 +"speed": 0.0 }] diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/RandomFrameBullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/RandomFrameBullet.cs new file mode 100644 index 0000000..2e2f5b9 --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/RandomFrameBullet.cs @@ -0,0 +1,18 @@ + +using Godot; + +/// +/// 随机选择帧的子弹 +/// +[Tool] +public partial class RandomFrameBullet : Bullet +{ + public override void OnInit() + { + base.OnInit(); + var animation = AnimatedSprite.Animation; + var frameCount = AnimatedSprite.SpriteFrames.GetFrameCount(animation); + + AnimatedSprite.Frame = Utils.Random.RandomRangeInt(0, frameCount - 1); + } +} \ No newline at end of file