diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 4229695..36c02a1 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net7.0 true @@ -6,7 +6,6 @@ - \ No newline at end of file diff --git a/DungeonShooting_Godot/DungeonShooting.csproj.old.2 b/DungeonShooting_Godot/DungeonShooting.csproj.old.2 new file mode 100644 index 0000000..543224c --- /dev/null +++ b/DungeonShooting_Godot/DungeonShooting.csproj.old.2 @@ -0,0 +1,11 @@ + + + net7.0 + true + + + + + + + \ No newline at end of file diff --git a/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn b/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn new file mode 100644 index 0000000..c25913b --- /dev/null +++ b/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn @@ -0,0 +1,322 @@ +[gd_scene load_steps=25 format=3 uid="uid://cw3c600m8rv6t"] + +[ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/sprite/effects/common/Smoke.png" id="1_ctx3v"] +[ext_resource type="Script" path="res://src/game/activity/bullet/explode/Explode.cs" id="1_qn5pu"] +[ext_resource type="Texture2D" uid="uid://ccdflg560oub6" path="res://resource/sprite/effects/explode/Explode_circle0001.png" id="2_bpdnr"] +[ext_resource type="Texture2D" uid="uid://rk73piti0qot" path="res://resource/sprite/effects/common/Smoke2.png" id="3_xt36q"] +[ext_resource type="Texture2D" uid="uid://cquv6nomd3tpf" path="res://resource/sprite/effects/explode/Explode_line0001.png" id="4_i3ry2"] + +[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_sk5lv"] +particles_animation = true +particles_anim_h_frames = 3 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="Gradient" id="Gradient_r2jo0"] +offsets = PackedFloat32Array(0.196911, 0.787645) +colors = PackedColorArray(0.862745, 0.862745, 0.862745, 0.741176, 0.34902, 0.34902, 0.34902, 0.933333) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_1neuh"] +gradient = SubResource("Gradient_r2jo0") + +[sub_resource type="Curve" id="Curve_2xqp4"] +_data = [Vector2(0, 0.516483), 0.0, 2.31551, 0, 0, Vector2(0.602787, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.274725), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_lbho4"] +curve = SubResource("Curve_2xqp4") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_8sxfm"] +particle_flag_disable_z = true +emission_shape = 3 +emission_box_extents = Vector3(5, 5, 5) +spread = 180.0 +initial_velocity_max = 30.0 +gravity = Vector3(0, 0, 0) +damping_max = 3.0 +scale_min = 0.5 +scale_curve = SubResource("CurveTexture_lbho4") +color_ramp = SubResource("GradientTexture1D_1neuh") +anim_offset_max = 1.0 + +[sub_resource type="Gradient" id="Gradient_36yod"] +offsets = PackedFloat32Array(0.196911, 0.791506) +colors = PackedColorArray(0.215686, 0.215686, 0.215686, 0.709804, 0.0196078, 0.0196078, 0.0196078, 0.537255) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_d3vr4"] +gradient = SubResource("Gradient_36yod") + +[sub_resource type="Curve" id="Curve_dvd5q"] +_data = [Vector2(0, 0.516483), 0.0, 2.31551, 0, 0, Vector2(0.602787, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.274725), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_anl6y"] +curve = SubResource("Curve_dvd5q") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_h3c43"] +particle_flag_disable_z = true +emission_shape = 3 +emission_box_extents = Vector3(4, 4, 4) +spread = 180.0 +initial_velocity_max = 25.0 +gravity = Vector3(0, 0, 0) +damping_max = 3.0 +scale_min = 1.3 +scale_max = 2.5 +scale_curve = SubResource("CurveTexture_anl6y") +color_ramp = SubResource("GradientTexture1D_d3vr4") +anim_offset_max = 1.0 + +[sub_resource type="Gradient" id="Gradient_wcvi2"] +offsets = PackedFloat32Array(0, 0.135135, 0.498069, 0.72973, 0.888031) +colors = PackedColorArray(1, 1, 1, 1, 0.976471, 0.862745, 0.34902, 0.843137, 1, 0.501961, 0.101961, 0.839216, 1, 0, 0, 0.690196, 0, 0, 0, 0.490196) + +[sub_resource type="GradientTexture1D" id="GradientTexture1D_ftewy"] +gradient = SubResource("Gradient_wcvi2") + +[sub_resource type="Curve" id="Curve_d4xab"] +_data = [Vector2(0, 0.318681), 0.0, 0.0, 0, 0, Vector2(0.146341, 1), 0.0, 0.0, 0, 0, Vector2(1, 0.120879), 0.0, 0.0, 0, 0] +point_count = 3 + +[sub_resource type="CurveTexture" id="CurveTexture_pdvs3"] +curve = SubResource("Curve_d4xab") + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_j41d3"] +lifetime_randomness = 0.5 +particle_flag_disable_z = true +spread = 180.0 +initial_velocity_max = 30.0 +gravity = Vector3(0, 0, 0) +damping_min = 0.5 +damping_max = 3.0 +scale_max = 2.0 +scale_curve = SubResource("CurveTexture_pdvs3") +color_ramp = SubResource("GradientTexture1D_ftewy") +anim_offset_max = 1.0 + +[sub_resource type="Animation" id="Animation_j6a2s"] +resource_name = "play" +step = 0.05 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0, 0.55), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, 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, 0.5), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0, 6] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Sprite2D2:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0.15, 0.45), +"transitions": PackedFloat32Array(1, 1), +"update": 1, +"values": [true, false] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Sprite2D2:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0.15, 0.4), +"transitions": PackedFloat32Array(1, 1), +"update": 0, +"values": [0, 5] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("GPUParticles2D:emitting") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0.15), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("GPUParticles2D2:emitting") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("GPUParticles2D3:emitting") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0.15), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} + +[sub_resource type="Animation" id="Animation_20asn"] +length = 0.001 +tracks/0/type = "value" +tracks/0/imported = false +tracks/0/enabled = true +tracks/0/path = NodePath("Sprite2D:visible") +tracks/0/interp = 1 +tracks/0/loop_wrap = true +tracks/0/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +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": 1, +"values": [0] +} +tracks/2/type = "value" +tracks/2/imported = false +tracks/2/enabled = true +tracks/2/path = NodePath("Sprite2D2:visible") +tracks/2/interp = 1 +tracks/2/loop_wrap = true +tracks/2/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [true] +} +tracks/3/type = "value" +tracks/3/imported = false +tracks/3/enabled = true +tracks/3/path = NodePath("Sprite2D2:frame") +tracks/3/interp = 1 +tracks/3/loop_wrap = true +tracks/3/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [0] +} +tracks/4/type = "value" +tracks/4/imported = false +tracks/4/enabled = true +tracks/4/path = NodePath("GPUParticles2D:emitting") +tracks/4/interp = 1 +tracks/4/loop_wrap = true +tracks/4/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/5/type = "value" +tracks/5/imported = false +tracks/5/enabled = true +tracks/5/path = NodePath("GPUParticles2D2:emitting") +tracks/5/interp = 1 +tracks/5/loop_wrap = true +tracks/5/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} +tracks/6/type = "value" +tracks/6/imported = false +tracks/6/enabled = true +tracks/6/path = NodePath("GPUParticles2D3:emitting") +tracks/6/interp = 1 +tracks/6/loop_wrap = true +tracks/6/keys = { +"times": PackedFloat32Array(0), +"transitions": PackedFloat32Array(1), +"update": 1, +"values": [false] +} + +[sub_resource type="AnimationLibrary" id="AnimationLibrary_p6l6x"] +_data = { +"RESET": SubResource("Animation_20asn"), +"play": SubResource("Animation_j6a2s") +} + +[node name="Explode0001" type="Area2D"] +modulate = Color(1.4, 1.4, 1.4, 1) +script = ExtResource("1_qn5pu") + +[node name="GPUParticles2D3" type="GPUParticles2D" parent="."] +material = SubResource("CanvasItemMaterial_sk5lv") +emitting = false +process_material = SubResource("ParticleProcessMaterial_8sxfm") +texture = ExtResource("3_xt36q") +one_shot = true +explosiveness = 0.6 +randomness = 1.0 + +[node name="GPUParticles2D" type="GPUParticles2D" parent="."] +material = SubResource("CanvasItemMaterial_sk5lv") +emitting = false +amount = 10 +process_material = SubResource("ParticleProcessMaterial_h3c43") +texture = ExtResource("1_ctx3v") +one_shot = true +explosiveness = 0.6 +randomness = 1.0 + +[node name="GPUParticles2D2" type="GPUParticles2D" parent="."] +material = SubResource("CanvasItemMaterial_sk5lv") +emitting = false +amount = 25 +process_material = SubResource("ParticleProcessMaterial_j41d3") +texture = ExtResource("1_ctx3v") +one_shot = true +explosiveness = 0.7 +randomness = 1.0 + +[node name="Sprite2D" type="Sprite2D" parent="."] +texture = ExtResource("2_bpdnr") +hframes = 7 + +[node name="Sprite2D2" type="Sprite2D" parent="."] +texture = ExtResource("4_i3ry2") +hframes = 6 + +[node name="AnimationPlayer" type="AnimationPlayer" parent="."] +libraries = { +"": SubResource("AnimationLibrary_p6l6x") +} diff --git a/DungeonShooting_Godot/resource/sprite/effects/Circle2.png b/DungeonShooting_Godot/resource/sprite/effects/Circle2.png new file mode 100644 index 0000000..c27b68f --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/Circle2.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/effects/Circle2.png.import b/DungeonShooting_Godot/resource/sprite/effects/Circle2.png.import new file mode 100644 index 0000000..dfcc3c1 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/Circle2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://hsevliqnq82n" +path="res://.godot/imported/Circle2.png-ef3a2d65cdf8bc187c245a202bc736dd.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/effects/Circle2.png" +dest_files=["res://.godot/imported/Circle2.png-ef3a2d65cdf8bc187c245a202bc736dd.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/resource/sprite/effects/common/Smoke2.png b/DungeonShooting_Godot/resource/sprite/effects/common/Smoke2.png new file mode 100644 index 0000000..af4aa83 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/common/Smoke2.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/effects/common/Smoke2.png.import b/DungeonShooting_Godot/resource/sprite/effects/common/Smoke2.png.import new file mode 100644 index 0000000..f9e9f57 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/common/Smoke2.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://rk73piti0qot" +path="res://.godot/imported/Smoke2.png-bfcd0e73871f709da66c76e16b1ccd07.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/effects/common/Smoke2.png" +dest_files=["res://.godot/imported/Smoke2.png-bfcd0e73871f709da66c76e16b1ccd07.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_circle0001.png b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_circle0001.png new file mode 100644 index 0000000..c20e52e --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_circle0001.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_circle0001.png.import b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_circle0001.png.import new file mode 100644 index 0000000..d32a45b --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_circle0001.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ccdflg560oub6" +path="res://.godot/imported/Explode_circle0001.png-226d2b77cea80f656d4eb2869ee47062.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/effects/explode/Explode_circle0001.png" +dest_files=["res://.godot/imported/Explode_circle0001.png-226d2b77cea80f656d4eb2869ee47062.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_line0001.png b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_line0001.png new file mode 100644 index 0000000..b631b3f --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_line0001.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_line0001.png.import b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_line0001.png.import new file mode 100644 index 0000000..0f10321 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/effects/explode/Explode_line0001.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cquv6nomd3tpf" +path="res://.godot/imported/Explode_line0001.png-449ac783735384f2465771c25c401693.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/effects/explode/Explode_line0001.png" +dest_files=["res://.godot/imported/Explode_line0001.png-449ac783735384f2465771c25c401693.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1 diff --git a/DungeonShooting_Godot/scene/World.tscn b/DungeonShooting_Godot/scene/World.tscn index 76eca4e..6abd441 100644 --- a/DungeonShooting_Godot/scene/World.tscn +++ b/DungeonShooting_Godot/scene/World.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=3 format=3 uid="uid://bqf2vks5ggnsp"] +[gd_scene load_steps=4 format=3 uid="uid://bqf2vks5ggnsp"] [ext_resource type="Script" path="res://src/game/room/World.cs" id="1_kt3mm"] +[ext_resource type="PackedScene" uid="uid://cw3c600m8rv6t" path="res://prefab/bullet/explode/Explode0001.tscn" id="2_pofgj"] [sub_resource type="Environment" id="Environment_g06jj"] background_mode = 3 @@ -63,3 +64,6 @@ [node name="AffiliationAreaRoot" type="Node2D" parent="."] [node name="FogMaskRoot" type="Node2D" parent="."] + +[node name="Explode0001" parent="." instance=ExtResource("2_pofgj")] +position = Vector2(56, 43) diff --git a/DungeonShooting_Godot/src/game/AnimatorNames.cs b/DungeonShooting_Godot/src/game/AnimatorNames.cs index 8ba547d..63ee6b3 100644 --- a/DungeonShooting_Godot/src/game/AnimatorNames.cs +++ b/DungeonShooting_Godot/src/game/AnimatorNames.cs @@ -60,4 +60,8 @@ /// 显示动画 /// public const string Show = "show"; + /// + /// 播放特效 + /// + public const string Play = "play"; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs b/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs new file mode 100644 index 0000000..c0fba47 --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs @@ -0,0 +1,30 @@ + +using Godot; + +/// +/// 爆炸 +/// +public partial class Explode : Area2D, IDestroy +{ + public bool IsDestroyed { get; private set; } + public void Destroy() + { + if (IsDestroyed) + { + return; + } + + IsDestroyed = true; + } + + public override void _Ready() + { + GameCamera.Main.CreateShake(new Vector2(6, 6), 0.7f, true); + GetNode("AnimationPlayer").Play(AnimatorNames.Play); + + this.CallDelayInNode(2, () => + { + Destroy(); + }); + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index bc09905..0527b0c 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -130,6 +130,15 @@ smoke.GlobalRotation = lastSlideCollision.GetNormal().Angle(); smoke.AddToActivityRoot(RoomLayerEnum.YSortLayer); + //击中爆炸,测试用 + if (TriggerRole == null || !TriggerRole.IsAi) + { + var loadAndInstantiate = ResourceManager.LoadAndInstantiate(ResourcePath.prefab_bullet_explode_Explode0001_tscn); + loadAndInstantiate.Position = Position; + loadAndInstantiate.RotationDegrees = Utils.Random.RandomRangeInt(0, 360); + GetParent().AddChild(loadAndInstantiate); + } + Destroy(); return; } @@ -172,6 +181,16 @@ //造成伤害 role.CallDeferred(nameof(Role.Hurt), damage, Rotation); + + //击中爆炸,测试用 + if (TriggerRole == null || !TriggerRole.IsAi) + { + var loadAndInstantiate = ResourceManager.LoadAndInstantiate(ResourcePath.prefab_bullet_explode_Explode0001_tscn); + loadAndInstantiate.Position = Position; + loadAndInstantiate.RotationDegrees = Utils.Random.RandomRangeInt(0, 360); + GetParent().AddChild(loadAndInstantiate); + } + Destroy(); } } diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index e05ad87..300677a 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -56,11 +56,11 @@ // CollisionMask = 0; //GameCamera.Main.Zoom = new Vector2(0.2f, 0.2f); //GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); - this.CallDelay(0.5f, () => - { - var weapon = Create(Ids.Id_weapon0008); - PickUpWeapon(weapon); - }); + // this.CallDelay(0.5f, () => + // { + // var weapon = Create(Ids.Id_weapon0008); + // PickUpWeapon(weapon); + // }); //注册状态机 StateController.Register(new PlayerIdleState()); diff --git a/DungeonShooting_Godot/src/game/camera/GameCamera.cs b/DungeonShooting_Godot/src/game/camera/GameCamera.cs index 4d7918d..ba37e95 100644 --- a/DungeonShooting_Godot/src/game/camera/GameCamera.cs +++ b/DungeonShooting_Godot/src/game/camera/GameCamera.cs @@ -7,6 +7,20 @@ /// public partial class GameCamera : Camera2D { + private class ShakeData + { + public Vector2 Value; + public bool Decline; + public float DataDelta; + + public ShakeData(Vector2 value, bool decline, float dataDelta) + { + Value = value; + Decline = decline; + DataDelta = dataDelta; + } + } + /// /// 当前场景的相机对象 /// @@ -46,7 +60,7 @@ private Vector2 _processDistanceSquared = Vector2.Zero; private Vector2 _processDirection = Vector2.Zero; //抖动数据 - private readonly Dictionary _shakeMap = new Dictionary(); + private readonly Dictionary _shakeMap = new Dictionary(); private Vector2 _camPos; private Vector2 _shakeOffset = Vector2.Zero; @@ -151,7 +165,7 @@ /// /// 创建一个抖动, 并设置抖动时间 /// - public async void CreateShake(Vector2 value, float time) + public async void CreateShake(Vector2 value, float time, bool decline = false) { if (time > 0) { @@ -159,7 +173,15 @@ value.Y = Mathf.Abs(value.Y); var tempIndex = _index++; var sceneTreeTimer = GetTree().CreateTimer(time); - _shakeMap[tempIndex] = value; + if (decline) + { + _shakeMap[tempIndex] = new ShakeData(value, true, value.Length() / time); + } + else + { + _shakeMap[tempIndex] = new ShakeData(value, false, 0); + } + await ToSignal(sceneTreeTimer, Timer.SignalName.Timeout); _shakeMap.Remove(tempIndex); } @@ -178,7 +200,7 @@ { if (EnableShake) { - var distance = _CalculateDistanceSquared(); + var distance = _CalculateDistanceSquared(delta); distance = new Vector2(Mathf.Sqrt(distance.X), Mathf.Sqrt(distance.Y)); _shakeOffset += _processDirection + new Vector2( (float)GD.RandRange(-distance.X, distance.X) - Offset.X, @@ -194,21 +216,28 @@ } //计算相机需要抖动的值 - private Vector2 _CalculateDistanceSquared() + private Vector2 _CalculateDistanceSquared(float delta) { var temp = Vector2.Zero; float length = 0; - + foreach (var keyValuePair in _shakeMap) { - var tempLenght = keyValuePair.Value.LengthSquared(); + var shakeData = keyValuePair.Value; + var tempLenght = shakeData.Value.LengthSquared(); if (tempLenght > length) { length = tempLenght; - temp = keyValuePair.Value; + temp = shakeData.Value; + if (shakeData.Decline) + { + shakeData.Value = shakeData.Value.MoveToward(Vector2.Zero, shakeData.DataDelta * delta); + //Debug.Log("shakeData.Value: " + shakeData.Value + ", _processDistanceSquared: " + _processDistanceSquared); + } } } - + + //return temp; return _processDistanceSquared.LengthSquared() > length ? _processDistanceSquared : temp; } } diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index e83381a..1fff899 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -9,10 +9,11 @@ public const string excel_DungeonShooting_ExcelTool_deps_json = "res://excel/DungeonShooting_ExcelTool.deps.json"; public const string excel_DungeonShooting_ExcelTool_runtimeconfig_json = "res://excel/DungeonShooting_ExcelTool.runtimeconfig.json"; public const string prefab_Cursor_tscn = "res://prefab/Cursor.tscn"; - public const string prefab_bullet_Bullet0001_tscn = "res://prefab/bullet/Bullet0001.tscn"; - public const string prefab_bullet_Bullet0002_tscn = "res://prefab/bullet/Bullet0002.tscn"; - public const string prefab_bullet_Bullet0003_tscn = "res://prefab/bullet/Bullet0003.tscn"; + public const string prefab_bullet_explode_Explode0001_tscn = "res://prefab/bullet/explode/Explode0001.tscn"; public const string prefab_bullet_laser_Laser0001_tscn = "res://prefab/bullet/laser/Laser0001.tscn"; + public const string prefab_bullet_normal_Bullet0001_tscn = "res://prefab/bullet/normal/Bullet0001.tscn"; + public const string prefab_bullet_normal_Bullet0002_tscn = "res://prefab/bullet/normal/Bullet0002.tscn"; + public const string prefab_bullet_normal_Bullet0003_tscn = "res://prefab/bullet/normal/Bullet0003.tscn"; public const string prefab_effect_Blood_tscn = "res://prefab/effect/Blood.tscn"; public const string prefab_effect_common_Effect1_tscn = "res://prefab/effect/common/Effect1.tscn"; public const string prefab_effect_enemy_Effect0001_tscn = "res://prefab/effect/enemy/Effect0001.tscn"; @@ -130,8 +131,10 @@ public const string resource_sound_sfx_reloading_Reloading_begin0008_ogg = "res://resource/sound/sfx/reloading/Reloading_begin0008.ogg"; public const string resource_sound_sfx_reloading_Reloading_begin0009_ogg = "res://resource/sound/sfx/reloading/Reloading_begin0009.ogg"; public const string resource_sound_sfx_reloading_Reloading_begin0010_ogg = "res://resource/sound/sfx/reloading/Reloading_begin0010.ogg"; + public const string resource_sound_sfx_reloading_Reloading_begin0011_ogg = "res://resource/sound/sfx/reloading/Reloading_begin0011.ogg"; public const string resource_sound_sfx_reloading_Reloading_finish0001_ogg = "res://resource/sound/sfx/reloading/Reloading_finish0001.ogg"; public const string resource_sound_sfx_reloading_Reloading_finish0002_ogg = "res://resource/sound/sfx/reloading/Reloading_finish0002.ogg"; + public const string resource_sound_sfx_reloading_Reloading_finish0003_ogg = "res://resource/sound/sfx/reloading/Reloading_finish0003.ogg"; public const string resource_sound_sfx_shooting_Shooting0001_ogg = "res://resource/sound/sfx/shooting/Shooting0001.ogg"; public const string resource_sound_sfx_shooting_Shooting0002_ogg = "res://resource/sound/sfx/shooting/Shooting0002.ogg"; public const string resource_sound_sfx_shooting_Shooting0003_ogg = "res://resource/sound/sfx/shooting/Shooting0003.ogg"; @@ -140,17 +143,22 @@ public const string resource_sound_sfx_shooting_Shooting0006_ogg = "res://resource/sound/sfx/shooting/Shooting0006.ogg"; public const string resource_sound_sfx_shooting_Shooting0007_ogg = "res://resource/sound/sfx/shooting/Shooting0007.ogg"; public const string resource_sound_sfx_shooting_Shooting0008_ogg = "res://resource/sound/sfx/shooting/Shooting0008.ogg"; - public const string resource_sprite_bullet_arrow_png = "res://resource/sprite/bullet/arrow.png"; - public const string resource_sprite_bullet_bullet0001_png = "res://resource/sprite/bullet/bullet0001.png"; - public const string resource_sprite_bullet_bullet0002_png = "res://resource/sprite/bullet/bullet0002.png"; - public const string resource_sprite_bullet_bullet0003_png = "res://resource/sprite/bullet/bullet0003.png"; - public const string resource_sprite_bullet_bullet2_png = "res://resource/sprite/bullet/bullet2.png"; - public const string resource_sprite_bullet_Laser0001_png = "res://resource/sprite/bullet/Laser0001.png"; + public const string resource_sound_sfx_shooting_Shooting0009_ogg = "res://resource/sound/sfx/shooting/Shooting0009.ogg"; + public const string resource_sound_sfx_shooting_Shooting0010_ogg = "res://resource/sound/sfx/shooting/Shooting0010.ogg"; + public const string resource_sprite_bullet_laser_Laser0001_png = "res://resource/sprite/bullet/laser/Laser0001.png"; + public const string resource_sprite_bullet_normal_arrow_png = "res://resource/sprite/bullet/normal/arrow.png"; + public const string resource_sprite_bullet_normal_bullet0001_png = "res://resource/sprite/bullet/normal/bullet0001.png"; + public const string resource_sprite_bullet_normal_bullet0002_png = "res://resource/sprite/bullet/normal/bullet0002.png"; + public const string resource_sprite_bullet_normal_bullet0003_png = "res://resource/sprite/bullet/normal/bullet0003.png"; + public const string resource_sprite_bullet_normal_bullet2_png = "res://resource/sprite/bullet/normal/bullet2.png"; public const string resource_sprite_effects_Circle_png = "res://resource/sprite/effects/Circle.png"; + public const string resource_sprite_effects_Circle2_png = "res://resource/sprite/effects/Circle2.png"; public const string resource_sprite_effects_debug_arrows_png = "res://resource/sprite/effects/debug_arrows.png"; public const string resource_sprite_effects_Explosion_png = "res://resource/sprite/effects/Explosion.png"; public const string resource_sprite_effects_common_Effect1_png = "res://resource/sprite/effects/common/Effect1.png"; public const string resource_sprite_effects_common_Smoke_png = "res://resource/sprite/effects/common/Smoke.png"; + public const string resource_sprite_effects_explode_Explode_circle0001_png = "res://resource/sprite/effects/explode/Explode_circle0001.png"; + public const string resource_sprite_effects_explode_Explode_line0001_png = "res://resource/sprite/effects/explode/Explode_line0001.png"; public const string resource_sprite_effects_weapon_Collision1_png = "res://resource/sprite/effects/weapon/Collision1.png"; public const string resource_sprite_effects_weapon_KnifeHit1_png = "res://resource/sprite/effects/weapon/KnifeHit1.png"; public const string resource_sprite_effects_weapon_MeleeAttack1_png = "res://resource/sprite/effects/weapon/MeleeAttack1.png"; @@ -284,6 +292,7 @@ public const string resource_sprite_weapon_weapon0006_Weapon0006_png = "res://resource/sprite/weapon/weapon0006/Weapon0006.png"; public const string resource_sprite_weapon_weapon0007_Weapon0007_png = "res://resource/sprite/weapon/weapon0007/Weapon0007.png"; public const string resource_sprite_weapon_weapon0008_Weapon0008_png = "res://resource/sprite/weapon/weapon0008/Weapon0008.png"; + public const string resource_sprite_weapon_weapon0008_Weapon0008_reloading_png = "res://resource/sprite/weapon/weapon0008/Weapon0008_reloading.png"; public const string resource_spriteFrames_bullet_Bullet0001_tres = "res://resource/spriteFrames/bullet/Bullet0001.tres"; public const string resource_spriteFrames_bullet_Bullet0002_tres = "res://resource/spriteFrames/bullet/Bullet0002.tres"; public const string resource_spriteFrames_bullet_Bullet0003_tres = "res://resource/spriteFrames/bullet/Bullet0003.tres";