diff --git a/DungeonShooting_Godot/prefab/role/Role0001.tscn b/DungeonShooting_Godot/prefab/role/Role0001.tscn index 65015c6..a541d06 100644 --- a/DungeonShooting_Godot/prefab/role/Role0001.tscn +++ b/DungeonShooting_Godot/prefab/role/Role0001.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=8 format=3 uid="uid://cxhrcytrx0kcf"] +[gd_scene load_steps=9 format=3 uid="uid://cxhrcytrx0kcf"] [ext_resource type="PackedScene" uid="uid://cyrcv2jdgr8cf" path="res://prefab/role/template/RoleTemplate.tscn" id="1_10c2n"] [ext_resource type="Script" path="res://src/game/activity/role/player/Player.cs" id="2_6xwnt"] @@ -15,6 +15,7 @@ shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 [sub_resource type="ShaderMaterial" id="ShaderMaterial_8hgu2"] resource_local_to_scene = true @@ -26,10 +27,13 @@ shader_parameter/outline_color = Color(0, 0, 0, 1) shader_parameter/outline_rainbow = false shader_parameter/outline_use_blend = true +shader_parameter/grey = 0.0 [sub_resource type="RectangleShape2D" id="RectangleShape2D_ve262"] size = Vector2(12, 18) +[sub_resource type="AnimationLibrary" id="AnimationLibrary_ka171"] + [node name="Role0001" node_paths=PackedStringArray("HurtArea", "HurtCollision", "InteractiveArea", "InteractiveCollision", "TipRoot", "TipSprite", "AnimationPlayer", "MountPoint", "BackMountPoint", "MeleeAttackArea", "MeleeAttackCollision", "ShadowSprite", "AnimatedSprite", "Collision") instance=ExtResource("1_10c2n")] collision_layer = 8 script = ExtResource("2_6xwnt") @@ -54,7 +58,11 @@ [node name="AnimatedSprite" parent="." index="2"] material = SubResource("ShaderMaterial_8hgu2") sprite_frames = ExtResource("4_galcc") -frame_progress = 0.658799 [node name="HurtCollision" parent="HurtArea" index="0"] shape = SubResource("RectangleShape2D_ve262") + +[node name="AnimationPlayer" parent="." index="8"] +libraries = { +"": SubResource("AnimationLibrary_ka171") +} diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0002.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0002.png deleted file mode 100644 index df4b964..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0002.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0002.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0002.png.import deleted file mode 100644 index 10663d3..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0002.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://d3thq2unooyl5" -path="res://.godot/imported/Sprite-0002.png-213031b39254f00c0c725e4252a9d486.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0002.png" -dest_files=["res://.godot/imported/Sprite-0002.png-213031b39254f00c0c725e4252a9d486.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/role/role0001/roll/Sprite-0003.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0003.png deleted file mode 100644 index 12b6942..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0003.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0003.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0003.png.import deleted file mode 100644 index c89343a..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0003.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://ccqgkq5qv33il" -path="res://.godot/imported/Sprite-0003.png-e6803dc1c9e8f17b579f63f5e8cb8e23.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0003.png" -dest_files=["res://.godot/imported/Sprite-0003.png-e6803dc1c9e8f17b579f63f5e8cb8e23.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/role/role0001/roll/Sprite-0004.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0004.png deleted file mode 100644 index 6bc1574..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0004.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0004.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0004.png.import deleted file mode 100644 index 5e6e424..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0004.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://sknj4eflhbvc" -path="res://.godot/imported/Sprite-0004.png-8d2b0ef4221d99fc8d9133c4f11809ff.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0004.png" -dest_files=["res://.godot/imported/Sprite-0004.png-8d2b0ef4221d99fc8d9133c4f11809ff.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/role/role0001/roll/Sprite-0005.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0005.png deleted file mode 100644 index a1128d2..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0005.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0005.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0005.png.import deleted file mode 100644 index 7d04efe..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0005.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://c8ijooj30lvpw" -path="res://.godot/imported/Sprite-0005.png-9c344cd4269051bef354e37f494af4b3.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0005.png" -dest_files=["res://.godot/imported/Sprite-0005.png-9c344cd4269051bef354e37f494af4b3.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/role/role0001/roll/Sprite-0006.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0006.png deleted file mode 100644 index 0bb3b72..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0006.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0006.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0006.png.import deleted file mode 100644 index 2912fea..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0006.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://blqx76rvx6c34" -path="res://.godot/imported/Sprite-0006.png-1cb8bb9f32bbeef7eb914435df8b325e.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0006.png" -dest_files=["res://.godot/imported/Sprite-0006.png-1cb8bb9f32bbeef7eb914435df8b325e.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/role/role0001/roll/Sprite-0007.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0007.png deleted file mode 100644 index a7f4176..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0007.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0007.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0007.png.import deleted file mode 100644 index 3dc376b..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0007.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://48qebkjqggub" -path="res://.godot/imported/Sprite-0007.png-e2c0f4efb93a9c9e29fa2a8da4c24baf.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0007.png" -dest_files=["res://.godot/imported/Sprite-0007.png-e2c0f4efb93a9c9e29fa2a8da4c24baf.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/role/role0001/roll/Sprite-0008.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png index b15c6ef..462e9a3 100644 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png +++ b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png.import index 8da943b..db9467b 100644 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png.import +++ b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0008.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://dvrxriqd6dk1d" +uid="uid://b2hdk7nca5rda" path="res://.godot/imported/Sprite-0008.png-bf19680d71b1e849c210397f3a25fca2.ctex" metadata={ "vram_texture": false diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png index 12b6942..7508707 100644 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png +++ b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png.import index c606373..98a613f 100644 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png.import +++ b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0009.png.import @@ -2,7 +2,7 @@ importer="texture" type="CompressedTexture2D" -uid="uid://ceqi6d4vhbpt" +uid="uid://bmoh16y1r2h1w" path="res://.godot/imported/Sprite-0009.png-d266a086bd0825b44bd46a64ac6248f3.ctex" metadata={ "vram_texture": false diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0010.png b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0010.png deleted file mode 100644 index df4b964..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0010.png +++ /dev/null Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0010.png.import b/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0010.png.import deleted file mode 100644 index b6b498e..0000000 --- a/DungeonShooting_Godot/resource/sprite/role/role0001/roll/Sprite-0010.png.import +++ /dev/null @@ -1,34 +0,0 @@ -[remap] - -importer="texture" -type="CompressedTexture2D" -uid="uid://cp8d5kqfwcyjf" -path="res://.godot/imported/Sprite-0010.png-c80699f0403ae66453b70f57a31ecc59.ctex" -metadata={ -"vram_texture": false -} - -[deps] - -source_file="res://resource/sprite/role/role0001/roll/Sprite-0010.png" -dest_files=["res://.godot/imported/Sprite-0010.png-c80699f0403ae66453b70f57a31ecc59.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/role/Role0001.tres b/DungeonShooting_Godot/resource/spriteFrames/role/Role0001.tres index 8205354..481275b 100644 --- a/DungeonShooting_Godot/resource/spriteFrames/role/Role0001.tres +++ b/DungeonShooting_Godot/resource/spriteFrames/role/Role0001.tres @@ -1,4 +1,4 @@ -[gd_resource type="SpriteFrames" load_steps=21 format=3 uid="uid://n11thtali6es"] +[gd_resource type="SpriteFrames" load_steps=17 format=3 uid="uid://n11thtali6es"] [ext_resource type="Texture2D" uid="uid://ekas4lqprrml" path="res://resource/sprite/role/role0001/idle/Sprite-0002.png" id="1_le6bk"] [ext_resource type="Texture2D" uid="uid://b81k08ofpf2oo" path="res://resource/sprite/role/role0001/idle/Sprite-0003.png" id="2_whsc2"] @@ -14,12 +14,8 @@ [ext_resource type="Texture2D" uid="uid://d32g0f5vk68sj" path="res://resource/sprite/role/role0001/run/Sprite-0004.png" id="12_cbabh"] [ext_resource type="Texture2D" uid="uid://cw83liyy6gnln" path="res://resource/sprite/role/role0001/run/Sprite-0003.png" id="13_u0cmp"] [ext_resource type="Texture2D" uid="uid://b1gh481w2xvsl" path="res://resource/sprite/role/role0001/run/Sprite-0002.png" id="14_nlfq5"] -[ext_resource type="Texture2D" uid="uid://sknj4eflhbvc" path="res://resource/sprite/role/role0001/roll/Sprite-0004.png" id="17_xnddk"] -[ext_resource type="Texture2D" uid="uid://c8ijooj30lvpw" path="res://resource/sprite/role/role0001/roll/Sprite-0005.png" id="18_1doii"] -[ext_resource type="Texture2D" uid="uid://blqx76rvx6c34" path="res://resource/sprite/role/role0001/roll/Sprite-0006.png" id="19_ilt25"] -[ext_resource type="Texture2D" uid="uid://48qebkjqggub" path="res://resource/sprite/role/role0001/roll/Sprite-0007.png" id="20_tp03g"] -[ext_resource type="Texture2D" uid="uid://dvrxriqd6dk1d" path="res://resource/sprite/role/role0001/roll/Sprite-0008.png" id="21_oocqa"] -[ext_resource type="Texture2D" uid="uid://ceqi6d4vhbpt" path="res://resource/sprite/role/role0001/roll/Sprite-0009.png" id="22_yc5ek"] +[ext_resource type="Texture2D" uid="uid://b2hdk7nca5rda" path="res://resource/sprite/role/role0001/roll/Sprite-0008.png" id="21_oocqa"] +[ext_resource type="Texture2D" uid="uid://bmoh16y1r2h1w" path="res://resource/sprite/role/role0001/roll/Sprite-0009.png" id="22_yc5ek"] [resource] animations = [{ @@ -85,18 +81,6 @@ }, { "frames": [{ "duration": 1.0, -"texture": ExtResource("17_xnddk") -}, { -"duration": 1.0, -"texture": ExtResource("18_1doii") -}, { -"duration": 1.0, -"texture": ExtResource("19_ilt25") -}, { -"duration": 1.0, -"texture": ExtResource("20_tp03g") -}, { -"duration": 1.0, "texture": ExtResource("21_oocqa") }, { "duration": 1.0, diff --git a/DungeonShooting_Godot/src/game/activity/role/RoleState.cs b/DungeonShooting_Godot/src/game/activity/role/RoleState.cs index 151b784..8f96289 100644 --- a/DungeonShooting_Godot/src/game/activity/role/RoleState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/RoleState.cs @@ -24,12 +24,17 @@ /// /// 翻滚速度 /// - public float RollSpeed = 180f; + public float RollSpeed = 400f; /// + /// 翻滚持续时间 + /// + public float RollTime = 0.15f; + + /// /// 翻滚冷却时间 /// - public float RollTime = 0.5f; + public float RollCoolingTime = 0.5f; /// /// 单格护盾恢复时间, 单位: 秒 diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs index 50a13be..c39aff9 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/state/AiAstonishedState.cs @@ -13,6 +13,7 @@ public AIStateEnum NextState; private float _timer; + private object[] _args; public AiAstonishedState() : base(AIStateEnum.AiAstonished) { @@ -27,6 +28,8 @@ return; } + _args = args; + NextState = (AIStateEnum)args[0]; _timer = 0.6f; @@ -40,7 +43,14 @@ _timer -= delta; if (_timer <= 0) { - ChangeState(NextState); + if (_args.Length == 1) + { + ChangeState(NextState); + } + else if (_args.Length == 2) + { + ChangeState(NextState, _args[1]); + } } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index c29158d..3cacc51 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -352,7 +352,7 @@ /// public void OverRoll() { - _rollCoolingTimer = RoleState.RollTime; + _rollCoolingTimer = RoleState.RollCoolingTime; } // protected override void DebugDraw() diff --git a/DungeonShooting_Godot/src/game/activity/role/player/state/PlayerRollState.cs b/DungeonShooting_Godot/src/game/activity/role/player/state/PlayerRollState.cs index 229b5df..5817928 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/state/PlayerRollState.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/state/PlayerRollState.cs @@ -22,11 +22,10 @@ } _coroutineId = Master.StartCoroutine(RunRoll()); - Master.AnimatedSprite.Play(AnimatorNames.Roll); - //隐藏武器 - Master.BackMountPoint.Visible = false; - Master.MountPoint.Visible = false; + // //隐藏武器 + // Master.BackMountPoint.Visible = false; + // Master.MountPoint.Visible = false; //禁用伤害碰撞 Master.HurtCollision.Disabled = true; @@ -37,11 +36,12 @@ public override void Exit(PlayerStateEnum next) { - //显示武器 - Master.BackMountPoint.Visible = true; - Master.MountPoint.Visible = true; + // //显示武器 + // Master.BackMountPoint.Visible = true; + // Master.MountPoint.Visible = true; //启用伤害碰撞 Master.HurtCollision.Disabled = false; + Master.BasisVelocity = Master.BasisVelocity.LimitLength(Master.RoleState.MoveSpeed); } public override void Process(float delta) @@ -52,7 +52,29 @@ //翻滚逻辑处理 private IEnumerator RunRoll() { - yield return Master.AnimatedSprite.ToSignal(Master.AnimatedSprite, AnimatedSprite2D.SignalName.AnimationFinished); + Master.AnimationPlayer.Play(AnimatorNames.Roll); + var time = 0f; + var time2 = 0f; + while (time < Master.RoleState.RollTime) + { + var delta = (float)Master.GetProcessDeltaTime(); + time += delta; + time2 += delta; + if (time2 >= 0.02f) + { + time2 %= 0.02f; + //拖尾效果 + var staticSprite = ObjectManager.GetPoolItemByClass(); + staticSprite.FromActivityObject(Master); + staticSprite.SetShowTimeout(0.2f); + staticSprite.ZIndex = 1; + var roomLayer = Master.World.GetRoomLayer(RoomLayerEnum.NormalLayer); + roomLayer.AddChild(staticSprite); + //roomLayer.MoveChild(staticSprite, Master.GetIndex()); + } + + yield return null; + } _coroutineId = -1; Master.OverRoll(); if (InputManager.MoveAxis != Vector2.Zero) //切换到移动状态 diff --git a/DungeonShooting_Godot/src/game/effects/SmearingSprite.cs b/DungeonShooting_Godot/src/game/effects/SmearingSprite.cs new file mode 100644 index 0000000..1e2fa24 --- /dev/null +++ b/DungeonShooting_Godot/src/game/effects/SmearingSprite.cs @@ -0,0 +1,70 @@ + +using Godot; + +/// +/// 拖影精灵 +/// +public partial class SmearingSprite : Sprite2D, IPoolItem +{ + public bool IsRecycled { get; set; } + public string Logotype { get; set; } + public bool IsDestroyed { get; set; } + + private double _timeOut = -1; + private double _totalTime = 0; + + /// + /// 从 ActivityObject 的 AnimatedSprite 中复制动画帧 + /// + public void FromActivityObject(ActivityObject activityObject) + { + var currentTexture = activityObject.GetCurrentTexture(); + Texture = currentTexture; + Offset = activityObject.AnimatedSprite.Offset; + GlobalPosition = activityObject.AnimatedSprite.GlobalPosition; + GlobalScale = activityObject.AnimatedSprite.GlobalScale; + GlobalRotation = activityObject.AnimatedSprite.GlobalRotation; + } + + /// + /// 设置显示的时间, 过期会自动回收 + /// + public void SetShowTimeout(float time) + { + _totalTime = time; + _timeOut = time; + } + + public override void _Process(double delta) + { + if (_timeOut > 0) + { + _timeOut -= delta; + Modulate = new Color(1, 1, 1, (float)(_timeOut / _totalTime)); + if (_timeOut <= 0) + { + ObjectPool.Reclaim(this); + } + } + } + + public void Destroy() + { + if (IsDestroyed) + { + return; + } + + IsDestroyed = true; + QueueFree(); + } + public void OnReclaim() + { + GetParent().RemoveChild(this); + } + + public void OnLeavePool() + { + Modulate = Colors.White; + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/ObjectManager.cs b/DungeonShooting_Godot/src/game/manager/ObjectManager.cs index 4c5336e..27206a3 100644 --- a/DungeonShooting_Godot/src/game/manager/ObjectManager.cs +++ b/DungeonShooting_Godot/src/game/manager/ObjectManager.cs @@ -35,6 +35,22 @@ return item; } + /// + /// 根据类型直接获取实例对象 + /// + public static T GetPoolItemByClass() where T : IPoolItem, new() + { + var name = typeof(T).FullName; + var item = ObjectPool.GetItem(name); + if (item == null) + { + item = new T(); + item.Logotype = name; + } + + return item; + } + public static Bullet GetBullet(string id) { var bullet = ObjectPool.GetItem(id);