Fixed an issue where players were blocked by a wall when entering a room.

修复玩家进入房间时被墙挡住的问题。
This commit is contained in:
Cold-Mint 2024-10-11 14:52:39 +08:00
parent 891986f706
commit e21d37edce
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
19 changed files with 195 additions and 82 deletions

View File

@ -35,9 +35,6 @@ log_register_item,注册物品类型{0}结果为{1},Registered item type {0}; re
log_error_when_open_item_regs_dir,尝试打开物品信息目录{0}时发生错误,错误代码:{1},"An error occurred when trying to open the item information directory {0}, error code: {1}",アイテム情報ディレクトリ{0}を開こうとしてエラーが発生しました、エラーコード:{1} log_error_when_open_item_regs_dir,尝试打开物品信息目录{0}时发生错误,错误代码:{1},"An error occurred when trying to open the item information directory {0}, error code: {1}",アイテム情報ディレクトリ{0}を開こうとしてエラーが発生しました、エラーコード:{1}
log_wrong_custom_arg,不匹配的参数:类型为{0}而值为{1},Mismatched parameter: type {0} and value {1},パラメータの不一致:型{0}と値{1}。 log_wrong_custom_arg,不匹配的参数:类型为{0}而值为{1},Mismatched parameter: type {0} and value {1},パラメータの不一致:型{0}と値{1}。
log_item_container_is_null,物品容器为空,Item container is null,アイテム・コンテナが空です log_item_container_is_null,物品容器为空,Item container is null,アイテム・コンテナが空です
log_item_has_no_owner,物品没有所有者,Item has no owner,アイテムに所有者がいません
log_no_damage_between_camps,没有阵营之间的伤害,No damage between camps,陣営間のダメージはありません
log_owner_of_the_item_is_not_character,物品的所有者不是角色,The owner of the item is not a character,アイテムの所有者はキャラクターではありません
log_try_to_open_state_machine_that_is_on,尝试打开处于运行状态的状态机。,Try to open a state machine that is on.,実行中のステートマシンを開こうとしています。 log_try_to_open_state_machine_that_is_on,尝试打开处于运行状态的状态机。,Try to open a state machine that is on.,実行中のステートマシンを開こうとしています。
log_state_machine_does_not_specify_context,状态机没有指定上下文。,The state machine does not specify a context.,ステートマシンはコンテキストを指定していません。 log_state_machine_does_not_specify_context,状态机没有指定上下文。,The state machine does not specify a context.,ステートマシンはコンテキストを指定していません。
log_state_processor_already_registered,状态处理器已经注册。,State processor already registered.,ステートプロセッサは既に登録されています。 log_state_processor_already_registered,状态处理器已经注册。,State processor already registered.,ステートプロセッサは既に登録されています。

1 id zh en ja
35 log_error_when_open_item_regs_dir 尝试打开物品信息目录{0}时发生错误,错误代码:{1} An error occurred when trying to open the item information directory {0}, error code: {1} アイテム情報ディレクトリ{0}を開こうとしてエラーが発生しました、エラーコード:{1}
36 log_wrong_custom_arg 不匹配的参数:类型为{0}而值为{1} Mismatched parameter: type {0} and value {1} パラメータの不一致:型{0}と値{1}。
37 log_item_container_is_null 物品容器为空 Item container is null アイテム・コンテナが空です
log_item_has_no_owner 物品没有所有者 Item has no owner アイテムに所有者がいません
log_no_damage_between_camps 没有阵营之间的伤害 No damage between camps 陣営間のダメージはありません
log_owner_of_the_item_is_not_character 物品的所有者不是角色 The owner of the item is not a character アイテムの所有者はキャラクターではありません
38 log_try_to_open_state_machine_that_is_on 尝试打开处于运行状态的状态机。 Try to open a state machine that is on. 実行中のステートマシンを開こうとしています。
39 log_state_machine_does_not_specify_context 状态机没有指定上下文。 The state machine does not specify a context. ステートマシンはコンテキストを指定していません。
40 log_state_processor_already_registered 状态处理器已经注册。 State processor already registered. ステートプロセッサは既に登録されています。

View File

@ -36,8 +36,10 @@ script = ExtResource("1_ubaid")
InitWeaponId = "staff_necromancy" InitWeaponId = "staff_necromancy"
CharacterName = "character_evil_crow" CharacterName = "character_evil_crow"
CanMutateAfterDeath = false CanMutateAfterDeath = false
_initialHp = null
MaxHp = 50 MaxHp = 50
CampId = "Mazoku" CampId = "Mazoku"
LootListId = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(2, 10) position = Vector2(2, 10)

View File

@ -30,8 +30,12 @@ platform_floor_layers = 4294967042
platform_wall_layers = 128 platform_wall_layers = 128
script = ExtResource("1_1dlls") script = ExtResource("1_1dlls")
_platformDetectionRayCast2DList = [NodePath("PlatformDetectionRayCast1"), NodePath("PlatformDetectionRayCast2"), NodePath("PlatformDetectionRayCast3")] _platformDetectionRayCast2DList = [NodePath("PlatformDetectionRayCast1"), NodePath("PlatformDetectionRayCast2"), NodePath("PlatformDetectionRayCast3")]
CharacterName = null
CanMutateAfterDeath = null
_initialHp = null
MaxHp = 32 MaxHp = 32
CampId = "Default" CampId = "Default"
LootListId = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CapsuleShape2D_bb8wt") shape = SubResource("CapsuleShape2D_bb8wt")

View File

@ -34,8 +34,10 @@ radius = 172.29
collision_layer = 64 collision_layer = 64
collision_mask = 38 collision_mask = 38
script = ExtResource("1_ubaid") script = ExtResource("1_ubaid")
InitWeaponId = null
CharacterName = "character_necromancer" CharacterName = "character_necromancer"
CanMutateAfterDeath = false CanMutateAfterDeath = false
_initialHp = null
MaxHp = 50 MaxHp = 50
CampId = "Mazoku" CampId = "Mazoku"
LootListId = "test" LootListId = "test"

View File

@ -92,6 +92,8 @@ collision_layer = 256
collision_mask = 160 collision_mask = 160
script = ExtResource("1_t1qdg") script = ExtResource("1_t1qdg")
Path = "res://prefab/ui/SpellEditorUI.tscn" Path = "res://prefab/ui/SpellEditorUI.tscn"
_initialDurability = null
_maxDurability = null
_furnitureName = "ui_spell_editor" _furnitureName = "ui_spell_editor"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]

View File

@ -13,7 +13,9 @@ radius = 52.6118
collision_layer = 256 collision_layer = 256
collision_mask = 160 collision_mask = 160
script = ExtResource("1_hfnuj") script = ExtResource("1_hfnuj")
_initialDurability = null
_maxDurability = 1 _maxDurability = 1
_furnitureName = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_vx4tg") shape = SubResource("RectangleShape2D_vx4tg")

View File

@ -14,6 +14,7 @@ collision_mask = 34
angular_damp = -1.0 angular_damp = -1.0
script = ExtResource("1_nydte") script = ExtResource("1_nydte")
FiringIntervalAsMillisecond = 1000 FiringIntervalAsMillisecond = 1000
_recoilStrength = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(1, 0.5) position = Vector2(1, 0.5)

View File

@ -13,6 +13,7 @@ collision_mask = 34
angular_damp = -1.0 angular_damp = -1.0
script = ExtResource("1_gg5rs") script = ExtResource("1_gg5rs")
_packedScenePath = "res://prefab/entitys/BlackenedAboriginalWarrior.tscn" _packedScenePath = "res://prefab/entitys/BlackenedAboriginalWarrior.tscn"
_projectilePath = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -0.5) position = Vector2(0, -0.5)

View File

@ -12,6 +12,10 @@ collision_layer = 8
collision_mask = 34 collision_mask = 34
angular_damp = -1.0 angular_damp = -1.0
script = ExtResource("1_cnhod") script = ExtResource("1_cnhod")
NumberOfProjectiles = null
RandomAngle = null
UnitRadian = null
_projectilePath = null
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, -0.5) position = Vector2(0, -0.5)

View File

@ -15,6 +15,9 @@ _maxDamage = 7
_minDamage = 3 _minDamage = 3
_damageType = 2 _damageType = 2
Speed = 500.0 Speed = 500.0
_enableBounce = null
_ignoreWall = null
_enableTracking = null
_targetDiesDestroyProjectile = true _targetDiesDestroyProjectile = true
_repelStrength = 2.5 _repelStrength = 2.5

View File

@ -55,6 +55,7 @@ shape = SubResource("RectangleShape2D_131jn")
[node name="Marker2D" type="Marker2D" parent="."] [node name="Marker2D" type="Marker2D" parent="."]
position = Vector2(237, 69) position = Vector2(237, 69)
script = ExtResource("2_7q101") script = ExtResource("2_7q101")
_resPathArray = null
metadata/ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" metadata/ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn"
[node name="NavigationRegion2D" type="NavigationRegion2D" parent="."] [node name="NavigationRegion2D" type="NavigationRegion2D" parent="."]

View File

@ -1,12 +1,9 @@
[gd_scene load_steps=9 format=4 uid="uid://c57cc1tyreybb"] [gd_scene load_steps=10 format=4 uid="uid://c57cc1tyreybb"]
[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"] [ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="1_rn2om"]
[ext_resource type="Texture2D" uid="uid://drw45jlmfo0su" path="res://sprites/light/White_100.png" id="2_1ctsj"] [ext_resource type="Texture2D" uid="uid://drw45jlmfo0su" path="res://sprites/light/White_100.png" id="2_1ctsj"]
[ext_resource type="Script" path="res://scripts/map/AiCharacterSpawn.cs" id="3_u5h84"] [ext_resource type="Script" path="res://scripts/map/AiCharacterSpawn.cs" id="3_u5h84"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
size = Vector2(728, 509)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o85u0"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_o85u0"]
size = Vector2(20, 48) size = Vector2(20, 48)
@ -22,15 +19,14 @@ polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3, 4), PackedInt32
outlines = Array[PackedVector2Array]([PackedVector2Array(35, 39, 36, 415, 0, 417, 3, 481, 733, 477, 729, 415, 706, 415, 701, 93, 734, 89, 731, 34)]) outlines = Array[PackedVector2Array]([PackedVector2Array(35, 39, 36, 415, 0, 417, 3, 481, 733, 477, 729, 415, 706, 415, 701, 93, 734, 89, 731, 34)])
source_geometry_group_name = &"navigation_polygon_source_group" source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
size = Vector2(728, 509)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kfmgh"]
size = Vector2(509, 407)
[node name="InitialRoom2" type="Node2D"] [node name="InitialRoom2" type="Node2D"]
[node name="RoomArea" type="Area2D" parent="."]
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
position = Vector2(365, 255.5)
shape = SubResource("RectangleShape2D_kiih8")
[node name="RoomSlotList" type="Node2D" parent="."] [node name="RoomSlotList" type="Node2D" parent="."]
[node name="Area2D" type="Area2D" parent="RoomSlotList"] [node name="Area2D" type="Area2D" parent="RoomSlotList"]
@ -94,3 +90,16 @@ _resPathArray = PackedStringArray("res://prefab/entitys/BlackenedAboriginalWarri
position = Vector2(545, 438) position = Vector2(545, 438)
script = ExtResource("3_u5h84") script = ExtResource("3_u5h84")
_resPathArray = PackedStringArray("res://prefab/entitys/BlackenedAboriginalWarrior.tscn", "", "res://prefab/entitys/BlackenedAboriginalWarrior.tscn", "") _resPathArray = PackedStringArray("res://prefab/entitys/BlackenedAboriginalWarrior.tscn", "", "res://prefab/entitys/BlackenedAboriginalWarrior.tscn", "")
[node name="RoomArea" type="Area2D" parent="."]
collision_mask = 0
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
position = Vector2(365, 255.5)
shape = SubResource("RectangleShape2D_kiih8")
[node name="SpawnArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpawnArea"]
position = Vector2(359.5, 246.5)
shape = SubResource("RectangleShape2D_kfmgh")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=4 uid="uid://du5ldsp613fei"] [gd_scene load_steps=12 format=4 uid="uid://du5ldsp613fei"]
[ext_resource type="Script" path="res://scripts/map/PlayerSpawn.cs" id="1_q04qt"] [ext_resource type="Script" path="res://scripts/map/PlayerSpawn.cs" id="1_q04qt"]
[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="2_5bnvh"] [ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="2_5bnvh"]
@ -8,9 +8,6 @@
[ext_resource type="Texture2D" uid="uid://cdjmfqp854utu" path="res://sprites/tutorials/spellEditor.png" id="6_dbg76"] [ext_resource type="Texture2D" uid="uid://cdjmfqp854utu" path="res://sprites/tutorials/spellEditor.png" id="6_dbg76"]
[ext_resource type="PackedScene" uid="uid://dld3qttpsdjpe" path="res://prefab/furnitures/WoodenBox.tscn" id="7_jybe6"] [ext_resource type="PackedScene" uid="uid://dld3qttpsdjpe" path="res://prefab/furnitures/WoodenBox.tscn" id="7_jybe6"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
size = Vector2(758, 342)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jxmys"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_jxmys"]
size = Vector2(23, 54.875) size = Vector2(23, 54.875)
@ -20,14 +17,14 @@ polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Arr
outlines = Array[PackedVector2Array]([PackedVector2Array(36, 32, 731, 32, 733, 258, 766, 257, 767, 316, 35, 317)]) outlines = Array[PackedVector2Array]([PackedVector2Array(36, 32, 731, 32, 733, 258, 766, 257, 767, 316, 35, 317)])
source_geometry_group_name = &"navigation_polygon_source_group" source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
size = Vector2(758, 342)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_u54ac"]
size = Vector2(658, 284)
[node name="InitialRoom3" type="Node2D"] [node name="InitialRoom3" type="Node2D"]
[node name="RoomArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
position = Vector2(383, 175)
shape = SubResource("RectangleShape2D_kiih8")
[node name="RoomSlotList" type="Node2D" parent="."] [node name="RoomSlotList" type="Node2D" parent="."]
[node name="Slot1" type="Area2D" parent="RoomSlotList"] [node name="Slot1" type="Area2D" parent="RoomSlotList"]
@ -114,3 +111,15 @@ _itemIdList = PackedStringArray("necromancy")
position = Vector2(100, 250) position = Vector2(100, 250)
script = ExtResource("4_6ihp7") script = ExtResource("4_6ihp7")
_itemIdList = PackedStringArray("beginner_staff") _itemIdList = PackedStringArray("beginner_staff")
[node name="RoomArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
position = Vector2(383, 175)
shape = SubResource("RectangleShape2D_kiih8")
[node name="SpawnArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpawnArea"]
position = Vector2(405, 178)
shape = SubResource("RectangleShape2D_u54ac")

View File

@ -1,4 +1,4 @@
[gd_scene load_steps=11 format=4 uid="uid://dodxp4mm0emj3"] [gd_scene load_steps=12 format=4 uid="uid://dodxp4mm0emj3"]
[ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="2_k54gk"] [ext_resource type="TileSet" uid="uid://c4wpp12rr44hi" path="res://tileSets/dungeon.tres" id="2_k54gk"]
[ext_resource type="Texture2D" uid="uid://drw45jlmfo0su" path="res://sprites/light/White_100.png" id="3_d6t7n"] [ext_resource type="Texture2D" uid="uid://drw45jlmfo0su" path="res://sprites/light/White_100.png" id="3_d6t7n"]
@ -7,9 +7,6 @@
[ext_resource type="PackedScene" uid="uid://djsh4unystlf0" path="res://prefab/furnitures/SpellEditor.tscn" id="5_ll4ng"] [ext_resource type="PackedScene" uid="uid://djsh4unystlf0" path="res://prefab/furnitures/SpellEditor.tscn" id="5_ll4ng"]
[ext_resource type="Texture2D" uid="uid://kgodvs3ilxbs" path="res://sprites/tutorials/tripleShotSpell.png" id="6_2qcf3"] [ext_resource type="Texture2D" uid="uid://kgodvs3ilxbs" path="res://sprites/tutorials/tripleShotSpell.png" id="6_2qcf3"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
size = Vector2(755, 340)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jxmys"] [sub_resource type="RectangleShape2D" id="RectangleShape2D_jxmys"]
size = Vector2(23, 54.875) size = Vector2(23, 54.875)
@ -22,14 +19,14 @@ polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Arr
outlines = Array[PackedVector2Array]([PackedVector2Array(33, 34, 32, 256, 0, 259, 0, 320, 416, 319, 415, 166, 447, 162, 448, 321, 764, 319, 766, 259, 738, 259, 736, 36, 609, 35, 611, 255, 573, 256, 575, 33)]) outlines = Array[PackedVector2Array]([PackedVector2Array(33, 34, 32, 256, 0, 259, 0, 320, 416, 319, 415, 166, 447, 162, 448, 321, 764, 319, 766, 259, 738, 259, 736, 36, 609, 35, 611, 255, 573, 256, 575, 33)])
source_geometry_group_name = &"navigation_polygon_source_group" source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"]
size = Vector2(755, 340)
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o4dgl"]
size = Vector2(706, 289)
[node name="InitialRoom" type="Node2D"] [node name="InitialRoom" type="Node2D"]
[node name="RoomArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
position = Vector2(383.5, 176)
shape = SubResource("RectangleShape2D_kiih8")
[node name="RoomSlotList" type="Node2D" parent="."] [node name="RoomSlotList" type="Node2D" parent="."]
[node name="Slot1" type="Area2D" parent="RoomSlotList"] [node name="Slot1" type="Area2D" parent="RoomSlotList"]
@ -125,6 +122,18 @@ position = Vector2(473, 285)
position = Vector2(637, 85) position = Vector2(637, 85)
texture = ExtResource("6_2qcf3") texture = ExtResource("6_2qcf3")
[node name="RoomArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"]
position = Vector2(383.5, 176)
shape = SubResource("RectangleShape2D_kiih8")
[node name="SpawnArea" type="Area2D" parent="."]
[node name="CollisionShape2D" type="CollisionShape2D" parent="SpawnArea"]
position = Vector2(385, 177.5)
shape = SubResource("RectangleShape2D_o4dgl")
[node name="AutoSpawn" type="Node2D" parent="."] [node name="AutoSpawn" type="Node2D" parent="."]
[node name="x3" type="Marker2D" parent="AutoSpawn"] [node name="x3" type="Marker2D" parent="AutoSpawn"]

View File

@ -13,6 +13,7 @@ collision_layer = 8
collision_mask = 34 collision_mask = 34
script = ExtResource("1_w4b6p") script = ExtResource("1_w4b6p")
_numberSlots = 5 _numberSlots = 5
_spellList = null
_fireSequentially = true _fireSequentially = true
FiringIntervalAsMillisecond = 300 FiringIntervalAsMillisecond = 300
_recoilStrength = 5 _recoilStrength = 5

View File

@ -15,6 +15,10 @@ collision_layer = 8
collision_mask = 34 collision_mask = 34
angular_damp = -1.0 angular_damp = -1.0
script = ExtResource("1_snmy1") script = ExtResource("1_snmy1")
_maxDamage = null
_minDamage = null
FiringIntervalAsMillisecond = null
_recoilStrength = null
[node name="StaffOfTheUndead2" type="Sprite2D" parent="."] [node name="StaffOfTheUndead2" type="Sprite2D" parent="."]
position = Vector2(30, 0) position = Vector2(30, 0)

View File

@ -127,4 +127,39 @@ public static class GameSceneDepend
/// <para>鼠标是否悬浮在物品槽上</para> /// <para>鼠标是否悬浮在物品槽上</para>
/// </summary> /// </summary>
public static bool IsMouseOverItemSlotNode; public static bool IsMouseOverItemSlotNode;
/// <summary>
/// <para>ShowMiniMap</para>
/// <para>显示迷你地图</para>
/// </summary>
public static void ShowMiniMap()
{
if (MiniMap == null)
{
return;
}
if (MiniMap.Visible)
{
return;
}
MiniMapAnimationPlayer?.Play(name: "show");
}
/// <summary>
/// <para>HideMiniMap</para>
/// <para>隐藏迷你地图</para>
/// </summary>
public static void HideMiniMap()
{
if (MiniMap == null)
{
return;
}
if (MiniMap.Visible)
{
MiniMapAnimationPlayer?.Play(name: "hide");
}
}
} }

View File

@ -23,11 +23,22 @@ public class Room
private RoomSlot?[]? _roomSlots; private RoomSlot?[]? _roomSlots;
private List<TileMapLayer>? _tileMapLayers; private List<TileMapLayer>? _tileMapLayers;
private Area2D? _area2D; private Area2D? _roomArea2D;
private Area2D? _spawnArea2D;
private PointLight2D? _pointLight2D; private PointLight2D? _pointLight2D;
private CollisionShape2D? _collisionShape2D; private CollisionShape2D? _collisionShape2D;
private bool _hasPlayer; private bool _hasPlayer;
private readonly List<CharacterTemplate> _characterTemplateList = []; /// <summary>
/// <para>All the characters in the room</para>
/// <para>房间内的所有角色</para>
/// </summary>
private readonly List<CharacterTemplate> _allCharacter = [];
/// <summary>
/// <para>A character automatically generated by the room</para>
/// <para>由房间自动生成的角色</para>
/// </summary>
private readonly List<CharacterTemplate> _spawnedCharacter = [];
/// <summary> /// <summary>
/// <para>When the player first enters the room, all <see cref="ISpawnMarker"/> nodes under this node are executed</para> /// <para>When the player first enters the room, all <see cref="ISpawnMarker"/> nodes under this node are executed</para>
@ -35,14 +46,18 @@ public class Room
/// </summary> /// </summary>
private Node2D? _autoSpawn; private Node2D? _autoSpawn;
/// <summary>
/// <para>hasSpawnedEntity</para>
/// <para>是否生成过实体</para>
/// </summary>
private bool _hasSpawnedEntity;
/// <summary> /// <summary>
/// <para>Current generated wave number</para> /// <para>Current generated wave number</para>
/// <para>当前生成波数</para> /// <para>当前生成波数</para>
/// </summary> /// </summary>
private int _currentWaveNumber; private int _currentWaveNumber;
private readonly List<CharacterTemplate> _spawnedCharacterTemplateList = [];
/// <summary> /// <summary>
/// <para>Max generated wave number</para> /// <para>Max generated wave number</para>
/// <para>最大的生成波数</para> /// <para>最大的生成波数</para>
@ -156,8 +171,8 @@ public class Room
private void ShowAllCharacterTemplate() private void ShowAllCharacterTemplate()
{ {
LogCat.LogWithFormat("show_all_node", LogCat.LogLabel.Room, LogCat.UploadFormat, LogCat.LogWithFormat("show_all_node", LogCat.LogLabel.Room, LogCat.UploadFormat,
_characterTemplateList.Count); _allCharacter.Count);
foreach (var characterTemplate in _characterTemplateList) foreach (var characterTemplate in _allCharacter)
{ {
characterTemplate.Show(); characterTemplate.Show();
} }
@ -170,8 +185,8 @@ public class Room
private void HideAllCharacterTemplate() private void HideAllCharacterTemplate()
{ {
LogCat.LogWithFormat("hide_all_node", LogCat.LogLabel.Room, LogCat.UploadFormat, LogCat.LogWithFormat("hide_all_node", LogCat.LogLabel.Room, LogCat.UploadFormat,
_characterTemplateList.Count); _allCharacter.Count);
foreach (var characterTemplate in _characterTemplateList) foreach (var characterTemplate in _allCharacter)
{ {
characterTemplate.Hide(); characterTemplate.Hide();
} }
@ -182,7 +197,7 @@ public class Room
/// </summary> /// </summary>
private void SpawnEnemyWave() private void SpawnEnemyWave()
{ {
if (PlayerRoomVisitCount != 1 || _autoSpawn == null) if (_autoSpawn == null)
{ {
return; return;
} }
@ -191,10 +206,7 @@ public class Room
//Complete all waves. //Complete all waves.
//完成所有的波次。 //完成所有的波次。
ClearAllMatchedBarriers(); ClearAllMatchedBarriers();
if (GameSceneDepend.MiniMap != null && !GameSceneDepend.MiniMap.Visible) GameSceneDepend.ShowMiniMap();
{
GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "show");
}
return; return;
} }
NodeUtils.ForEachNode<ISpawnMarker>(_autoSpawn, marker => NodeUtils.ForEachNode<ISpawnMarker>(_autoSpawn, marker =>
@ -205,11 +217,11 @@ public class Room
//The maximum wave number should be the maximum wave number produced by living organisms.For now, the player's condition for the next step is to kill all enemies. //The maximum wave number should be the maximum wave number produced by living organisms.For now, the player's condition for the next step is to kill all enemies.
//最大波数应该是生物生成的最大波数。就目前而言,玩家进入下一步的条件是杀死所有敌人。 //最大波数应该是生物生成的最大波数。就目前而言,玩家进入下一步的条件是杀死所有敌人。
_maxWaveNumber = Math.Max(_maxWaveNumber, marker.GetMaxWaveNumber()); _maxWaveNumber = Math.Max(_maxWaveNumber, marker.GetMaxWaveNumber());
_spawnedCharacterTemplateList.Add(characterTemplate); _spawnedCharacter.Add(characterTemplate);
characterTemplate.TreeExited += () => characterTemplate.TreeExited += () =>
{ {
_spawnedCharacterTemplateList.Remove(characterTemplate); _spawnedCharacter.Remove(characterTemplate);
if (_spawnedCharacterTemplateList.Count == 0) if (_spawnedCharacter.Count == 0)
{ {
//All the creatures they summoned are dead. //All the creatures they summoned are dead.
//召唤的生物全死了。 //召唤的生物全死了。
@ -220,16 +232,14 @@ public class Room
} }
return false; return false;
}); });
if (_spawnedCharacterTemplateList.Count > 0) if (_spawnedCharacter.Count > 0)
{ {
if (GameSceneDepend.MiniMap != null && GameSceneDepend.MiniMap.Visible) GameSceneDepend.HideMiniMap();
{
GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "hide");
}
AddTimer(PlaceBarriersInAllSlots); AddTimer(PlaceBarriersInAllSlots);
} }
} }
/// <summary> /// <summary>
/// <para>Add a timer node to handle some events</para> /// <para>Add a timer node to handle some events</para>
/// <para>添加定时器节点处理一些事件</para> /// <para>添加定时器节点处理一些事件</para>
@ -268,10 +278,9 @@ public class Room
if (node is Player player) if (node is Player player)
{ {
_characterTemplateList.Add(player); _allCharacter.Add(player);
_hasPlayer = true; _hasPlayer = true;
PlayerRoomVisitCount++; PlayerRoomVisitCount++;
SpawnEnemyWave();
//The player enters the room, opening up their view. //The player enters the room, opening up their view.
//玩家进入了房间,开放视野。 //玩家进入了房间,开放视野。
if (_pointLight2D != null) if (_pointLight2D != null)
@ -279,7 +288,7 @@ public class Room
_pointLight2D.Show(); _pointLight2D.Show();
_pointLight2D.Texture = AssetHolder.White100; _pointLight2D.Texture = AssetHolder.White100;
} }
GameSceneDepend.ShowMiniMap();
GameSceneDepend.MiniMap?.ShowRoomPreview(this); GameSceneDepend.MiniMap?.ShowRoomPreview(this);
ShowAllCharacterTemplate(); ShowAllCharacterTemplate();
} }
@ -294,7 +303,7 @@ public class Room
characterTemplate.Hide(); characterTemplate.Hide();
} }
_characterTemplateList.Add(characterTemplate); _allCharacter.Add(characterTemplate);
} }
if (string.IsNullOrEmpty(EnterRoomEventHandlerId)) if (string.IsNullOrEmpty(EnterRoomEventHandlerId))
@ -325,7 +334,7 @@ public class Room
{ {
//The player leaves the room, hiding the view. //The player leaves the room, hiding the view.
//玩家离开了房间,隐藏视野。 //玩家离开了房间,隐藏视野。
_characterTemplateList.Remove(player); _allCharacter.Remove(player);
_hasPlayer = false; _hasPlayer = false;
if (_pointLight2D != null) if (_pointLight2D != null)
{ {
@ -347,7 +356,7 @@ public class Room
} }
else if (node is CharacterTemplate characterTemplate && characterTemplate.Visible) else if (node is CharacterTemplate characterTemplate && characterTemplate.Visible)
{ {
_characterTemplateList.Remove(characterTemplate); _allCharacter.Remove(characterTemplate);
} }
if (string.IsNullOrEmpty(ExitRoomEventHandlerId)) if (string.IsNullOrEmpty(ExitRoomEventHandlerId))
@ -369,10 +378,10 @@ public class Room
set => _collisionShape2D = value; set => _collisionShape2D = value;
} }
public Area2D? Area2D public Area2D? RoomArea2D
{ {
get => _area2D; get => _roomArea2D;
set => _area2D = value; set => _roomArea2D = value;
} }
public PackedScene? RoomScene public PackedScene? RoomScene
@ -411,17 +420,21 @@ public class Room
_tileMapLayers.Add(node); _tileMapLayers.Add(node);
return false; return false;
}); });
_area2D = rootNode.GetNode<Area2D>("RoomArea"); _roomArea2D = rootNode.GetNode<Area2D>("RoomArea");
_area2D.Monitoring = true; _roomArea2D.Monitoring = true;
_area2D.SetCollisionLayerValue(Config.LayerNumber.RoomArea, true); _roomArea2D.SetCollisionLayerValue(Config.LayerNumber.RoomArea, true);
//Sets the collision layer that can be detected in the current room area. _roomArea2D.SetCollisionMaskValue(Config.LayerNumber.Player, true);
//设置当前房间区域可检测到的碰撞层。 _roomArea2D.SetCollisionMaskValue(Config.LayerNumber.Mob, true);
_area2D.SetCollisionMaskValue(Config.LayerNumber.Player, true); _roomArea2D.BodyExited += OnExitRoom;
_area2D.SetCollisionMaskValue(Config.LayerNumber.Mob, true); _roomArea2D.BodyEntered += OnEnterRoom;
_area2D.BodyExited += OnExitRoom; _spawnArea2D = rootNode.GetNodeOrNull<Area2D>("SpawnArea");
_area2D.BodyEntered += OnEnterRoom; if (_spawnArea2D != null)
_collisionShape2D = _area2D.GetChild<CollisionShape2D>(0); {
_roomSlots = GetRoomSlots(GetTileMapLayer(Config.TileMapLayerName.Ground), _area2D, _spawnArea2D.SetCollisionMaskValue(Config.LayerNumber.Player, true);
_spawnArea2D.BodyEntered += OnEnterSpawnArea;
}
_collisionShape2D = _roomArea2D.GetChild<CollisionShape2D>(0);
_roomSlots = GetRoomSlots(GetTileMapLayer(Config.TileMapLayerName.Ground), _roomArea2D,
rootNode.GetNode<Node2D>("RoomSlotList")); rootNode.GetNode<Node2D>("RoomSlotList"));
_pointLight2D = rootNode.GetNodeOrNull<PointLight2D>("PointLight2D"); _pointLight2D = rootNode.GetNodeOrNull<PointLight2D>("PointLight2D");
if (_pointLight2D != null) if (_pointLight2D != null)
@ -431,6 +444,20 @@ public class Room
_autoSpawn = rootNode.GetNodeOrNull<Node2D>("AutoSpawn"); _autoSpawn = rootNode.GetNodeOrNull<Node2D>("AutoSpawn");
} }
private void OnEnterSpawnArea(Node2D body)
{
if (_hasSpawnedEntity)
{
return;
}
if (body is not Player)
{
return;
}
SpawnEnemyWave();
_hasSpawnedEntity = true;
}
public Node2D? RootNode => _rootNode; public Node2D? RootNode => _rootNode;
public RoomSlot?[]? RoomSlots => _roomSlots; public RoomSlot?[]? RoomSlots => _roomSlots;

View File

@ -436,7 +436,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
{ {
//Ignore yourself when detecting room overlap //Ignore yourself when detecting room overlap
//检测房间重叠时应忽略自身 //检测房间重叠时应忽略自身
_selfArea2D = newRoom.Area2D; _selfArea2D = newRoom.RoomArea2D;
_measuringArea2D.Position = result; _measuringArea2D.Position = result;
_measuringCollisionShape2D.Shape = newRoom.RoomCollisionShape2D.Shape; _measuringCollisionShape2D.Shape = newRoom.RoomCollisionShape2D.Shape;
//Calculate the offset of the shape. //Calculate the offset of the shape.