diff --git a/DungeonShooting_Godot/excel/ActivityBase.xlsx b/DungeonShooting_Godot/excel/ActivityBase.xlsx index 738a3b6..1fd1d4c 100644 --- a/DungeonShooting_Godot/excel/ActivityBase.xlsx +++ b/DungeonShooting_Godot/excel/ActivityBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/excel/WeaponBase.xlsx b/DungeonShooting_Godot/excel/WeaponBase.xlsx index cfa23bb..9e72dd1 100644 --- a/DungeonShooting_Godot/excel/WeaponBase.xlsx +++ b/DungeonShooting_Godot/excel/WeaponBase.xlsx Binary files differ diff --git a/DungeonShooting_Godot/prefab/box/TreasureBox0001.tscn b/DungeonShooting_Godot/prefab/box/TreasureBox0001.tscn new file mode 100644 index 0000000..804110c --- /dev/null +++ b/DungeonShooting_Godot/prefab/box/TreasureBox0001.tscn @@ -0,0 +1,94 @@ +[gd_scene load_steps=12 format=3 uid="uid://d2gj0yuup0gdb"] + +[ext_resource type="Script" path="res://src/game/activity/box/TreasureBox.cs" id="1_wxils"] +[ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="2_l4sas"] +[ext_resource type="Texture2D" uid="uid://dladvmgql1pwe" path="res://resource/sprite/box/TreasureBox0001.png" id="3_eed5t"] + +[sub_resource type="ShaderMaterial" id="ShaderMaterial_1v1is"] +resource_local_to_scene = true +shader = ExtResource("2_l4sas") +shader_parameter/blend = Color(0, 0, 0, 0.470588) +shader_parameter/schedule = 1.0 +shader_parameter/modulate = Color(1, 1, 1, 1) +shader_parameter/show_outline = true +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_lewo8"] +resource_local_to_scene = true +shader = ExtResource("2_l4sas") +shader_parameter/blend = Color(1, 1, 1, 1) +shader_parameter/schedule = 0.0 +shader_parameter/modulate = Color(1, 1, 1, 1) +shader_parameter/show_outline = true +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="AtlasTexture" id="AtlasTexture_hserg"] +atlas = ExtResource("3_eed5t") +region = Rect2(0, 0, 32, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_8d3br"] +atlas = ExtResource("3_eed5t") +region = Rect2(0, 0, 32, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_fp844"] +atlas = ExtResource("3_eed5t") +region = Rect2(32, 0, 32, 32) + +[sub_resource type="AtlasTexture" id="AtlasTexture_151ky"] +atlas = ExtResource("3_eed5t") +region = Rect2(64, 0, 32, 32) + +[sub_resource type="SpriteFrames" id="SpriteFrames_e74dc"] +animations = [{ +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_hserg") +}], +"loop": false, +"name": &"default", +"speed": 5.0 +}, { +"frames": [{ +"duration": 1.0, +"texture": SubResource("AtlasTexture_8d3br") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_fp844") +}, { +"duration": 1.0, +"texture": SubResource("AtlasTexture_151ky") +}], +"loop": false, +"name": &"open", +"speed": 8.0 +}] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_j3yup"] +size = Vector2(26, 11) + +[node name="TreasureBox0001" type="CharacterBody2D" node_paths=PackedStringArray("ShadowSprite", "AnimatedSprite", "Collision")] +collision_layer = 516 +script = ExtResource("1_wxils") +ShadowSprite = NodePath("ShadowSprite") +AnimatedSprite = NodePath("AnimatedSprite") +Collision = NodePath("Collision") + +[node name="ShadowSprite" type="Sprite2D" parent="."] +z_index = -1 +material = SubResource("ShaderMaterial_1v1is") + +[node name="AnimatedSprite" type="AnimatedSprite2D" parent="."] +material = SubResource("ShaderMaterial_lewo8") +position = Vector2(0, -11) +sprite_frames = SubResource("SpriteFrames_e74dc") +animation = &"open" + +[node name="Collision" type="CollisionShape2D" parent="."] +position = Vector2(0, -1.5) +shape = SubResource("RectangleShape2D_j3yup") diff --git a/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn b/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn index fad5129..bd7ca13 100644 --- a/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn +++ b/DungeonShooting_Godot/prefab/bullet/explode/Explode0001.tscn @@ -307,6 +307,7 @@ modulate = Color(1.3, 1.3, 1.3, 1) z_index = 1 collision_layer = 0 +collision_mask = 0 monitorable = false script = ExtResource("1_qn5pu") diff --git a/DungeonShooting_Godot/prefab/bullet/laser/Laser0001.tscn b/DungeonShooting_Godot/prefab/bullet/laser/Laser0001.tscn index 9189dc9..04de455 100644 --- a/DungeonShooting_Godot/prefab/bullet/laser/Laser0001.tscn +++ b/DungeonShooting_Godot/prefab/bullet/laser/Laser0001.tscn @@ -8,6 +8,7 @@ [node name="Laser0001" type="Area2D" node_paths=PackedStringArray("Particles2D")] collision_layer = 2 +collision_mask = 0 monitorable = false script = ExtResource("1_3w0rp") Particles2D = [] diff --git a/DungeonShooting_Godot/prefab/bullet/laser/Laser0002.tscn b/DungeonShooting_Godot/prefab/bullet/laser/Laser0002.tscn index fc415cf..c989324 100644 --- a/DungeonShooting_Godot/prefab/bullet/laser/Laser0002.tscn +++ b/DungeonShooting_Godot/prefab/bullet/laser/Laser0002.tscn @@ -8,6 +8,7 @@ [node name="Laser0001" type="Area2D" node_paths=PackedStringArray("Particles2D")] collision_layer = 2 +collision_mask = 0 monitorable = false script = ExtResource("1_t3xbd") Particles2D = [] diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0001.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0001.tscn index 1dd7c32..e1ddde3 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0001.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0001.tscn @@ -33,6 +33,7 @@ [node name="Bullet0001" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 +collision_mask = 0 script = ExtResource("1_3d3df") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0002.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0002.tscn index ecabf2f..4441bc7 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0002.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0002.tscn @@ -36,6 +36,7 @@ [node name="Bullet0002" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 +collision_mask = 0 script = ExtResource("1_hepay") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0003.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0003.tscn index b87d8e0..88082d7 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0003.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0003.tscn @@ -33,6 +33,7 @@ [node name="Bullet0003" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 +collision_mask = 0 script = ExtResource("1_h6lfm") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn index 3c96ac3..57e55ab 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0004.tscn @@ -62,6 +62,7 @@ [node name="Bullet0003" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 +collision_mask = 0 script = ExtResource("1_1jbgr") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn index 3203560..a6a0493 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0005.tscn @@ -62,6 +62,8 @@ [node name="Bullet0005" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 +collision_mask = 0 +platform_wall_layers = 512 script = ExtResource("1_13wdl") BrushId = "0004" EffectiveAltitude = 1.0 diff --git a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0006.tscn b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0006.tscn index 0586c5b..9e58d27 100644 --- a/DungeonShooting_Godot/prefab/bullet/normal/Bullet0006.tscn +++ b/DungeonShooting_Godot/prefab/bullet/normal/Bullet0006.tscn @@ -36,6 +36,7 @@ [node name="Bullet0006" type="CharacterBody2D" node_paths=PackedStringArray("CollisionArea", "CollisionShape2D", "Particles2D", "ShadowSprite", "AnimatedSprite", "Collision")] collision_layer = 2 +collision_mask = 0 script = ExtResource("1_b8pov") CollisionArea = NodePath("AnimatedSprite/CollisionArea") CollisionShape2D = NodePath("AnimatedSprite/CollisionArea/CollisionShape2D") diff --git a/DungeonShooting_Godot/prefab/role/Role0001.tscn b/DungeonShooting_Godot/prefab/role/Role0001.tscn index 04aa1b8..cb1c9cb 100644 --- a/DungeonShooting_Godot/prefab/role/Role0001.tscn +++ b/DungeonShooting_Godot/prefab/role/Role0001.tscn @@ -55,8 +55,8 @@ [node name="HurtCollision" parent="HurtArea" index="0"] shape = SubResource("RectangleShape2D_ve262") -[node name="InteractiveArea" parent="." index="5"] -visible = true +[node name="InteractiveCollision" parent="InteractiveArea" index="0"] +position = Vector2(0, 0) [node name="AnimationPlayer" parent="." index="8"] libraries = { diff --git a/DungeonShooting_Godot/prefab/role/template/EnemyTemplate.tscn b/DungeonShooting_Godot/prefab/role/template/EnemyTemplate.tscn index 3625be0..4247548 100644 --- a/DungeonShooting_Godot/prefab/role/template/EnemyTemplate.tscn +++ b/DungeonShooting_Godot/prefab/role/template/EnemyTemplate.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=4 format=3 uid="uid://dbrig6dq441wo"] +[gd_scene load_steps=5 format=3 uid="uid://dbrig6dq441wo"] [ext_resource type="PackedScene" uid="uid://cyrcv2jdgr8cf" path="res://prefab/role/template/RoleTemplate.tscn" id="1_5po38"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="3_x8agd"] @@ -15,6 +15,9 @@ shader_parameter/outline_use_blend = true shader_parameter/grey = 0.0 +[sub_resource type="CircleShape2D" id="CircleShape2D_wu0xv"] +radius = 8.06226 + [node name="EnemyTemplate" instance=ExtResource("1_5po38")] collision_layer = 16 collision_mask = 25 @@ -22,6 +25,9 @@ [node name="AnimatedSprite" parent="." index="2"] material = SubResource("ShaderMaterial_k8mt5") +[node name="InteractiveCollision" parent="InteractiveArea" index="0"] +shape = SubResource("CircleShape2D_wu0xv") + [node name="ViewRay" type="RayCast2D" parent="." index="6"] position = Vector2(0, -8) enabled = false diff --git a/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn b/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn index d6187e3..be6716b 100644 --- a/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn +++ b/DungeonShooting_Godot/prefab/role/template/RoleTemplate.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=8 format=3 uid="uid://cyrcv2jdgr8cf"] +[gd_scene load_steps=9 format=3 uid="uid://cyrcv2jdgr8cf"] [ext_resource type="Shader" path="res://resource/material/Blend.gdshader" id="1_xk5yk"] [ext_resource type="Script" path="res://src/game/activity/role/MountRotation.cs" id="2_5ddpw"] +[ext_resource type="Script" path="res://src/framework/activity/hurt/HurtArea.cs" id="2_8jnvr"] [ext_resource type="SpriteFrames" uid="uid://c8h5svp76h3kw" path="res://resource/spriteFrames/role/Role_tip.tres" id="3_bo78w"] [sub_resource type="ShaderMaterial" id="ShaderMaterial_yif6x"] @@ -22,11 +23,13 @@ [sub_resource type="RectangleShape2D" id="RectangleShape2D_1eja2"] size = Vector2(12, 18) -[sub_resource type="RectangleShape2D" id="RectangleShape2D_n68nu"] -size = Vector2(10, 16.5) +[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_843d5"] +radius = 8.0 +height = 16.0 [node name="RoleTemplate" type="CharacterBody2D"] collision_layer = 0 +collision_mask = 513 [node name="ShadowSprite" type="Sprite2D" parent="."] z_index = -1 @@ -46,26 +49,27 @@ collision_layer = 0 collision_mask = 0 monitoring = false +script = ExtResource("2_8jnvr") [node name="HurtCollision" type="CollisionShape2D" parent="HurtArea"] position = Vector2(0, -9) shape = SubResource("RectangleShape2D_1eja2") [node name="InteractiveArea" type="Area2D" parent="."] -visible = false collision_layer = 0 collision_mask = 4 monitorable = false [node name="InteractiveCollision" type="CollisionShape2D" parent="InteractiveArea"] -position = Vector2(0, -5) -shape = SubResource("RectangleShape2D_n68nu") +position = Vector2(0, -2) +shape = SubResource("CapsuleShape2D_843d5") [node name="MountPoint" type="Marker2D" parent="."] position = Vector2(2, -8) script = ExtResource("2_5ddpw") [node name="MeleeAttackArea" type="Area2D" parent="MountPoint"] +visible = false collision_layer = 0 collision_mask = 0 monitorable = false diff --git a/DungeonShooting_Godot/prefab/weapon/Weapon0010.tscn b/DungeonShooting_Godot/prefab/weapon/Weapon0010.tscn index 3810950..571ff9f 100644 --- a/DungeonShooting_Godot/prefab/weapon/Weapon0010.tscn +++ b/DungeonShooting_Godot/prefab/weapon/Weapon0010.tscn @@ -148,7 +148,7 @@ modulate = Color(1.9, 1.9, 1.9, 1) material = SubResource("ShaderMaterial_0oy4o") sprite_frames = ExtResource("3_nj0c6") -offset = Vector2(4, -2.015) +offset = Vector2(4, -2) [node name="ShellPoint" type="Marker2D" parent="AnimatedSprite"] position = Vector2(-3, -3) @@ -157,7 +157,7 @@ position = Vector2(21, -1) [node name="Collision" type="CollisionShape2D" parent="."] -position = Vector2(4, -1) +position = Vector2(5, -1) shape = SubResource("RectangleShape2D_evjpf") [node name="AnimationPlayer" type="AnimationPlayer" parent="."] diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index bf53351..1d33891 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -244,7 +244,7 @@ 2d_physics/layer_4="player" 2d_physics/layer_5="enemy" 2d_physics/layer_6="affiliation" -2d_physics/layer_7="onHead" +2d_physics/layer_7="onHand" 2d_physics/layer_8="debris" 2d_physics/layer_9="throwing" diff --git a/DungeonShooting_Godot/resource/config/ActivityBase.json b/DungeonShooting_Godot/resource/config/ActivityBase.json index aa7e701..412087e 100644 --- a/DungeonShooting_Godot/resource/config/ActivityBase.json +++ b/DungeonShooting_Godot/resource/config/ActivityBase.json @@ -684,5 +684,19 @@ "Prefab": "res://prefab/currency/Gold1.tscn", "Icon": "res://resource/sprite/ui/commonIcon/Gold_1.png", "ShowInMapEditor": true + }, + { + "Id": "treasure_box0001", + "Type": 99, + "Name": "\u6728\u8D28\u5B9D\u7BB1", + "Quality": 0, + "Price": 0, + "Intro": "\u6728\u8D28\u5B9D\u7BB1", + "Details": "", + "IsStatic": false, + "__Material": "", + "Prefab": "res://prefab/box/TreasureBox0001.tscn", + "Icon": "res://resource/sprite/box/TreasureBox0001.png", + "ShowInMapEditor": true } ] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/config/WeaponBase.json b/DungeonShooting_Godot/resource/config/WeaponBase.json index 9d8e8e0..b83859d 100644 --- a/DungeonShooting_Godot/resource/config/WeaponBase.json +++ b/DungeonShooting_Godot/resource/config/WeaponBase.json @@ -53,10 +53,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -130,10 +126,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -207,10 +199,6 @@ "__Shell": "shell0002", "ReloadThrowShell": false, "ThrowShellDelayTime": 0.2, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -284,10 +272,6 @@ "__Shell": "shell0002", "ReloadThrowShell": false, "ThrowShellDelayTime": 0.2, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -361,10 +345,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -438,10 +418,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -514,10 +490,6 @@ "__Shell": "", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -590,10 +562,6 @@ "__Shell": "", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -667,10 +635,6 @@ "__Shell": "shell0003", "ReloadThrowShell": false, "ThrowShellDelayTime": 0.2, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -744,10 +708,6 @@ "__Shell": "shell0003", "ReloadThrowShell": false, "ThrowShellDelayTime": 0.2, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -821,10 +781,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -898,10 +854,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -975,10 +927,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1052,10 +1000,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1129,10 +1073,6 @@ "__Shell": "", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1206,10 +1146,6 @@ "__Shell": "", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1283,10 +1219,6 @@ "__Shell": "shell0004", "ReloadThrowShell": true, "ThrowShellDelayTime": 0.46, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1360,10 +1292,6 @@ "__Shell": "shell0004", "ReloadThrowShell": true, "ThrowShellDelayTime": 0.46, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1437,10 +1365,6 @@ "__Shell": "", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1514,10 +1438,6 @@ "__Shell": "", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1591,10 +1511,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 @@ -1668,10 +1584,6 @@ "__Shell": "shell0001", "ReloadThrowShell": false, "ThrowShellDelayTime": 0, - "ThrowCollisionSize": { - "X": 20, - "Y": 15 - }, "CanMeleeAttack": true, "MeleeAttackHarmRange": [ 10 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json index 5ceb016..63a7e48 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json @@ -1 +1 @@ -[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":39,"Y":8},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-16,"Y":-18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":6},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0010","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":47,"Y":-32},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0008","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":23,"Y":37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0010","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0005","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":-30},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":40,"Y":-10},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":-37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-2,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":29,"Y":63},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0013","Weight":100,"Attr":{"CurrAmmon":"50","ResidueAmmo":"250"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-30,"Y":39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]}]]}] \ No newline at end of file +[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":39,"Y":8},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]},{"Position":{"X":-16,"Y":-18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":6},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0009","Weight":100,"Attr":{"CurrAmmon":"1","ResidueAmmo":"25"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":66,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0010","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":47,"Y":-32},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0008","Weight":100,"Attr":{"CurrAmmon":"10","ResidueAmmo":"120"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":23,"Y":37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0010","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":18},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0005","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":24,"Y":-30},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":40,"Y":-10},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":2,"Y":-37},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-2,"Y":47},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":29,"Y":63},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0013","Weight":100,"Attr":{"CurrAmmon":"50","ResidueAmmo":"250"},"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-30,"Y":39},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":-19,"Y":71},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop0003","Weight":100,"Attr":null,"Altitude":8,"VerticalSpeed":0}]},{"Position":{"X":48,"Y":29},"Size":{"X":16,"Y":16},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0004","Weight":100,"Attr":{"CurrAmmon":"180","ResidueAmmo":"90"},"Altitude":8,"VerticalSpeed":0}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001.png b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001.png new file mode 100644 index 0000000..96ba1c1 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001.png.import b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001.png.import new file mode 100644 index 0000000..11628b1 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dladvmgql1pwe" +path="res://.godot/imported/TreasureBox0001.png-470db2c564e486f7e8aa1da89a50df44.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/box/TreasureBox0001.png" +dest_files=["res://.godot/imported/TreasureBox0001.png-470db2c564e486f7e8aa1da89a50df44.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/box/TreasureBox0001_icon.png b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001_icon.png new file mode 100644 index 0000000..6b1d441 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001_icon.png Binary files differ diff --git a/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001_icon.png.import b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001_icon.png.import new file mode 100644 index 0000000..f90f748 --- /dev/null +++ b/DungeonShooting_Godot/resource/sprite/box/TreasureBox0001_icon.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dmmq0qjtk3emj" +path="res://.godot/imported/TreasureBox0001_icon.png-84fd776b11f978d95f53508cc4a524a3.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://resource/sprite/box/TreasureBox0001_icon.png" +dest_files=["res://.godot/imported/TreasureBox0001_icon.png-84fd776b11f978d95f53508cc4a524a3.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/config/ExcelConfig_WeaponBase.cs b/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs index 23a5b5b..acf351d 100644 --- a/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs +++ b/DungeonShooting_Godot/src/config/ExcelConfig_WeaponBase.cs @@ -287,12 +287,6 @@ public float ThrowShellDelayTime; /// - /// 投抛状态下物体碰撞器大小 - /// - [JsonInclude] - public SerializeVector2 ThrowCollisionSize; - - /// /// 是否可以触发近战攻击 /// [JsonInclude] @@ -425,7 +419,6 @@ inst.Shell = Shell; inst.ReloadThrowShell = ReloadThrowShell; inst.ThrowShellDelayTime = ThrowShellDelayTime; - inst.ThrowCollisionSize = ThrowCollisionSize; inst.CanMeleeAttack = CanMeleeAttack; inst.MeleeAttackHarmRange = MeleeAttackHarmRange; inst.MeleeAttackRepelRange = MeleeAttackRepelRange; diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs index fb14160..6e2a533 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject.cs @@ -257,7 +257,12 @@ /// /// 默认所在层级 /// - public RoomLayerEnum DefaultLayer { get; protected set; } + public RoomLayerEnum DefaultLayer { get; set; } + + /// + /// 投抛状态下的碰撞器层级 + /// + public uint ThrowCollisionMask { get; set; } = PhysicsLayer.Wall; // -------------------------------------------------------------------------------- @@ -1492,7 +1497,7 @@ Collision.Position = Vector2.Zero; Collision.Rotation = 0; Collision.Scale = Vector2.One; - CollisionMask = 1; + CollisionMask = ThrowCollisionMask; CollisionLayer = _fallData.OriginCollisionLayer | PhysicsLayer.Throwing; _fallData.UseOrigin = false; } diff --git a/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs b/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs index 4963193..a6848fc 100644 --- a/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs +++ b/DungeonShooting_Godot/src/framework/activity/ActivityObject_Init.cs @@ -253,5 +253,10 @@ /// 简介: 获得1金币 /// public const string Id_gold_1 = "gold_1"; + /// + /// 名称: 木质宝箱
+ /// 简介: 木质宝箱 + ///
+ public const string Id_treasure_box0001 = "treasure_box0001"; } } diff --git a/DungeonShooting_Godot/src/framework/activity/CheckInteractiveResult.cs b/DungeonShooting_Godot/src/framework/activity/CheckInteractiveResult.cs index 99b1296..fb38e21 100644 --- a/DungeonShooting_Godot/src/framework/activity/CheckInteractiveResult.cs +++ b/DungeonShooting_Godot/src/framework/activity/CheckInteractiveResult.cs @@ -20,6 +20,14 @@ /// 替换 /// Replace, + /// + /// 打开宝箱 + /// + OpenTreasureBox, + /// + /// 其他互动类型 + /// + Other, } /// diff --git a/DungeonShooting_Godot/src/framework/activity/hurt/HurtArea.cs b/DungeonShooting_Godot/src/framework/activity/hurt/HurtArea.cs new file mode 100644 index 0000000..5a1ca5c --- /dev/null +++ b/DungeonShooting_Godot/src/framework/activity/hurt/HurtArea.cs @@ -0,0 +1,28 @@ +using Godot; + +public partial class HurtArea : Area2D, IHurt +{ + public delegate void HurtDelegate(ActivityObject target, int damage, float angle); + + public event HurtDelegate OnHurtEvent; + + public ActivityObject ActivityObject { get; private set; } + + public void InitActivityObject(ActivityObject activityObject) + { + ActivityObject = activityObject; + } + + public override void _Ready() + { + Monitoring = false; + } + + public void Hurt(ActivityObject target, int damage, float angle) + { + if (OnHurtEvent != null) + { + OnHurtEvent(target, damage, angle); + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/activity/hurt/IHurt.cs b/DungeonShooting_Godot/src/framework/activity/hurt/IHurt.cs new file mode 100644 index 0000000..fd27abc --- /dev/null +++ b/DungeonShooting_Godot/src/framework/activity/hurt/IHurt.cs @@ -0,0 +1,13 @@ + +using Godot; + +public interface IHurt +{ + /// + /// 受到伤害 + /// + /// 触发伤害的对象, 为 null 表示不存在对象或者对象已经被销毁 + /// 伤害的量 + /// 伤害角度(弧度制) + void Hurt(ActivityObject target, int damage, float angle); +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/common/NodeExtend.cs b/DungeonShooting_Godot/src/framework/common/NodeExtend.cs index 250aea8..d4a62a9 100644 --- a/DungeonShooting_Godot/src/framework/common/NodeExtend.cs +++ b/DungeonShooting_Godot/src/framework/common/NodeExtend.cs @@ -7,39 +7,39 @@ /// public static class NodeExtend { - /// - /// 尝试将一个 Node2d 节点转换成一个 ActivityObject 对象, 如果转换失败, 则返回 null - /// - public static ActivityObject AsActivityObject(this Node2D node2d) - { - if (node2d is ActivityObject p) - { - return p; - } - var parent = node2d.GetParent(); - if (parent != null && parent is ActivityObject p2) - { - return p2; - } - return null; - } - - /// - /// 尝试将一个 Node2d 节点转换成一个 ActivityObject 对象, 如果转换失败, 则返回 null - /// - public static T AsActivityObject(this Node2D node2d) where T : ActivityObject - { - if (node2d is T p) - { - return p; - } - var parent = node2d.GetParent(); - if (parent != null && parent is T p2) - { - return p2; - } - return null; - } + // /// + // /// 尝试将一个 Node2d 节点转换成一个 ActivityObject 对象, 如果转换失败, 则返回 null + // /// + // public static ActivityObject AsActivityObject(this Node2D node2d) + // { + // if (node2d is ActivityObject p) + // { + // return p; + // } + // var parent = node2d.GetParent(); + // if (parent != null && parent is ActivityObject p2) + // { + // return p2; + // } + // return null; + // } + // + // /// + // /// 尝试将一个 Node2d 节点转换成一个 ActivityObject 对象, 如果转换失败, 则返回 null + // /// + // public static T AsActivityObject(this Node2D node2d) where T : ActivityObject + // { + // if (node2d is T p) + // { + // return p; + // } + // var parent = node2d.GetParent(); + // if (parent != null && parent is T p2) + // { + // return p2; + // } + // return null; + // } /// /// 将节点插入的房间物体根节点 diff --git a/DungeonShooting_Godot/src/game/activity/box/TreasureBox.cs b/DungeonShooting_Godot/src/game/activity/box/TreasureBox.cs new file mode 100644 index 0000000..046cc24 --- /dev/null +++ b/DungeonShooting_Godot/src/game/activity/box/TreasureBox.cs @@ -0,0 +1,43 @@ +using Godot; + +/// +/// 宝箱 +/// +[Tool] +public partial class TreasureBox : ActivityObject, IHurt +{ + public bool IsOpen { get; private set; } + + public override void OnInit() + { + AnimatedSprite.AnimationFinished += OnAnimationFinished; + } + + public override CheckInteractiveResult CheckInteractive(ActivityObject master) + { + return new CheckInteractiveResult(this, !IsOpen, CheckInteractiveResult.InteractiveType.OpenTreasureBox); + } + + public override void Interactive(ActivityObject master) + { + if (IsOpen) + { + return; + } + + IsOpen = true; + AnimatedSprite.Play(AnimatorNames.Open); + } + + private void OnAnimationFinished() + { + var weapon = Create(World.RandomPool.GetRandomProp()); + weapon.Throw(Position, 2, 90, new Vector2(0, 13), 0); + } + + public void Hurt(ActivityObject target, int damage, float angle) + { + PlayHitAnimation(); + Debug.Log("111"); + } +} \ 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 index 637b9b3..eeffbc9 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/explode/Explode.cs @@ -70,6 +70,7 @@ CollisionShape = GetNode("CollisionShape2D"); CircleShape = (CircleShape2D)CollisionShape.Shape; AnimationPlayer.AnimationFinished += OnAnimationFinish; + AreaEntered += OnArea2dEntered; BodyEntered += OnBodyEntered; } @@ -133,36 +134,43 @@ private void OnBodyEntered(Node2D node) { - var o = node.AsActivityObject(); - if (o != null) + if (node is IHurt hurt) { - var temp = o.Position - Position; - var len = temp.Length(); - var angle = temp.Angle(); + HandlerCollision(hurt); + } + else if (node is Bullet bullet) //是子弹 + { + if (bullet is BoomBullet boomBullet) //如果是爆炸子弹, 则直接销毁 + { + boomBullet.PlayBoom(); + } + bullet.Destroy(); + } + } + + private void OnArea2dEntered(Area2D other) + { + if (other is IHurt hurt) + { + HandlerCollision(hurt); + } + } - if (len <= _hitRadius) //在伤害半径内 - { - if (o is Role role) //是角色 - { - role.CallDeferred(nameof(role.Hurt), BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, _harm, angle); - } - else if (o is Bullet bullet) //是子弹 - { - if (bullet is BoomBullet boomBullet) //如果是爆炸子弹, 则直接销毁 - { - boomBullet.PlayBoom(); - } - bullet.Destroy(); - return; - } - } + private void HandlerCollision(IHurt hurt) + { + var temp = ((Node2D)hurt).GlobalPosition - Position; + var len = temp.Length(); + var angle = temp.Angle(); + + if (len <= _hitRadius) //在伤害半径内 + { + hurt.Hurt(BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, _harm, angle); + } - if (len <= _repelledRadius) //击退半径内 - { - var repelled = (_repelledRadius - len) / _repelledRadius * _maxRepelled; - //o.MoveController.SetAllVelocity(Vector2.Zero); - o.AddRepelForce(Vector2.FromAngle(angle) * repelled); - } + if (len <= _repelledRadius && hurt is HurtArea hurtArea) //击退半径内 + { + var repelled = (_repelledRadius - len) / _repelledRadius * _maxRepelled; + hurtArea.ActivityObject.AddRepelForce(Vector2.FromAngle(angle) * repelled); } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs index 0558ef3..15d260d 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/laser/Laser.cs @@ -64,6 +64,7 @@ _pixelScale = 1f / LineSprite.Texture.GetHeight(); AreaEntered += OnArea2dEntered; + BodyEntered += OnBodyEntered; _init = true; } @@ -77,7 +78,7 @@ //计算射线最大距离, 也就是撞到墙壁的距离 var targetPosition = data.Position + Vector2.FromAngle(data.Rotation) * data.MaxDistance; - var parameters = PhysicsRayQueryParameters2D.Create(data.Position + new Vector2(0, data.Altitude), targetPosition + new Vector2(0, data.Altitude), PhysicsLayer.Wall); + var parameters = PhysicsRayQueryParameters2D.Create(data.Position + new Vector2(0, data.Altitude), targetPosition + new Vector2(0, data.Altitude), PhysicsLayer.Wall | PhysicsLayer.Obstacle); var result = GetWorld2D().DirectSpaceState.IntersectRay(parameters); float distance; var doRebound = false; //是否需要执行反弹 @@ -192,22 +193,39 @@ } } } + + private void OnBodyEntered(Node2D body) + { + if (body is IHurt hurt) + { + HandlerCollision(hurt); + } + } private void OnArea2dEntered(Area2D other) { - var role = other.AsActivityObject(); - if (role != null) + if (other is IHurt hurt) { - //击退 - if (BulletData.Repel != 0) - { - role.AddRepelForce(Vector2.FromAngle(Rotation) * BulletData.Repel); - } - //造成伤害 - role.CallDeferred(nameof(Role.Hurt), BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation); + HandlerCollision(hurt); } } + private void HandlerCollision(IHurt hurt) + { + if (hurt is HurtArea hurtArea) + { + var o = hurtArea.ActivityObject; + //击退 + if (o is not Player && BulletData.Repel != 0) + { + o.AddRepelForce(Vector2.FromAngle(Rotation) * BulletData.Repel); + } + } + + //造成伤害 + hurt.Hurt(BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation); + } + public long StartCoroutine(IEnumerator able) { return ProxyCoroutineHandler.ProxyStartCoroutine(ref _coroutineList, able); diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs index 1a763f3..2c7f240 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/BoomBullet.cs @@ -19,7 +19,7 @@ DoReclaim(); } - public override void OnCollisionTarget(ActivityObject o) + public override void OnCollisionTarget(IHurt o) { PlayBoom(); DoReclaim(); diff --git a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs index 800cb64..7b94b8e 100644 --- a/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs +++ b/DungeonShooting_Godot/src/game/activity/bullet/normal/Bullet.cs @@ -76,6 +76,7 @@ if (!_init) { CollisionArea.AreaEntered += OnArea2dEntered; + CollisionArea.BodyEntered += OnBodyEntered; _init = true; } @@ -115,14 +116,12 @@ { if (!IsEnemyBullet) { - IsEnemyBullet = true; - OnRefreshBulletColor(IsEnemyBullet); + RefreshBulletColor(true); } } else if (IsEnemyBullet) { - IsEnemyBullet = false; - OnRefreshBulletColor(IsEnemyBullet); + RefreshBulletColor(false); } PutDown(RoomLayerEnum.YSortLayer); @@ -150,8 +149,9 @@ /// 刷新子弹的颜色 /// /// 是否是敌人使用的子弹 - public virtual void OnRefreshBulletColor(bool isEnemyBullet) + public virtual void RefreshBulletColor(bool isEnemyBullet) { + IsEnemyBullet = isEnemyBullet; if (isEnemyBullet) { ShowOutline = true; @@ -178,30 +178,31 @@ /// /// 碰到目标 /// - public virtual void OnCollisionTarget(ActivityObject o) + public virtual void OnCollisionTarget(IHurt hurt) { - if (o is Role role) - { - OnPlayDisappearEffect(); + OnPlayDisappearEffect(); + if (hurt is HurtArea hurtArea) + { + var o = hurtArea.ActivityObject; //击退 - if (role is not Player) //目标不是玩家才会触发击退 + if (o is not Player) //目标不是玩家才会触发击退 { if (BulletData.Repel != 0) { - role.AddRepelForce(Velocity.Normalized() * BulletData.Repel); + o.AddRepelForce(Velocity.Normalized() * BulletData.Repel); } } - - //造成伤害 - role.CallDeferred(nameof(Role.Hurt), BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation); + } + + //造成伤害 + hurt.Hurt(BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation); - //穿透次数 - CurrentPenetration++; - if (CurrentPenetration > BulletData.Penetration) - { - DoReclaim(); - } + //穿透次数 + CurrentPenetration++; + if (CurrentPenetration > BulletData.Penetration) + { + DoReclaim(); } } @@ -306,17 +307,37 @@ OnMaxDistance(); } } - + + private void OnBodyEntered(Node2D body) + { + if (IsDestroyed) + { + return; + } + + if (body is IHurt hurt) + { + OnCollisionTarget(hurt); + } + } + private void OnArea2dEntered(Area2D other) { if (IsDestroyed) { return; } - var activityObject = other.AsActivityObject(); - OnCollisionTarget(activityObject); + + if (other is HurtArea hurtArea) + { + OnCollisionTarget(hurtArea); + } + else if (other is IHurt hurt) + { + hurt.Hurt(BulletData.TriggerRole.IsDestroyed ? null : BulletData.TriggerRole, BulletData.Harm, Rotation); + } } - + public virtual void DoReclaim() { ObjectPool.Reclaim(this); diff --git a/DungeonShooting_Godot/src/game/activity/prop/Prop.cs b/DungeonShooting_Godot/src/game/activity/prop/Prop.cs index c79dfc0..90fb6e7 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/Prop.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/Prop.cs @@ -21,6 +21,11 @@ /// public abstract void OnRemoveItem(); + public override void OnInit() + { + ThrowCollisionMask = PhysicsLayer.Wall; + } + /// /// 如果道具放入了角色背包中, 则每帧调用 /// diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs index 2770ac7..bdc2ce4 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5000.cs @@ -9,6 +9,7 @@ { public override void OnInit() { + base.OnInit(); AutoDestroy = true; MaxCount = 10; Superposition = true; diff --git a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs index 2bac5e6..43770cb 100644 --- a/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs +++ b/DungeonShooting_Godot/src/game/activity/prop/active/ActiveProp5001.cs @@ -9,6 +9,7 @@ { public override void OnInit() { + base.OnInit(); Superposition = true; AutoDestroy = true; MaxCount = 10; diff --git a/DungeonShooting_Godot/src/game/activity/role/Role.cs b/DungeonShooting_Godot/src/game/activity/role/Role.cs index 4dbfcc6..7557829 100644 --- a/DungeonShooting_Godot/src/game/activity/role/Role.cs +++ b/DungeonShooting_Godot/src/game/activity/role/Role.cs @@ -22,13 +22,13 @@ /// /// 默认攻击对象层级 /// - public const uint DefaultAttackLayer = PhysicsLayer.Player | PhysicsLayer.Enemy | PhysicsLayer.Wall; + public const uint DefaultAttackLayer = PhysicsLayer.Player | PhysicsLayer.Enemy | PhysicsLayer.Obstacle; /// /// 伤害区域 /// [Export, ExportFillNode] - public Area2D HurtArea { get; set; } + public HurtArea HurtArea { get; set; } /// /// 伤害区域碰撞器 @@ -44,7 +44,7 @@ /// /// 攻击目标的碰撞器所属层级, 数据源自于: /// - public uint AttackLayer { get; set; } = PhysicsLayer.Wall; + public uint AttackLayer { get; set; } = PhysicsLayer.Wall | PhysicsLayer.Obstacle; /// /// 该角色敌对目标的碰撞器所属层级, 数据源自于: @@ -464,9 +464,15 @@ _startScale = Scale; + HurtArea.InitActivityObject(this); HurtArea.CollisionLayer = CollisionLayer; - HurtArea.CollisionMask = 0; + HurtArea.CollisionMask = PhysicsLayer.None; _currentLayer = HurtArea.CollisionLayer; + //CollisionLayer = PhysicsLayer.None; + HurtArea.OnHurtEvent += (target, damage, angle) => + { + CallDeferred(nameof(HurtHandler), target, damage, angle); + }; Face = FaceDirection.Right; @@ -486,6 +492,7 @@ WeaponPack.ChangeActiveItemEvent += OnChangeActiveItem; //近战区域进入物体 MeleeAttackArea.BodyEntered += OnMeleeAttackBodyEntered; + MeleeAttackArea.AreaEntered += OnMeleeAttackAreaEntered; } protected override void Process(float delta) @@ -788,14 +795,14 @@ activeItem.Use(); } } - + /// /// 受到伤害, 如果是在碰撞信号处理函数中调用该函数, 请使用 CallDeferred 来延时调用, 否则很有可能导致报错 /// /// 触发伤害的对象, 为 null 表示不存在对象或者对象已经被销毁 /// 伤害的量 /// 伤害角度(弧度制) - public virtual void Hurt(ActivityObject target, int damage, float angle) + protected virtual void HurtHandler(ActivityObject target, int damage, float angle) { //受伤闪烁, 无敌状态 if (Invincible) @@ -1266,6 +1273,20 @@ } } + private void OnMeleeAttackAreaEntered(Area2D area) + { + var activeWeapon = WeaponPack.ActiveItem; + if (activeWeapon == null) + { + return; + } + + if (area is IHurt hurt) + { + HandlerCollision(hurt, activeWeapon); + } + } + /// /// 近战区域碰到敌人 /// @@ -1276,38 +1297,48 @@ { return; } - var activityObject = body.AsActivityObject(); - if (activityObject != null) + + if (body is IHurt hurt) { - if (activityObject is Role role) //攻击角色 + HandlerCollision(hurt, activeWeapon); + } + else if (body is Bullet bullet) //攻击子弹 + { + var attackLayer = bullet.AttackLayer; + if (CollisionWithMask(attackLayer)) //是攻击玩家的子弹 { - var damage = Utils.Random.RandomConfigRange(activeWeapon.Attribute.MeleeAttackHarmRange); - damage = RoleState.CalcDamage(damage); - - //击退 - if (role is not Player) //目标不是玩家才会触发击退 - { - var attr = IsAi ? activeWeapon.AiUseAttribute : activeWeapon.PlayerUseAttribute; - var repel = Utils.Random.RandomConfigRange(attr.MeleeAttackRepelRange); - var position = role.GlobalPosition - MountPoint.GlobalPosition; - var v2 = position.Normalized() * repel; - role.AddRepelForce(v2); - } - - role.CallDeferred(nameof(Hurt), this, damage, (role.GetCenterPosition() - GlobalPosition).Angle()); - } - else if (activityObject is Bullet bullet) //攻击子弹 - { - var attackLayer = bullet.AttackLayer; - if (CollisionWithMask(attackLayer)) //是攻击玩家的子弹 - { - bullet.OnPlayDisappearEffect(); - bullet.Destroy(); - } + bullet.OnPlayDisappearEffect(); + bullet.Destroy(); } } } - + + private void HandlerCollision(IHurt hurt, Weapon activeWeapon) + { + var damage = Utils.Random.RandomConfigRange(activeWeapon.Attribute.MeleeAttackHarmRange); + damage = RoleState.CalcDamage(damage); + + if (hurt is HurtArea hurtArea) + { + //击退 + if (hurtArea.ActivityObject is not Player) //目标不是玩家才会触发击退 + { + var attr = IsAi ? activeWeapon.AiUseAttribute : activeWeapon.PlayerUseAttribute; + var repel = Utils.Random.RandomConfigRange(attr.MeleeAttackRepelRange); + var position = hurtArea.ActivityObject.GlobalPosition - MountPoint.GlobalPosition; + var v2 = position.Normalized() * repel; + hurtArea.ActivityObject.AddRepelForce(v2); + } + + hurt.Hurt(this, damage, (hurtArea.ActivityObject.GetCenterPosition() - GlobalPosition).Angle()); + } + else if (hurt is Node2D node2D) + { + //造成伤害 + hurt.Hurt(this, damage, (node2D.GlobalPosition - GlobalPosition).Angle()); + } + } + protected override void OnDestroy() { //销毁道具 diff --git a/DungeonShooting_Godot/src/game/activity/role/SubLine.cs b/DungeonShooting_Godot/src/game/activity/role/SubLine.cs index 5f9dd84..4839685 100644 --- a/DungeonShooting_Godot/src/game/activity/role/SubLine.cs +++ b/DungeonShooting_Godot/src/game/activity/role/SubLine.cs @@ -28,7 +28,7 @@ AddChild(_line2D); _rayCast2D = new RayCast2D(); - _rayCast2D.CollisionMask = PhysicsLayer.Wall; + _rayCast2D.CollisionMask = PhysicsLayer.Wall | PhysicsLayer.Obstacle; AddChild(_rayCast2D); Master.WeaponPack.ChangeActiveItemEvent += OnChangeWeapon; diff --git a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs index 6e52346..37faa8e 100644 --- a/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs +++ b/DungeonShooting_Godot/src/game/activity/role/enemy/Enemy.cs @@ -134,7 +134,7 @@ StateController = AddComponent>(); - AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Player; + AttackLayer = PhysicsLayer.Obstacle | PhysicsLayer.Player; EnemyLayer = PhysicsLayer.Player; Camp = CampEnum.Camp2; diff --git a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs index 8366f99..b187a24 100644 --- a/DungeonShooting_Godot/src/game/activity/role/player/Player.cs +++ b/DungeonShooting_Godot/src/game/activity/role/player/Player.cs @@ -48,7 +48,7 @@ IsAi = false; StateController = AddComponent>(); - AttackLayer = PhysicsLayer.Wall | PhysicsLayer.Enemy; + AttackLayer = PhysicsLayer.Obstacle | PhysicsLayer.Enemy; EnemyLayer = EnemyLayer = PhysicsLayer.Enemy; Camp = CampEnum.Camp1; @@ -62,6 +62,12 @@ // debug用 // DebugSet(); + this.CallDelay(2.5f, () => + { + var o = Create(Ids.Id_treasure_box0001); + o.Position = Position; + o.PutDown(RoomLayerEnum.YSortLayer); + }); //注册状态机 StateController.Register(new PlayerIdleState()); @@ -80,8 +86,8 @@ RoleState.Acceleration = 3000; RoleState.Friction = 3000; RoleState.MoveSpeed = 500; - CollisionLayer = 0; - CollisionMask = 0; + CollisionLayer = PhysicsLayer.None; + CollisionMask = PhysicsLayer.None; GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); // this.CallDelay(0.5f, () => // { @@ -220,14 +226,14 @@ { //Hurt(1000, 0); Hp = 0; - Hurt(this, 1000, 0); + HurtHandler(this, 1000, 0); } else if (Input.IsKeyPressed(Key.O)) //测试用, 消灭房间内所有敌人 { var enemyList = AffiliationArea.FindIncludeItems(o => o.CollisionWithMask(PhysicsLayer.Enemy)); foreach (var enemy in enemyList) { - ((Enemy)enemy).Hurt(this, 1000, 0); + ((Enemy)enemy).HurtArea.Hurt(this, 1000, 0); } } // //测试用 diff --git a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs index 26be02e..4443bef 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/Weapon.cs @@ -214,7 +214,8 @@ private Vector2 _gripOffset; //碰撞器位置 - private Vector2 _collPoint; + private Vector2 _collPoint1; + private Vector2 _collPoint2; //换弹计时器 private float _reloadTimer = 0; @@ -294,10 +295,11 @@ AnimationPlayer.AnimationFinished += OnAnimationPlayerFinished; _gripPoint = AnimatedSprite.Position; _gripOffset = AnimatedSprite.Offset; - _collPoint = Collision.Position; + _collPoint1 = Collision.Position; + _collPoint2 = _collPoint1 - AnimatedSprite.Offset - AnimatedSprite.Position; AnimatedSprite.Position = Vector2.Zero; AnimatedSprite.Offset = Vector2.Zero; - Collision.Position = Vector2.Zero; + Collision.Position = _collPoint2; } /// @@ -326,8 +328,15 @@ CurrAmmo = Attribute.AmmoCapacity; //剩余弹药量 ResidueAmmo = Mathf.Min(Attribute.StandbyAmmoCapacity + CurrAmmo, Attribute.MaxAmmoCapacity) - CurrAmmo; - - ThrowCollisionSize = attribute.ThrowCollisionSize.AsVector2(); + + if (Collision.Shape is RectangleShape2D rectangleShape) + { + ThrowCollisionSize = rectangleShape.Size; + } + else + { + ThrowCollisionSize = new Vector2(-1, -1); + } } /// @@ -1916,7 +1925,7 @@ //精灵位置, 旋转中心点 AnimatedSprite.Position = Vector2.Zero; AnimatedSprite.Offset = Vector2.Zero; - Collision.Position = Vector2.Zero; + Collision.Position = _collPoint2; //清除 Ai 拾起标记 RemoveSign(SignNames.AiFindWeaponSign); //停止换弹 @@ -1946,7 +1955,7 @@ //Collision.Disabled = true; AnimatedSprite.Position = _gripPoint; AnimatedSprite.Offset = _gripOffset; - Collision.Position = _collPoint; + Collision.Position = _collPoint1; //修改层级 _tempLayer = CollisionLayer; CollisionLayer = PhysicsLayer.OnHand; diff --git a/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs b/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs index dcb13e3..207fbda 100644 --- a/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs +++ b/DungeonShooting_Godot/src/game/activity/weapon/knife/Knife.cs @@ -39,6 +39,7 @@ _hitArea.Monitoring = false; _hitArea.Monitorable = false; _hitArea.BodyEntered += OnBodyEntered; + _hitArea.AreaEntered += OnArea2dEntered; //禁用自动播放动画 IsAutoPlaySpriteFrames = false; @@ -123,56 +124,75 @@ private void OnBodyEntered(Node2D body) { - //Debug.Log("碰到物体: " + body.Name); - var activityObject = body.AsActivityObject(); - if (activityObject != null) + if (body is IHurt hurt) { - if (activityObject is Role role) //碰到角色 + HandlerCollision(hurt); + } + else if (body is Bullet bullet) //攻击子弹 + { + var attackLayer = bullet.AttackLayer; + if (TriggerRole != null && TriggerRole.CollisionWithMask(attackLayer)) //是攻击玩家的子弹 { - var damage = Utils.Random.RandomConfigRange(Attribute.Bullet.HarmRange); - //计算子弹造成的伤害 + //反弹子弹 + bullet.OnPlayDisappearEffect(); + bullet.MoveController.ScaleAllVelocity(-1); + bullet.Rotation += Mathf.Pi; + bullet.AttackLayer = TriggerRole.AttackLayer; + bullet.RefreshBulletColor(false); + } + } + } + + private void OnArea2dEntered(Area2D area) + { + if (area is IHurt hurt) + { + HandlerCollision(hurt); + } + } + + private void HandlerCollision(IHurt hurt) + { + var damage = Utils.Random.RandomConfigRange(Attribute.Bullet.HarmRange); + //计算子弹造成的伤害 + if (TriggerRole != null) + { + damage = TriggerRole.RoleState.CalcDamage(damage); + } + //击退 + var attr = GetUseAttribute(TriggerRole); + var repel = Utils.Random.RandomConfigRange(attr.Bullet.RepelRange); + //计算击退 + if (TriggerRole != null) + { + repel = TriggerRole.RoleState.CalcBulletRepel(repel); + } + + if (hurt is HurtArea hurtArea) + { + var globalPosition = GlobalPosition; + if (repel != 0 && hurtArea.ActivityObject is not Player) //不是玩家才能被击退 + { + Vector2 position; if (TriggerRole != null) { - damage = TriggerRole.RoleState.CalcDamage(damage); + position = hurtArea.ActivityObject.GlobalPosition - TriggerRole.MountPoint.GlobalPosition; } - //击退 - var attr = GetUseAttribute(TriggerRole); - var repel = Utils.Random.RandomConfigRange(attr.Bullet.RepelRange); - //计算击退 - if (TriggerRole != null) + else { - repel = TriggerRole.RoleState.CalcBulletRepel(repel); + position = hurtArea.ActivityObject.GlobalPosition - globalPosition; } - if (repel != 0) - { - Vector2 position; - if (TriggerRole != null) - { - position = role.GlobalPosition - TriggerRole.MountPoint.GlobalPosition; - } - else - { - position = role.GlobalPosition - GlobalPosition; - } - var v2 = position.Normalized() * repel; - role.AddRepelForce(v2); - } - - //造成伤害 - role.CallDeferred(nameof(Role.Hurt), TriggerRole, damage, (role.GetCenterPosition() - GlobalPosition).Angle()); + var v2 = position.Normalized() * repel; + hurtArea.ActivityObject.AddRepelForce(v2); } - else if (activityObject is Bullet bullet) //攻击子弹 - { - var attackLayer = bullet.AttackLayer; - if (TriggerRole != null && TriggerRole.CollisionWithMask(attackLayer)) //是攻击玩家的子弹 - { - //反弹子弹 - bullet.OnPlayDisappearEffect(); - bullet.MoveController.ScaleAllVelocity(-1); - bullet.Rotation += Mathf.Pi; - bullet.AttackLayer = TriggerRole.AttackLayer; - } - } + + //造成伤害 + hurt.Hurt(TriggerRole, damage, (hurtArea.ActivityObject.GetCenterPosition() - globalPosition).Angle()); + } + else if (hurt is Node2D node2D) + { + //造成伤害 + hurt.Hurt(TriggerRole, damage, (node2D.GlobalPosition - GlobalPosition).Angle()); } } } diff --git a/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs b/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs index bf3d97d..747cff3 100644 --- a/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs +++ b/DungeonShooting_Godot/src/game/data/property/AnimatorNames.cs @@ -90,4 +90,9 @@ /// 重置动画 /// public static readonly StringName Reset = "RESET"; + + /// + /// 打开宝箱 + /// + public static readonly StringName Open = "open"; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/data/property/PhysicsLayer.cs b/DungeonShooting_Godot/src/game/data/property/PhysicsLayer.cs index f181de2..d1675e4 100644 --- a/DungeonShooting_Godot/src/game/data/property/PhysicsLayer.cs +++ b/DungeonShooting_Godot/src/game/data/property/PhysicsLayer.cs @@ -43,4 +43,8 @@ /// 投抛中 /// public const uint Throwing = 0b100000000; + /// + /// 障碍物 + /// + public const uint Obstacle = 0b1000000000; } \ 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 67e9894..153224b 100644 --- a/DungeonShooting_Godot/src/game/manager/ResourcePath.cs +++ b/DungeonShooting_Godot/src/game/manager/ResourcePath.cs @@ -6,6 +6,58 @@ public const string default_bus_layout_tres = "res://default_bus_layout.tres"; public const string default_env_tres = "res://default_env.tres"; public const string icon_png = "res://icon.png"; + public const string build_windows_data_DungeonShooting_windows_x86_64_DungeonShooting_deps_json = "res://build/windows/data_DungeonShooting_windows_x86_64/DungeonShooting.deps.json"; + public const string build_windows_data_DungeonShooting_windows_x86_64_DungeonShooting_runtimeconfig_json = "res://build/windows/data_DungeonShooting_windows_x86_64/DungeonShooting.runtimeconfig.json"; + public const string build_windows_resource_map_tileMaps_GroupConfig_json = "res://build/windows/resource/map/tileMaps/GroupConfig.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle1_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle1/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle1_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle1/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle1_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle1/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle1_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle1/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle2_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle2/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle2_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle2/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle2_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle2/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle2_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle2/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle3_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle3/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle3_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle3/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle3_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle3/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle3_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle3/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle4_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle4/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle4_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle4/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle4_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle4/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle4_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle4/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle5_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle5/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle5_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle5/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle5_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle5/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_battle_Battle5_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/battle/Battle5/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_boss_Boss1_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/boss/Boss1/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_boss_Boss1_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/boss/Boss1/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_boss_Boss1_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/boss/Boss1/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_boss_Boss1_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/boss/Boss1/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_inlet_Start_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/inlet/Start/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_inlet_Start_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/inlet/Start/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_inlet_Start_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/inlet/Start/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_inlet_Start_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/inlet/Start/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_outlet_End1_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/outlet/End1/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_outlet_End1_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/outlet/End1/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_outlet_End1_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/outlet/End1/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_outlet_End1_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/outlet/End1/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_reward_Award1_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/reward/Award1/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_reward_Award1_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/reward/Award1/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_reward_Award1_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/reward/Award1/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_reward_Award1_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/reward/Award1/TileInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_shop_Shop1_Preinstall_json = "res://build/windows/resource/map/tileMaps/Test1/shop/Shop1/Preinstall.json"; + public const string build_windows_resource_map_tileMaps_Test1_shop_Shop1_Preview_png = "res://build/windows/resource/map/tileMaps/Test1/shop/Shop1/Preview.png"; + public const string build_windows_resource_map_tileMaps_Test1_shop_Shop1_RoomInfo_json = "res://build/windows/resource/map/tileMaps/Test1/shop/Shop1/RoomInfo.json"; + public const string build_windows_resource_map_tileMaps_Test1_shop_Shop1_TileInfo_json = "res://build/windows/resource/map/tileMaps/Test1/shop/Shop1/TileInfo.json"; + public const string build_windows_resource_map_tileSet_TileSetConfig_json = "res://build/windows/resource/map/tileSet/TileSetConfig.json"; + public const string build_windows_resource_map_tileSet_TileSet1_Main_png = "res://build/windows/resource/map/tileSet/TileSet1/Main.png"; + public const string build_windows_resource_map_tileSet_TileSet1_Test1_png = "res://build/windows/resource/map/tileSet/TileSet1/Test1.png"; + public const string build_windows_resource_map_tileSet_TileSet1_Test2_png = "res://build/windows/resource/map/tileSet/TileSet1/Test2.png"; + public const string build_windows_resource_map_tileSet_TileSet1_Test3_png = "res://build/windows/resource/map/tileSet/TileSet1/Test3.png"; + public const string build_windows_resource_map_tileSet_TileSet1_TileSet_json = "res://build/windows/resource/map/tileSet/TileSet1/TileSet.json"; + public const string build_windows_resource_map_tileSet_TileSet2_Main_png = "res://build/windows/resource/map/tileSet/TileSet2/Main.png"; + public const string build_windows_resource_map_tileSet_TileSet2_Test2_png = "res://build/windows/resource/map/tileSet/TileSet2/Test2.png"; + public const string build_windows_resource_map_tileSet_TileSet2_TileSet_json = "res://build/windows/resource/map/tileSet/TileSet2/TileSet.json"; public const string excelTool_bin_Release_net8_0_winx64_ExcelTool_deps_json = "res://excelTool/bin/Release/net8.0/win-x64/ExcelTool.deps.json"; public const string excelTool_bin_Release_net8_0_winx64_ExcelTool_runtimeconfig_json = "res://excelTool/bin/Release/net8.0/win-x64/ExcelTool.runtimeconfig.json"; public const string excelTool_obj_ExcelTool_csproj_nuget_dgspec_json = "res://excelTool/obj/ExcelTool.csproj.nuget.dgspec.json"; @@ -15,6 +67,7 @@ public const string excelTool_publish_winx64_ExcelTool_deps_json = "res://excelTool/publish/win-x64/ExcelTool.deps.json"; public const string excelTool_publish_winx64_ExcelTool_runtimeconfig_json = "res://excelTool/publish/win-x64/ExcelTool.runtimeconfig.json"; public const string prefab_Cursor_tscn = "res://prefab/Cursor.tscn"; + public const string prefab_box_TreasureBox0001_tscn = "res://prefab/box/TreasureBox0001.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_laser_Laser0002_tscn = "res://prefab/bullet/laser/Laser0002.tscn"; @@ -24,7 +77,9 @@ public const string prefab_bullet_normal_Bullet0004_tscn = "res://prefab/bullet/normal/Bullet0004.tscn"; public const string prefab_bullet_normal_Bullet0005_tscn = "res://prefab/bullet/normal/Bullet0005.tscn"; public const string prefab_bullet_normal_Bullet0006_tscn = "res://prefab/bullet/normal/Bullet0006.tscn"; + public const string prefab_currency_Gold1_tscn = "res://prefab/currency/Gold1.tscn"; public const string prefab_currency_Gold10_tscn = "res://prefab/currency/Gold10.tscn"; + public const string prefab_currency_Gold5_tscn = "res://prefab/currency/Gold5.tscn"; public const string prefab_currency_GoldTemplate_tscn = "res://prefab/currency/GoldTemplate.tscn"; public const string prefab_effect_Blood_tscn = "res://prefab/effect/Blood.tscn"; public const string prefab_effect_bullet_BulletDisappear0001_tscn = "res://prefab/effect/bullet/BulletDisappear0001.tscn"; @@ -118,6 +173,7 @@ public const string prefab_weapon_Weapon0008_tscn = "res://prefab/weapon/Weapon0008.tscn"; public const string prefab_weapon_Weapon0009_tscn = "res://prefab/weapon/Weapon0009.tscn"; public const string prefab_weapon_Weapon0010_tscn = "res://prefab/weapon/Weapon0010.tscn"; + public const string prefab_weapon_Weapon0013_tscn = "res://prefab/weapon/Weapon0013.tscn"; public const string prefab_weapon_WeaponTemplate_tscn = "res://prefab/weapon/WeaponTemplate.tscn"; public const string resource_config_ActivityBase_json = "res://resource/config/ActivityBase.json"; public const string resource_config_ActivityMaterial_json = "res://resource/config/ActivityMaterial.json"; @@ -166,6 +222,7 @@ public const string resource_sound_sfx_beLoaded_BeLoaded0016_ogg = "res://resource/sound/sfx/beLoaded/BeLoaded0016.ogg"; public const string resource_sound_sfx_beLoaded_BeLoaded0017_ogg = "res://resource/sound/sfx/beLoaded/BeLoaded0017.ogg"; public const string resource_sound_sfx_collision_Collision0001_ogg = "res://resource/sound/sfx/collision/Collision0001.ogg"; + public const string resource_sound_sfx_common_gold_ogg = "res://resource/sound/sfx/common/gold.ogg"; public const string resource_sound_sfx_explosion_Explosion0001_ogg = "res://resource/sound/sfx/explosion/Explosion0001.ogg"; public const string resource_sound_sfx_explosion_Explosion0002_ogg = "res://resource/sound/sfx/explosion/Explosion0002.ogg"; public const string resource_sound_sfx_explosion_Explosion0003_ogg = "res://resource/sound/sfx/explosion/Explosion0003.ogg"; @@ -202,6 +259,9 @@ public const string resource_sound_sfx_shooting_Shooting0010_ogg = "res://resource/sound/sfx/shooting/Shooting0010.ogg"; public const string resource_sound_sfx_shooting_Shooting0011_ogg = "res://resource/sound/sfx/shooting/Shooting0011.ogg"; public const string resource_sound_sfx_shooting_Shooting0012_ogg = "res://resource/sound/sfx/shooting/Shooting0012.ogg"; + public const string resource_sound_sfx_shooting_Shooting0013_ogg = "res://resource/sound/sfx/shooting/Shooting0013.ogg"; + public const string resource_sprite_box_TreasureBox0001_png = "res://resource/sprite/box/TreasureBox0001.png"; + public const string resource_sprite_box_TreasureBox0001_icon_png = "res://resource/sprite/box/TreasureBox0001_icon.png"; public const string resource_sprite_brush_Brush1_png = "res://resource/sprite/brush/Brush1.png"; public const string resource_sprite_brush_Brush2_png = "res://resource/sprite/brush/Brush2.png"; public const string resource_sprite_brush_Brush3_png = "res://resource/sprite/brush/Brush3.png"; @@ -230,6 +290,7 @@ public const string resource_sprite_currency_Gold_1_png = "res://resource/sprite/currency/Gold_1.png"; public const string resource_sprite_currency_Gold_10_png = "res://resource/sprite/currency/Gold_10.png"; public const string resource_sprite_currency_Gold_5_png = "res://resource/sprite/currency/Gold_5.png"; + public const string resource_sprite_currency_Gold_shadow_png = "res://resource/sprite/currency/Gold_shadow.png"; public const string resource_sprite_explode_Explode_circle0001_png = "res://resource/sprite/explode/Explode_circle0001.png"; public const string resource_sprite_explode_Explode_circle0002_png = "res://resource/sprite/explode/Explode_circle0002.png"; public const string resource_sprite_explode_Explode_circle0003_png = "res://resource/sprite/explode/Explode_circle0003.png"; @@ -462,6 +523,7 @@ public const string resource_spriteFrames_weapon_Weapon0008_tres = "res://resource/spriteFrames/weapon/Weapon0008.tres"; public const string resource_spriteFrames_weapon_Weapon0009_tres = "res://resource/spriteFrames/weapon/Weapon0009.tres"; public const string resource_spriteFrames_weapon_Weapon0010_tres = "res://resource/spriteFrames/weapon/Weapon0010.tres"; + public const string resource_spriteFrames_weapon_Weapon0013_tres = "res://resource/spriteFrames/weapon/Weapon0013.tres"; public const string resource_theme_mainTheme_tres = "res://resource/theme/mainTheme.tres"; public const string resource_theme_theme1_tres = "res://resource/theme/theme1.tres"; public const string scene_Main_tscn = "res://scene/Main.tscn";