diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0009.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0009.tscn index a1c9e3e..2831163 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0009.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0009.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=8 format=3 uid="uid://c4puxmnan51ds"] -[ext_resource type="Script" path="res://src/game/activity/bullet/normal/Bullet.cs" id="1_dmdyg"] +[ext_resource type="Script" path="res://src/game/activity/bullet/normal/Arrow.cs" id="1_eots7"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_tscmb"] [ext_resource type="SpriteFrames" uid="uid://cyg3uvbakan08" path="res://resource/spriteFrames/bullet/Bullet0009.tres" id="3_l58ff"] @@ -29,15 +29,16 @@ shader_parameter/grey = 0.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_5x14b"] -size = Vector2(26, 3) +size = Vector2(21, 3) [sub_resource type="RectangleShape2D" id="RectangleShape2D_72d75"] -size = Vector2(26, 3) +size = Vector2(21, 3) -[node name="Bullet0009" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] +[node name="Bullet0009" type="CharacterBody2D" node_paths=PackedStringArray("HalfSprite", "CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 collision_mask = 0 -script = ExtResource("1_dmdyg") +script = ExtResource("1_eots7") +HalfSprite = NodePath("AnimatedSprite/HalfSprite") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") Particles2D = [] @@ -59,7 +60,15 @@ monitorable = false [node name="CollisionShape2D" type="CollisionShape2D" parent="AnimatedSprite/CollisionArea"] +position = Vector2(-2.5, 0) shape = SubResource("RectangleShape2D_5x14b") +[node name="HalfSprite" type="AnimatedSprite2D" parent="AnimatedSprite"] +visible = false +z_index = -1 +sprite_frames = ExtResource("3_l58ff") +animation = &"half_start" + [node name="Collision" type="CollisionShape2D" parent="."] +position = Vector2(-2.5, 0) shape = SubResource("RectangleShape2D_72d75") diff --git a/DungeonShooting_Godot/resource/sprite/bullet/normal/bullet0009.png b/DungeonShooting_Godot/resource/sprite/bullet/normal/bullet0009.png index a9bf9a4..fe240cd 100644 --- a/DungeonShooting_Godot/resource/sprite/bullet/normal/bullet0009.png +++ b/DungeonShooting_Godot/resource/sprite/bullet/normal/bullet0009.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/weapon/weapon0030/weapon0030.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0030/weapon0030.png.import new file mode 100644 index 0000000..ccaa46b --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0030/weapon0030.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://wcuv5oy17ede" +path="res://.godot/imported/weapon0030.png-d068b0866dcc9b9002082be1954c20e8.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0030/weapon0030.png" +dest_files=["res://.godot/imported/weapon0030.png-d068b0866dcc9b9002082be1954c20e8.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/weapon/weapon0032/weapon0032.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0032/weapon0032.png.import new file mode 100644 index 0000000..04b1f8c --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0032/weapon0032.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://sqq2a5o3n8b" +path="res://.godot/imported/weapon0032.png-81b32a2cc96540e73ceef21bc1d963db.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0032/weapon0032.png" +dest_files=["res://.godot/imported/weapon0032.png-81b32a2cc96540e73ceef21bc1d963db.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/weapon/weapon0041/weapon0041.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0041/weapon0041.png.import new file mode 100644 index 0000000..79f93da --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0041/weapon0041.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dgpt5sox41had" +path="res://.godot/imported/weapon0041.png-bc6e68522a6fc0223f80d06af365d475.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0041/weapon0041.png" +dest_files=["res://.godot/imported/weapon0041.png-bc6e68522a6fc0223f80d06af365d475.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/weapon/weapon0042/weapon0042.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0042/weapon0042.png.import new file mode 100644 index 0000000..7e67d03 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0042/weapon0042.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bgd5d4wsyphco" +path="res://.godot/imported/weapon0042.png-0cc626b5ea8c951effcccb723b71168a.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0042/weapon0042.png" +dest_files=["res://.godot/imported/weapon0042.png-0cc626b5ea8c951effcccb723b71168a.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/weapon/weapon0043/weapon0043.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0043/weapon0043.png.import new file mode 100644 index 0000000..da1ad83 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0043/weapon0043.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bq5tcaqju0icj" +path="res://.godot/imported/weapon0043.png-245ddd1635cbc7abe5e9f90f5d5a459d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0043/weapon0043.png" +dest_files=["res://.godot/imported/weapon0043.png-245ddd1635cbc7abe5e9f90f5d5a459d.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/weapon/weapon0044/weapon0044.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0044/weapon0044.png.import new file mode 100644 index 0000000..0f40edf --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0044/weapon0044.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://ckv2qfcbuyw27" +path="res://.godot/imported/weapon0044.png-0a168ddd1a230f76db91625c3fe9e7d5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0044/weapon0044.png" +dest_files=["res://.godot/imported/weapon0044.png-0a168ddd1a230f76db91625c3fe9e7d5.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/weapon/weapon0045/weapon0045.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0045/weapon0045.png.import new file mode 100644 index 0000000..97d849c --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0045/weapon0045.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://cogtgq1aoa0xw" +path="res://.godot/imported/weapon0045.png-86861d1626d9c0b9f4d2632e7a763f63.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0045/weapon0045.png" +dest_files=["res://.godot/imported/weapon0045.png-86861d1626d9c0b9f4d2632e7a763f63.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/weapon/weapon0045/\345\255\220\345\274\271.png.import" "b/DungeonShooting_Godot/resource/sprite/weapon/weapon0045/\345\255\220\345\274\271.png.import" new file mode 100644 index 0000000..2fd0958 --- /dev/null +++ "b/DungeonShooting_Godot/resource/sprite/weapon/weapon0045/\345\255\220\345\274\271.png.import" @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://csyqaglrxpus0" +path="res://.godot/imported/子弹.png-50072d5fb54502db90827299ba900a43.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0045/子弹.png" +dest_files=["res://.godot/imported/子弹.png-50072d5fb54502db90827299ba900a43.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/weapon/weapon0046/weapon0046.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon0046/weapon0046.png.import new file mode 100644 index 0000000..0ca72d6 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon0046/weapon0046.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dhyb3122qx50y" +path="res://.godot/imported/weapon0046.png-978eee461209b567302df2ed7ad70035.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon0046/weapon0046.png" +dest_files=["res://.godot/imported/weapon0046.png-978eee461209b567302df2ed7ad70035.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/weapon/weapon29/weapon0029.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon29/weapon0029.png.import new file mode 100644 index 0000000..e681ce2 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon29/weapon0029.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dph00sfp1wksx" +path="res://.godot/imported/weapon0029.png-37dc40dbf3de56fbcf49fc241c201f2d.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon29/weapon0029.png" +dest_files=["res://.godot/imported/weapon0029.png-37dc40dbf3de56fbcf49fc241c201f2d.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/weapon/weapon31/weapon0031.png.import b/DungeonShooting_Godot/resource/sprite/weapon/weapon31/weapon0031.png.import new file mode 100644 index 0000000..49a2bc5 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/weapon/weapon31/weapon0031.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://fbe0jp7o8ccq" +path="res://.godot/imported/weapon0031.png-778cb9a417b671f93729b391300c4db6.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/weapon/weapon31/weapon0031.png" +dest_files=["res://.godot/imported/weapon0031.png-778cb9a417b671f93729b391300c4db6.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/spriteFrames/bullet/Bullet0009.tres b/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0009.tres index 40aaa93..2941488 100644 --- a/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0009.tres +++ b/DungeonShooting_Godot/resource/spriteFrames/bullet/Bullet0009.tres @@ -1,14 +1,42 @@ -[gd_resource type="SpriteFrames" load_steps=2 format=3 uid="uid://cyg3uvbakan08"] +[gd_resource type="SpriteFrames" load_steps=5 format=3 uid="uid://cyg3uvbakan08"] [ext_resource type="Texture2D" uid="uid://c5b2dmsxgv1p8" path="res://resource/sprite/bullet/normal/bullet0009.png" id="1_v33wk"] +[sub_resource type="AtlasTexture" id="AtlasTexture_n6dlo"] +atlas = ExtResource("1_v33wk") +region = Rect2(0, 0, 28, 7) + +[sub_resource type="AtlasTexture" id="AtlasTexture_b3wh3"] +atlas = ExtResource("1_v33wk") +region = Rect2(28, 0, 28, 7) + +[sub_resource type="AtlasTexture" id="AtlasTexture_bdaam"] +atlas = ExtResource("1_v33wk") +region = Rect2(56, 0, 28, 7) + [resource] animations = [{ "frames": [{ "duration": 1.0, -"texture": ExtResource("1_v33wk") +"texture": SubResource("AtlasTexture_n6dlo") }], "loop": true, "name": &"default", "speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_b3wh3") +}], +"loop": false, +"name": &"half_end", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_bdaam") +}], +"loop": false, +"name": &"half_start", +"speed": 5.0 }] diff --git a/DungeonShooting_Godot/scene/World.tscn b/DungeonShooting_Godot/scene/World.tscn index 2bdf432..0a055fc 100644 --- a/DungeonShooting_Godot/scene/World.tscn +++ b/DungeonShooting_Godot/scene/World.tscn @@ -30,6 +30,7 @@ z_index = -1 [node name="YSortLayer" type="Node2D" parent="TileRoot"] +z_index = 2 y_sort_enabled = true [node name="AffiliationAreaRoot" type="Node2D" parent="TileRoot"] diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index 6e2a533..c4df8c2 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -75,7 +75,7 @@ /// 阴影偏移 /// [Export] - public Vector2 ShadowOffset { get; protected set; } = new Vector2(0, 2); + public Vector2 ShadowOffset { get; set; } = new Vector2(0, 2); /// /// 移动控制器 @@ -322,6 +322,8 @@ //击退外力 private ExternalForce _repelForce; + private HashSet _destroySet; + // -------------------------------------------------------------------------------- //实例索引 @@ -1416,6 +1418,16 @@ } _components.Clear(); + + if (_destroySet != null) + { + foreach (var destroy in _destroySet) + { + destroy.Destroy(); + } + + _destroySet = null; + } } /// @@ -1855,4 +1867,30 @@ BrushPrevPosition = pos; } } + + /// + /// 绑定可销毁对象, 绑定的物体会在当前物体销毁时触发销毁 + /// + public void BindDestroyObject(IDestroy destroy) + { + if (_destroySet == null) + { + _destroySet = new HashSet(); + } + + _destroySet.Add(destroy); + } + + /// + /// 移除绑定可销毁对象 + /// + public void RemoveDestroyObject(IDestroy destroy) + { + if (_destroySet == null) + { + return; + } + + _destroySet.Remove(destroy); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs index ef0f435..0f69a21 100644 --- a/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs +++ b/DungeonShooting_Godot/src/framework/activity/components/MoveController.cs @@ -382,29 +382,32 @@ var no = collision.GetNormal().Rotated(Mathf.Pi * 0.5f); newVelocity = finallyEf.Reflect(no); var rotation = newVelocity.Angle(); - - if (Master.ActivityMaterial.RotationType == 1) //跟着反弹角度 - { - Rotation = rotation; - } - else if (Master.ActivityMaterial.RotationType == 2) //跟着反弹角度, 带垂直角度 - { - Rotation = rotation; - AnimatedSprite.Rotation = new Vector2(newVelocity.X, newVelocity.Y - Master.VerticalSpeed).Angle() - rotation; - } - var length = _forceList.Count; - if (length != 0) - { - var v = newVelocity / (length / Master.ActivityMaterial.BounceStrength); - for (var i = 0; i < _forceList.Count; i++) - { - _forceList[i].Velocity = v; - } - } - //调用反弹函数 Master.OnBounce(rotation); + + if (Enable) + { + if (Master.ActivityMaterial.RotationType == 1) //跟着反弹角度 + { + Rotation = rotation; + } + else if (Master.ActivityMaterial.RotationType == 2) //跟着反弹角度, 带垂直角度 + { + Rotation = rotation; + AnimatedSprite.Rotation = new Vector2(newVelocity.X, newVelocity.Y - Master.VerticalSpeed).Angle() - rotation; + } + + var length = _forceList.Count; + if (length != 0) + { + var v = newVelocity / (length / Master.ActivityMaterial.BounceStrength); + for (var i = 0; i < _forceList.Count; i++) + { + _forceList[i].Velocity = v; + } + } + } } else //没有撞到物体 { diff --git a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs index cbde60e..c6b0379 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs @@ -138,7 +138,7 @@ _tween.TweenCallback(Callable.From(() => { _tween = null; - DoReclaim(); + LogicalFinish(); })); _tween.Play(); @@ -245,7 +245,7 @@ ProxyCoroutineHandler.ProxyStopAllCoroutine(ref _coroutineList); } - public void DoReclaim() + public void LogicalFinish() { ObjectPool.Reclaim(this); } diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Arrow.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Arrow.cs new file mode 100644 index 0000000..49d2a2c --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Arrow.cs @@ -0,0 +1,44 @@ + +using Godot; + +[Tool] +public partial class Arrow : Bullet +{ + [Export, ExportFillNode] + public AnimatedSprite2D HalfSprite { get; set; } + + public override void OnPlayDisappearEffect() + { + } + + public override void OnPlayCollisionEffect(KinematicCollision2D collision) + { + } + + public override void OnCollisionTarget(IHurt hurt) + { + base.OnCollisionTarget(hurt); + var activityObject = hurt.GetActivityObject(); + if (activityObject != null) + { + CallDeferred(nameof(OnBindTarget), activityObject); + } + } + + public override void LogicalFinish() + { + MoveController.Enable = false; + CollisionArea.Monitoring = false; + CollisionArea.Monitorable = false; + Collision.Disabled = true; + } + + private void OnBindTarget(ActivityObject activityObject) + { + Altitude = -activityObject.ToLocal(GlobalPosition).Y; + Reparent(activityObject); + activityObject.BindDestroyObject(this); + AnimatedSprite.Play(AnimatorNames.HalfEnd); + HalfSprite.Visible = true; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs index 36702cc..085c4c6 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs @@ -10,19 +10,19 @@ public override void OnLimeOver() { PlayBoom(); - DoReclaim(); + LogicalFinish(); } public override void OnMaxDistance() { PlayBoom(); - DoReclaim(); + LogicalFinish(); } public override void OnCollisionTarget(IHurt o) { PlayBoom(); - DoReclaim(); + LogicalFinish(); } public override void OnMoveCollision(KinematicCollision2D lastSlideCollision) @@ -31,7 +31,7 @@ if (CurrentBounce > BulletData.BounceCount) //反弹次数超过限制 { PlayBoom(); - DoReclaim(); + LogicalFinish(); } else { diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index b0183c2..8744f60 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -174,7 +174,7 @@ { //创建粒子特效 OnPlayCollisionEffect(collision); - DoReclaim(); + LogicalFinish(); } } @@ -200,7 +200,7 @@ CurrentPenetration++; if (CurrentPenetration > BulletData.Penetration) { - DoReclaim(); + CallDeferred(nameof(LogicalFinish)); } } @@ -210,7 +210,7 @@ public virtual void OnMaxDistance() { OnPlayDisappearEffect(); - DoReclaim(); + LogicalFinish(); } /// @@ -219,14 +219,14 @@ public virtual void OnLimeOver() { OnPlayDisappearEffect(); - DoReclaim(); + LogicalFinish(); } protected override void OnFallToGround() { //落地销毁 OnPlayDisappearEffect(); - DoReclaim(); + LogicalFinish(); } /// @@ -335,7 +335,7 @@ } } - public virtual void DoReclaim() + public virtual void LogicalFinish() { ObjectPool.Reclaim(this); } diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/IBullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/IBullet.cs index 9611387..56d4b88 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/IBullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/IBullet.cs @@ -26,7 +26,7 @@ /// void InitData(BulletData data, uint attackLayer); /// - /// 执行子弹回收操作 + /// 子弹运行逻辑执行完成 /// - void DoReclaim(); + void LogicalFinish(); } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/weapon/bow/Bow.cs b/DungeonShooting_Godot/src/game/activity/weapon/bow/Bow.cs index bff0b22..9898284 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/bow/Bow.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/bow/Bow.cs @@ -13,20 +13,24 @@ public Marker2D ArrowPoint { get; set; } //正在使用的弓箭 - private Bullet _activeArrow; + private Arrow _activeArrow; - private void InitActiveArrow() + public override void OnInit() { - if (_activeArrow == null) - { - _activeArrow = (Bullet)FireManager.ShootBullet(this, 0, Attribute.Bullet); - _activeArrow.Pickup(); - _activeArrow.MoveController.Enable = false; - _activeArrow.CollisionArea.Monitoring = false; - _activeArrow.Collision.Disabled = true; - _activeArrow.Position = Vector2.Zero; - ArrowPoint.AddChild(_activeArrow); - } + base.OnInit(); + _activeArrow = (Arrow)FireManager.ShootBullet(this, 0, Attribute.Bullet); + _activeArrow.Pickup(); + _activeArrow.MoveController.Enable = false; + _activeArrow.CollisionArea.Monitoring = false; + _activeArrow.Collision.Disabled = true; + _activeArrow.Position = Vector2.Zero; + ArrowPoint.AddChild(_activeArrow); + } + + protected override void Process(float delta) + { + base.Process(delta); + _activeArrow.ShadowOffset = ShadowOffset + new Vector2(0, Altitude); } protected override void OnBeginCharge() @@ -35,18 +39,16 @@ AnimationPlayer.Play(AnimatorNames.Pull); } - protected override void OnChargeProcess(float delta, float charge) + protected override void OnChargeFinish() { - if (Master.IsPlayer() && IsChargeFinish()) - { - //蓄力完成抖动屏幕 - GameCamera.Main.Shake(new Vector2(Utils.Random.RandomRangeFloat(-1, 1), Utils.Random.RandomRangeFloat(-1, 1))); - } + //蓄力完成 + SetShake(0.7f); } protected override void OnEndCharge() { //结束蓄力 + SetShake(0); AnimationPlayer.Play(AnimatorNames.Reset); } @@ -64,22 +66,6 @@ FireManager.ShootBullet(this, fireRotation, Attribute.Bullet); } - protected override void OnPickUp(Role master) - { - base.OnPickUp(master); - InitActiveArrow(); - } - - protected override void OnRemove(Role master) - { - base.OnRemove(master); - if (_activeArrow != null) - { - _activeArrow.DoReclaim(); - _activeArrow = null; - } - } - protected override void OnDestroy() { base.OnDestroy(); diff --git a/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs b/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs index 32a174b..88ae1af 100644 --- a/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs +++ b/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs @@ -100,4 +100,8 @@ /// 拉弓 /// public static readonly StringName Pull = "pull"; + + + public static readonly StringName HalfStart = "half_start"; + public static readonly StringName HalfEnd = "half_end"; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/MapLayerManager.cs b/DungeonShooting_Godot/src/game/manager/MapLayerManager.cs index 3ac25c0..2def661 100644 --- a/DungeonShooting_Godot/src/game/manager/MapLayerManager.cs +++ b/DungeonShooting_Godot/src/game/manager/MapLayerManager.cs @@ -32,19 +32,19 @@ tileMap.SetLayerName(MapLayer.CustomFloorLayer3, nameof(MapLayer.CustomFloorLayer3)); tileMap.AddLayer(MapLayer.AutoMiddleLayer); - tileMap.SetLayerZIndex(MapLayer.AutoMiddleLayer, 0); + tileMap.SetLayerZIndex(MapLayer.AutoMiddleLayer, 2); tileMap.SetLayerNavigationEnabled(MapLayer.AutoMiddleLayer, false); tileMap.SetLayerYSortEnabled(MapLayer.AutoMiddleLayer, true); tileMap.SetLayerName(MapLayer.AutoMiddleLayer, nameof(MapLayer.AutoMiddleLayer)); tileMap.AddLayer(MapLayer.CustomMiddleLayer1); - tileMap.SetLayerZIndex(MapLayer.CustomMiddleLayer1, 0); + tileMap.SetLayerZIndex(MapLayer.CustomMiddleLayer1, 2); tileMap.SetLayerNavigationEnabled(MapLayer.CustomMiddleLayer1, false); tileMap.SetLayerYSortEnabled(MapLayer.CustomMiddleLayer1, true); tileMap.SetLayerName(MapLayer.CustomMiddleLayer1, nameof(MapLayer.CustomMiddleLayer1)); tileMap.AddLayer(MapLayer.CustomMiddleLayer2); - tileMap.SetLayerZIndex(MapLayer.CustomMiddleLayer2, 0); + tileMap.SetLayerZIndex(MapLayer.CustomMiddleLayer2, 2); tileMap.SetLayerNavigationEnabled(MapLayer.CustomMiddleLayer2, false); tileMap.SetLayerYSortEnabled(MapLayer.CustomMiddleLayer2, true); tileMap.SetLayerName(MapLayer.CustomMiddleLayer2, nameof(MapLayer.CustomMiddleLayer2));