diff --git a/DungeonShooting_Godot/prefab/effect/BulletSmoke.tscn b/DungeonShooting_Godot/prefab/effect/BulletSmoke.tscn index 366e88e..22ba2ef 100644 --- a/DungeonShooting_Godot/prefab/effect/BulletSmoke.tscn +++ b/DungeonShooting_Godot/prefab/effect/BulletSmoke.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=10 format=3 uid="uid://dtr8nurmv2qtg"] +[gd_scene load_steps=9 format=3 uid="uid://dtr8nurmv2qtg"] [ext_resource type="Texture2D" uid="uid://h7hkgbwj1li" path="res://resource/effects/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/effects/Collision.png" id="2"] [sub_resource type="CanvasItemMaterial" id="1"] @@ -9,13 +10,6 @@ particles_anim_v_frames = 1 particles_anim_loop = false -[sub_resource type="Curve" id="Curve_kve5o"] -_data = [Vector2(0.00645161, 0), 0.0, 0.0, 0, 0, Vector2(0.151613, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] -point_count = 3 - -[sub_resource type="CurveTexture" id="CurveTexture_yr1bt"] -curve = SubResource("Curve_kve5o") - [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_gpp81"] lifetime_randomness = 0.5 particle_flag_disable_z = true @@ -25,7 +19,7 @@ orbit_velocity_min = 0.0 orbit_velocity_max = 0.0 angle_max = 360.0 -scale_curve = SubResource("CurveTexture_yr1bt") +scale_curve = ExtResource("1_8pe88") color = Color(0.75, 0.75, 0.75, 0.470588) anim_offset_max = 1.0 diff --git a/DungeonShooting_Godot/prefab/effect/Effect1.tscn b/DungeonShooting_Godot/prefab/effect/Effect1.tscn new file mode 100644 index 0000000..df39e78 --- /dev/null +++ b/DungeonShooting_Godot/prefab/effect/Effect1.tscn @@ -0,0 +1,62 @@ +[gd_scene load_steps=8 format=3 uid="uid://crx1kqqrymmdb"] + +[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/effects/Smoke.png" id="2_3kyig"] +[ext_resource type="Texture2D" uid="uid://csud4e6kc3iku" path="res://resource/effects/Effect1.png" id="3_1mceu"] +[ext_resource type="Script" path="res://src/game/effects/Effect1.cs" id="3_ax5u4"] + +[sub_resource type="CanvasItemMaterial" id="CanvasItemMaterial_ipadv"] +particles_animation = true +particles_anim_h_frames = 3 +particles_anim_v_frames = 1 +particles_anim_loop = false + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_wsy4a"] +particle_flag_disable_z = true +spread = 180.0 +gravity = Vector3(0, 0, 0) +initial_velocity_min = 5.0 +initial_velocity_max = 35.0 +orbit_velocity_min = 0.0 +orbit_velocity_max = 0.0 +scale_min = 0.8 +scale_max = 0.8 +scale_curve = ExtResource("1_s60r7") +color = Color(0.760784, 0.760784, 0.760784, 0.533333) +anim_offset_max = 1.0 + +[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_pgx85"] +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 +scale_min = 0.2 +scale_max = 0.3 +scale_curve = ExtResource("1_s60r7") + +[node name="Effect1" type="GPUParticles2D"] +z_index = 5 +material = SubResource("CanvasItemMaterial_ipadv") +emitting = false +amount = 10 +process_material = SubResource("ParticleProcessMaterial_wsy4a") +texture = ExtResource("2_3kyig") +lifetime = 0.7 +one_shot = true +explosiveness = 1.0 +fixed_fps = 20 +script = ExtResource("3_ax5u4") + +[node name="GPUParticles2D" type="GPUParticles2D" parent="."] +emitting = false +process_material = SubResource("ParticleProcessMaterial_pgx85") +texture = ExtResource("3_1mceu") +lifetime = 0.5 +one_shot = true +explosiveness = 1.0 +randomness = 0.5 +fixed_fps = 20 diff --git a/DungeonShooting_Godot/resource/curve/Curve1.tres b/DungeonShooting_Godot/resource/curve/Curve1.tres new file mode 100644 index 0000000..71aa695 --- /dev/null +++ b/DungeonShooting_Godot/resource/curve/Curve1.tres @@ -0,0 +1,8 @@ +[gd_resource type="CurveTexture" load_steps=2 format=3 uid="uid://bs1lan5uwxyfg"] + +[sub_resource type="Curve" id="Curve_kve5o"] +_data = [Vector2(0.00645161, 0), 0.0, 0.0, 0, 0, Vector2(0.151613, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0] +point_count = 3 + +[resource] +curve = SubResource("Curve_kve5o") diff --git a/DungeonShooting_Godot/resource/effects/Effect1.png b/DungeonShooting_Godot/resource/effects/Effect1.png new file mode 100644 index 0000000..51ef9a9 --- /dev/null +++ b/DungeonShooting_Godot/resource/effects/Effect1.png Binary files differ diff --git a/DungeonShooting_Godot/resource/effects/Effect1.png.import b/DungeonShooting_Godot/resource/effects/Effect1.png.import new file mode 100644 index 0000000..f6bc5d2 --- /dev/null +++ b/DungeonShooting_Godot/resource/effects/Effect1.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://csud4e6kc3iku" +path="res://.godot/imported/Effect1.png-277a43c6763fd3e5c0967adefb26bf09.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/effects/Effect1.png" +dest_files=["res://.godot/imported/Effect1.png-277a43c6763fd3e5c0967adefb26bf09.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/src/framework/common/Utils.cs b/DungeonShooting_Godot/src/framework/common/Utils.cs index ddac26c..4b27f8e 100644 --- a/DungeonShooting_Godot/src/framework/common/Utils.cs +++ b/DungeonShooting_Godot/src/framework/common/Utils.cs @@ -13,7 +13,7 @@ static Utils() { - _random = new Random(1); + _random = new Random(); } /// diff --git a/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs b/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs index 8359e1a..5d0c29c 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs @@ -69,6 +69,10 @@ CreateWeapon(instance, pos, Weapon3Id, Weapon3Ammo); if (!string.IsNullOrWhiteSpace(Weapon4Id)) CreateWeapon(instance, pos, Weapon4Id, Weapon4Ammo); + + var effect1 = ResourceManager.LoadAndInstantiate(ResourcePath.prefab_effect_Effect1_tscn); + effect1.Position = instance.Position; + effect1.AddToActivityRoot(RoomLayerEnum.NormalLayer); } //生成武器 diff --git a/DungeonShooting_Godot/src/framework/map/mark/WeaponMark.cs b/DungeonShooting_Godot/src/framework/map/mark/WeaponMark.cs index 9b06298..38dc06f 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/WeaponMark.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/WeaponMark.cs @@ -41,5 +41,9 @@ instance.PutDown(Layer); + + var effect1 = ResourceManager.LoadAndInstantiate(ResourcePath.prefab_effect_Effect1_tscn); + effect1.Position = instance.Position; + effect1.AddToActivityRoot(RoomLayerEnum.NormalLayer); } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/effects/Effect1.cs b/DungeonShooting_Godot/src/game/effects/Effect1.cs new file mode 100644 index 0000000..2bf5ca0 --- /dev/null +++ b/DungeonShooting_Godot/src/game/effects/Effect1.cs @@ -0,0 +1,17 @@ +using Godot; + +public partial class Effect1 : GpuParticles2D +{ + public override async void _Ready() + { + var c = GetNode("GPUParticles2D"); + c.Amount = Utils.RandomRangeInt(2, 6); + c.Emitting = true; + Emitting = true; + + var sceneTreeTimer = GetTree().CreateTimer(1f); + await ToSignal(sceneTreeTimer, Timer.SignalName.Timeout); + QueueFree(); + } + +} diff --git a/DungeonShooting_Godot/src/game/manager/ResourceManager.cs b/DungeonShooting_Godot/src/game/manager/ResourceManager.cs index 9460334..e5798a8 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourceManager.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourceManager.cs @@ -53,7 +53,7 @@ { if (!useCache) { - T res = ResourceLoader.Load(path, null, ResourceLoader.CacheMode.Ignore); + var res = ResourceLoader.Load(path, null, ResourceLoader.CacheMode.Ignore); if (res == null) { GD.PrintErr("加载资源失败, 未找到资源: " + path); @@ -81,4 +81,14 @@ return default; } + + /// + /// 加载并且实例化场景, 并返回 + /// + /// 场景路径 + public static T LoadAndInstantiate(string path) where T : Node + { + var packedScene = Load(path); + return packedScene.Instantiate(); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs index 7d89582..aa05b8b 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -8,6 +8,7 @@ public const string prefab_effect_Blood_tscn = "res://prefab/effect/Blood.tscn"; public const string prefab_effect_BulletDisappear_tscn = "res://prefab/effect/BulletDisappear.tscn"; public const string prefab_effect_BulletSmoke_tscn = "res://prefab/effect/BulletSmoke.tscn"; + public const string prefab_effect_Effect1_tscn = "res://prefab/effect/Effect1.tscn"; public const string prefab_effect_FirePart_tscn = "res://prefab/effect/FirePart.tscn"; public const string prefab_effect_ShotFire_tscn = "res://prefab/effect/ShotFire.tscn"; public const string prefab_map_RoomDoor_tscn = "res://prefab/map/RoomDoor.tscn"; @@ -22,9 +23,11 @@ public const string prefab_weapon_Weapon_tscn = "res://prefab/weapon/Weapon.tscn"; public const string prefab_weapon_bullet_Bullet_tscn = "res://prefab/weapon/bullet/Bullet.tscn"; public const string prefab_weapon_shell_ShellCase_tscn = "res://prefab/weapon/shell/ShellCase.tscn"; + public const string resource_curve_Curve1_tres = "res://resource/curve/Curve1.tres"; public const string resource_effects_Circle_png = "res://resource/effects/Circle.png"; public const string resource_effects_Collision_png = "res://resource/effects/Collision.png"; public const string resource_effects_debug_arrows_png = "res://resource/effects/debug_arrows.png"; + public const string resource_effects_Effect1_png = "res://resource/effects/Effect1.png"; public const string resource_effects_Explosion_png = "res://resource/effects/Explosion.png"; public const string resource_effects_Hit_tres = "res://resource/effects/Hit.tres"; public const string resource_effects_KnifeHit1_tres = "res://resource/effects/KnifeHit1.tres"; @@ -40,6 +43,7 @@ public const string resource_map_tiledata_testGroup_battle_Room4_json = "res://resource/map/tiledata/testGroup/battle/Room4.json"; public const string resource_map_tiledata_testGroup_battle_Room5_json = "res://resource/map/tiledata/testGroup/battle/Room5.json"; public const string resource_map_tiledata_testGroup_battle_Room6_json = "res://resource/map/tiledata/testGroup/battle/Room6.json"; + public const string resource_map_tiledata_testGroup_battle_Room7_json = "res://resource/map/tiledata/testGroup/battle/Room7.json"; public const string resource_map_tiledata_testGroup_inlet_Room1_json = "res://resource/map/tiledata/testGroup/inlet/Room1.json"; public const string resource_map_tiledata_testGroup_outlet_Room1_json = "res://resource/map/tiledata/testGroup/outlet/Room1.json"; public const string resource_map_tileMaps_testGroup_battle_Room1_tscn = "res://resource/map/tileMaps/testGroup/battle/Room1.tscn"; @@ -48,6 +52,7 @@ public const string resource_map_tileMaps_testGroup_battle_Room4_tscn = "res://resource/map/tileMaps/testGroup/battle/Room4.tscn"; public const string resource_map_tileMaps_testGroup_battle_Room5_tscn = "res://resource/map/tileMaps/testGroup/battle/Room5.tscn"; public const string resource_map_tileMaps_testGroup_battle_Room6_tscn = "res://resource/map/tileMaps/testGroup/battle/Room6.tscn"; + public const string resource_map_tileMaps_testGroup_battle_Room7_tscn = "res://resource/map/tileMaps/testGroup/battle/Room7.tscn"; public const string resource_map_tileMaps_testGroup_inlet_Room1_tscn = "res://resource/map/tileMaps/testGroup/inlet/Room1.tscn"; public const string resource_map_tileMaps_testGroup_outlet_Room1_tscn = "res://resource/map/tileMaps/testGroup/outlet/Room1.tscn"; public const string resource_map_tileset_TileSet1_tres = "res://resource/map/tileset/TileSet1.tres"; @@ -238,6 +243,7 @@ public const string resource_sprite_gun_gun8_png = "res://resource/sprite/gun/gun8.png"; public const string resource_sprite_gun_knife1_png = "res://resource/sprite/gun/knife1.png"; public const string resource_sprite_gun_out_default_png = "res://resource/sprite/gun/out/default.png"; + public const string resource_sprite_map_door1_down_png = "res://resource/sprite/map/door1_down.png"; public const string resource_sprite_role_role1_png = "res://resource/sprite/role/role1.png"; public const string resource_sprite_role_role10_png = "res://resource/sprite/role/role10.png"; public const string resource_sprite_role_role2_png = "res://resource/sprite/role/role2.png"; diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs index a2c4dde..8ef27b9 100644 --- a/DungeonShooting_Godot/src/game/role/Player.cs +++ b/DungeonShooting_Godot/src/game/role/Player.cs @@ -1,3 +1,4 @@ +using System.Collections; using Godot;