From e21d37edce5a76e2db7789deef83d9f91ee36abf Mon Sep 17 00:00:00 2001 From: Cold-Mint Date: Fri, 11 Oct 2024 14:52:39 +0800 Subject: [PATCH] =?UTF-8?q?Fixed=20an=20issue=20where=20players=20were=20b?= =?UTF-8?q?locked=20by=20a=20wall=20when=20entering=20a=20room.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=8E=A9=E5=AE=B6=E8=BF=9B=E5=85=A5=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E6=97=B6=E8=A2=AB=E5=A2=99=E6=8C=A1=E4=BD=8F=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- locals/Log.csv | 3 - .../entitys/BlackenedAboriginalWarrior.tscn | 2 + prefab/entitys/Character.tscn | 4 + prefab/entitys/DelivererOfDarkMagic.tscn | 2 + prefab/furnitures/SpellEditor.tscn | 2 + prefab/furnitures/WoodenBox.tscn | 2 + prefab/items/resignationCertificate.tscn | 1 + prefab/magics/curse.tscn | 1 + prefab/magics/x3.tscn | 4 + prefab/projectile/curseOfTheUndead.tscn | 3 + .../dungeon/horizontalCorridorWithSewer.tscn | 1 + prefab/roomTemplates/dungeon/utilityRoom.tscn | 31 +++-- .../roomTemplates/tutorials/spellEditor.tscn | 29 +++-- .../tutorials/tripleShotSpell.tscn | 29 +++-- prefab/weapons/BeginnerStaff.tscn | 1 + prefab/weapons/IronAxe.tscn | 4 + scripts/GameSceneDepend.cs | 47 +++++++- scripts/map/room/Room.cs | 109 +++++++++++------- .../PatchworkRoomPlacementStrategy.cs | 2 +- 19 files changed, 195 insertions(+), 82 deletions(-) diff --git a/locals/Log.csv b/locals/Log.csv index 7f6d04c..dd06ab6 100644 --- a/locals/Log.csv +++ b/locals/Log.csv @@ -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_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_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_state_machine_does_not_specify_context,状态机没有指定上下文。,The state machine does not specify a context.,ステートマシンはコンテキストを指定していません。 log_state_processor_already_registered,状态处理器已经注册。,State processor already registered.,ステートプロセッサは既に登録されています。 diff --git a/prefab/entitys/BlackenedAboriginalWarrior.tscn b/prefab/entitys/BlackenedAboriginalWarrior.tscn index 40f0c81..ef83258 100644 --- a/prefab/entitys/BlackenedAboriginalWarrior.tscn +++ b/prefab/entitys/BlackenedAboriginalWarrior.tscn @@ -36,8 +36,10 @@ script = ExtResource("1_ubaid") InitWeaponId = "staff_necromancy" CharacterName = "character_evil_crow" CanMutateAfterDeath = false +_initialHp = null MaxHp = 50 CampId = "Mazoku" +LootListId = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(2, 10) diff --git a/prefab/entitys/Character.tscn b/prefab/entitys/Character.tscn index f18d714..cf7237f 100644 --- a/prefab/entitys/Character.tscn +++ b/prefab/entitys/Character.tscn @@ -30,8 +30,12 @@ platform_floor_layers = 4294967042 platform_wall_layers = 128 script = ExtResource("1_1dlls") _platformDetectionRayCast2DList = [NodePath("PlatformDetectionRayCast1"), NodePath("PlatformDetectionRayCast2"), NodePath("PlatformDetectionRayCast3")] +CharacterName = null +CanMutateAfterDeath = null +_initialHp = null MaxHp = 32 CampId = "Default" +LootListId = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("CapsuleShape2D_bb8wt") diff --git a/prefab/entitys/DelivererOfDarkMagic.tscn b/prefab/entitys/DelivererOfDarkMagic.tscn index e575760..b433ee7 100644 --- a/prefab/entitys/DelivererOfDarkMagic.tscn +++ b/prefab/entitys/DelivererOfDarkMagic.tscn @@ -34,8 +34,10 @@ radius = 172.29 collision_layer = 64 collision_mask = 38 script = ExtResource("1_ubaid") +InitWeaponId = null CharacterName = "character_necromancer" CanMutateAfterDeath = false +_initialHp = null MaxHp = 50 CampId = "Mazoku" LootListId = "test" diff --git a/prefab/furnitures/SpellEditor.tscn b/prefab/furnitures/SpellEditor.tscn index 4c1d8d0..00dae2c 100644 --- a/prefab/furnitures/SpellEditor.tscn +++ b/prefab/furnitures/SpellEditor.tscn @@ -92,6 +92,8 @@ collision_layer = 256 collision_mask = 160 script = ExtResource("1_t1qdg") Path = "res://prefab/ui/SpellEditorUI.tscn" +_initialDurability = null +_maxDurability = null _furnitureName = "ui_spell_editor" [node name="CollisionShape2D" type="CollisionShape2D" parent="."] diff --git a/prefab/furnitures/WoodenBox.tscn b/prefab/furnitures/WoodenBox.tscn index 70d6f12..0247b97 100644 --- a/prefab/furnitures/WoodenBox.tscn +++ b/prefab/furnitures/WoodenBox.tscn @@ -13,7 +13,9 @@ radius = 52.6118 collision_layer = 256 collision_mask = 160 script = ExtResource("1_hfnuj") +_initialDurability = null _maxDurability = 1 +_furnitureName = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] shape = SubResource("RectangleShape2D_vx4tg") diff --git a/prefab/items/resignationCertificate.tscn b/prefab/items/resignationCertificate.tscn index b5a016f..ff34cb8 100644 --- a/prefab/items/resignationCertificate.tscn +++ b/prefab/items/resignationCertificate.tscn @@ -14,6 +14,7 @@ collision_mask = 34 angular_damp = -1.0 script = ExtResource("1_nydte") FiringIntervalAsMillisecond = 1000 +_recoilStrength = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(1, 0.5) diff --git a/prefab/magics/curse.tscn b/prefab/magics/curse.tscn index 8986580..42615fe 100644 --- a/prefab/magics/curse.tscn +++ b/prefab/magics/curse.tscn @@ -13,6 +13,7 @@ collision_mask = 34 angular_damp = -1.0 script = ExtResource("1_gg5rs") _packedScenePath = "res://prefab/entitys/BlackenedAboriginalWarrior.tscn" +_projectilePath = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, -0.5) diff --git a/prefab/magics/x3.tscn b/prefab/magics/x3.tscn index 1f23761..3e68c74 100644 --- a/prefab/magics/x3.tscn +++ b/prefab/magics/x3.tscn @@ -12,6 +12,10 @@ collision_layer = 8 collision_mask = 34 angular_damp = -1.0 script = ExtResource("1_cnhod") +NumberOfProjectiles = null +RandomAngle = null +UnitRadian = null +_projectilePath = null [node name="CollisionShape2D" type="CollisionShape2D" parent="."] position = Vector2(0, -0.5) diff --git a/prefab/projectile/curseOfTheUndead.tscn b/prefab/projectile/curseOfTheUndead.tscn index 8aee10b..f008090 100644 --- a/prefab/projectile/curseOfTheUndead.tscn +++ b/prefab/projectile/curseOfTheUndead.tscn @@ -15,6 +15,9 @@ _maxDamage = 7 _minDamage = 3 _damageType = 2 Speed = 500.0 +_enableBounce = null +_ignoreWall = null +_enableTracking = null _targetDiesDestroyProjectile = true _repelStrength = 2.5 diff --git a/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn b/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn index 99600f1..34ab51b 100644 --- a/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn +++ b/prefab/roomTemplates/dungeon/horizontalCorridorWithSewer.tscn @@ -55,6 +55,7 @@ shape = SubResource("RectangleShape2D_131jn") [node name="Marker2D" type="Marker2D" parent="."] position = Vector2(237, 69) script = ExtResource("2_7q101") +_resPathArray = null metadata/ResPath = "res://prefab/entitys/DelivererOfDarkMagic.tscn" [node name="NavigationRegion2D" type="NavigationRegion2D" parent="."] diff --git a/prefab/roomTemplates/dungeon/utilityRoom.tscn b/prefab/roomTemplates/dungeon/utilityRoom.tscn index fbb9f64..8b39347 100644 --- a/prefab/roomTemplates/dungeon/utilityRoom.tscn +++ b/prefab/roomTemplates/dungeon/utilityRoom.tscn @@ -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="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"] -[sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] -size = Vector2(728, 509) - [sub_resource type="RectangleShape2D" id="RectangleShape2D_o85u0"] 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)]) 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="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="Area2D" type="Area2D" parent="RoomSlotList"] @@ -94,3 +90,16 @@ _resPathArray = PackedStringArray("res://prefab/entitys/BlackenedAboriginalWarri position = Vector2(545, 438) script = ExtResource("3_u5h84") _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") diff --git a/prefab/roomTemplates/tutorials/spellEditor.tscn b/prefab/roomTemplates/tutorials/spellEditor.tscn index 3dacf61..75b9d54 100644 --- a/prefab/roomTemplates/tutorials/spellEditor.tscn +++ b/prefab/roomTemplates/tutorials/spellEditor.tscn @@ -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="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="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"] 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)]) 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="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="Slot1" type="Area2D" parent="RoomSlotList"] @@ -114,3 +111,15 @@ _itemIdList = PackedStringArray("necromancy") position = Vector2(100, 250) script = ExtResource("4_6ihp7") _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") diff --git a/prefab/roomTemplates/tutorials/tripleShotSpell.tscn b/prefab/roomTemplates/tutorials/tripleShotSpell.tscn index 9ef8d0a..b0075db 100644 --- a/prefab/roomTemplates/tutorials/tripleShotSpell.tscn +++ b/prefab/roomTemplates/tutorials/tripleShotSpell.tscn @@ -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="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="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"] 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)]) 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="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="Slot1" type="Area2D" parent="RoomSlotList"] @@ -125,6 +122,18 @@ position = Vector2(473, 285) position = Vector2(637, 85) 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="x3" type="Marker2D" parent="AutoSpawn"] diff --git a/prefab/weapons/BeginnerStaff.tscn b/prefab/weapons/BeginnerStaff.tscn index d6956b5..a9b6d04 100644 --- a/prefab/weapons/BeginnerStaff.tscn +++ b/prefab/weapons/BeginnerStaff.tscn @@ -13,6 +13,7 @@ collision_layer = 8 collision_mask = 34 script = ExtResource("1_w4b6p") _numberSlots = 5 +_spellList = null _fireSequentially = true FiringIntervalAsMillisecond = 300 _recoilStrength = 5 diff --git a/prefab/weapons/IronAxe.tscn b/prefab/weapons/IronAxe.tscn index 9922c3f..ad0cb27 100644 --- a/prefab/weapons/IronAxe.tscn +++ b/prefab/weapons/IronAxe.tscn @@ -15,6 +15,10 @@ collision_layer = 8 collision_mask = 34 angular_damp = -1.0 script = ExtResource("1_snmy1") +_maxDamage = null +_minDamage = null +FiringIntervalAsMillisecond = null +_recoilStrength = null [node name="StaffOfTheUndead2" type="Sprite2D" parent="."] position = Vector2(30, 0) diff --git a/scripts/GameSceneDepend.cs b/scripts/GameSceneDepend.cs index 0480a7d..97c0e1b 100644 --- a/scripts/GameSceneDepend.cs +++ b/scripts/GameSceneDepend.cs @@ -17,7 +17,7 @@ public static class GameSceneDepend /// 迷你地图 /// public static MiniMap? MiniMap { get; set; } - + /// /// MiniMapAnimationPlayer /// 迷你地图的动画节点 @@ -54,7 +54,7 @@ public static class GameSceneDepend /// 抛射体容器 /// public static Node2D? ProjectileContainer { get; set; } - + /// /// SpellContainer /// 法术容器 @@ -78,7 +78,7 @@ public static class GameSceneDepend /// 玩家容器 /// public static Node2D? PlayerContainer { get; set; } - + /// /// PickAbleContainer /// 可拾捡物容器 @@ -103,7 +103,7 @@ public static class GameSceneDepend /// 健康条UI /// public static HealthBarUi? HealthBarUi { get; set; } - + /// /// DynamicUiGroup /// 动态生成的Ui组 @@ -112,7 +112,7 @@ public static class GameSceneDepend ///Dynamically generated Ui objects will be placed under this node ///动态生成的Ui对象将放置在此节点下 /// - public static UiGroup? DynamicUiGroup { get; set; } + public static UiGroup? DynamicUiGroup { get; set; } /// @@ -121,10 +121,45 @@ public static class GameSceneDepend /// public static bool IsMouseOverFurnitureGui; - + /// /// Whether the mouse is suspended over the item slot /// 鼠标是否悬浮在物品槽上 /// public static bool IsMouseOverItemSlotNode; + + + /// + /// ShowMiniMap + /// 显示迷你地图 + /// + public static void ShowMiniMap() + { + if (MiniMap == null) + { + return; + } + if (MiniMap.Visible) + { + return; + } + MiniMapAnimationPlayer?.Play(name: "show"); + } + + + /// + /// HideMiniMap + /// 隐藏迷你地图 + /// + public static void HideMiniMap() + { + if (MiniMap == null) + { + return; + } + if (MiniMap.Visible) + { + MiniMapAnimationPlayer?.Play(name: "hide"); + } + } } \ No newline at end of file diff --git a/scripts/map/room/Room.cs b/scripts/map/room/Room.cs index 2f85da1..8aec9e5 100644 --- a/scripts/map/room/Room.cs +++ b/scripts/map/room/Room.cs @@ -23,11 +23,22 @@ public class Room private RoomSlot?[]? _roomSlots; private List? _tileMapLayers; - private Area2D? _area2D; + private Area2D? _roomArea2D; + private Area2D? _spawnArea2D; private PointLight2D? _pointLight2D; private CollisionShape2D? _collisionShape2D; private bool _hasPlayer; - private readonly List _characterTemplateList = []; + /// + /// All the characters in the room + /// 房间内的所有角色 + /// + private readonly List _allCharacter = []; + + /// + /// A character automatically generated by the room + /// 由房间自动生成的角色 + /// + private readonly List _spawnedCharacter = []; /// /// When the player first enters the room, all nodes under this node are executed @@ -35,14 +46,18 @@ public class Room /// private Node2D? _autoSpawn; + /// + /// hasSpawnedEntity + /// 是否生成过实体 + /// + private bool _hasSpawnedEntity; + /// /// Current generated wave number /// 当前生成波数 /// private int _currentWaveNumber; - private readonly List _spawnedCharacterTemplateList = []; - /// /// Max generated wave number /// 最大的生成波数 @@ -156,8 +171,8 @@ public class Room private void ShowAllCharacterTemplate() { LogCat.LogWithFormat("show_all_node", LogCat.LogLabel.Room, LogCat.UploadFormat, - _characterTemplateList.Count); - foreach (var characterTemplate in _characterTemplateList) + _allCharacter.Count); + foreach (var characterTemplate in _allCharacter) { characterTemplate.Show(); } @@ -170,8 +185,8 @@ public class Room private void HideAllCharacterTemplate() { LogCat.LogWithFormat("hide_all_node", LogCat.LogLabel.Room, LogCat.UploadFormat, - _characterTemplateList.Count); - foreach (var characterTemplate in _characterTemplateList) + _allCharacter.Count); + foreach (var characterTemplate in _allCharacter) { characterTemplate.Hide(); } @@ -182,7 +197,7 @@ public class Room /// private void SpawnEnemyWave() { - if (PlayerRoomVisitCount != 1 || _autoSpawn == null) + if (_autoSpawn == null) { return; } @@ -191,10 +206,7 @@ public class Room //Complete all waves. //完成所有的波次。 ClearAllMatchedBarriers(); - if (GameSceneDepend.MiniMap != null && !GameSceneDepend.MiniMap.Visible) - { - GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "show"); - } + GameSceneDepend.ShowMiniMap(); return; } NodeUtils.ForEachNode(_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. //最大波数应该是生物生成的最大波数。就目前而言,玩家进入下一步的条件是杀死所有敌人。 _maxWaveNumber = Math.Max(_maxWaveNumber, marker.GetMaxWaveNumber()); - _spawnedCharacterTemplateList.Add(characterTemplate); + _spawnedCharacter.Add(characterTemplate); characterTemplate.TreeExited += () => { - _spawnedCharacterTemplateList.Remove(characterTemplate); - if (_spawnedCharacterTemplateList.Count == 0) + _spawnedCharacter.Remove(characterTemplate); + if (_spawnedCharacter.Count == 0) { //All the creatures they summoned are dead. //召唤的生物全死了。 @@ -220,16 +232,14 @@ public class Room } return false; }); - if (_spawnedCharacterTemplateList.Count > 0) + if (_spawnedCharacter.Count > 0) { - if (GameSceneDepend.MiniMap != null && GameSceneDepend.MiniMap.Visible) - { - GameSceneDepend.MiniMapAnimationPlayer?.Play(name: "hide"); - } + GameSceneDepend.HideMiniMap(); AddTimer(PlaceBarriersInAllSlots); } } + /// /// Add a timer node to handle some events /// 添加定时器节点处理一些事件 @@ -268,10 +278,9 @@ public class Room if (node is Player player) { - _characterTemplateList.Add(player); + _allCharacter.Add(player); _hasPlayer = true; PlayerRoomVisitCount++; - SpawnEnemyWave(); //The player enters the room, opening up their view. //玩家进入了房间,开放视野。 if (_pointLight2D != null) @@ -279,7 +288,7 @@ public class Room _pointLight2D.Show(); _pointLight2D.Texture = AssetHolder.White100; } - + GameSceneDepend.ShowMiniMap(); GameSceneDepend.MiniMap?.ShowRoomPreview(this); ShowAllCharacterTemplate(); } @@ -294,7 +303,7 @@ public class Room characterTemplate.Hide(); } - _characterTemplateList.Add(characterTemplate); + _allCharacter.Add(characterTemplate); } if (string.IsNullOrEmpty(EnterRoomEventHandlerId)) @@ -325,7 +334,7 @@ public class Room { //The player leaves the room, hiding the view. //玩家离开了房间,隐藏视野。 - _characterTemplateList.Remove(player); + _allCharacter.Remove(player); _hasPlayer = false; if (_pointLight2D != null) { @@ -347,7 +356,7 @@ public class Room } else if (node is CharacterTemplate characterTemplate && characterTemplate.Visible) { - _characterTemplateList.Remove(characterTemplate); + _allCharacter.Remove(characterTemplate); } if (string.IsNullOrEmpty(ExitRoomEventHandlerId)) @@ -369,10 +378,10 @@ public class Room set => _collisionShape2D = value; } - public Area2D? Area2D + public Area2D? RoomArea2D { - get => _area2D; - set => _area2D = value; + get => _roomArea2D; + set => _roomArea2D = value; } public PackedScene? RoomScene @@ -411,17 +420,21 @@ public class Room _tileMapLayers.Add(node); return false; }); - _area2D = rootNode.GetNode("RoomArea"); - _area2D.Monitoring = true; - _area2D.SetCollisionLayerValue(Config.LayerNumber.RoomArea, true); - //Sets the collision layer that can be detected in the current room area. - //设置当前房间区域可检测到的碰撞层。 - _area2D.SetCollisionMaskValue(Config.LayerNumber.Player, true); - _area2D.SetCollisionMaskValue(Config.LayerNumber.Mob, true); - _area2D.BodyExited += OnExitRoom; - _area2D.BodyEntered += OnEnterRoom; - _collisionShape2D = _area2D.GetChild(0); - _roomSlots = GetRoomSlots(GetTileMapLayer(Config.TileMapLayerName.Ground), _area2D, + _roomArea2D = rootNode.GetNode("RoomArea"); + _roomArea2D.Monitoring = true; + _roomArea2D.SetCollisionLayerValue(Config.LayerNumber.RoomArea, true); + _roomArea2D.SetCollisionMaskValue(Config.LayerNumber.Player, true); + _roomArea2D.SetCollisionMaskValue(Config.LayerNumber.Mob, true); + _roomArea2D.BodyExited += OnExitRoom; + _roomArea2D.BodyEntered += OnEnterRoom; + _spawnArea2D = rootNode.GetNodeOrNull("SpawnArea"); + if (_spawnArea2D != null) + { + _spawnArea2D.SetCollisionMaskValue(Config.LayerNumber.Player, true); + _spawnArea2D.BodyEntered += OnEnterSpawnArea; + } + _collisionShape2D = _roomArea2D.GetChild(0); + _roomSlots = GetRoomSlots(GetTileMapLayer(Config.TileMapLayerName.Ground), _roomArea2D, rootNode.GetNode("RoomSlotList")); _pointLight2D = rootNode.GetNodeOrNull("PointLight2D"); if (_pointLight2D != null) @@ -431,6 +444,20 @@ public class Room _autoSpawn = rootNode.GetNodeOrNull("AutoSpawn"); } + private void OnEnterSpawnArea(Node2D body) + { + if (_hasSpawnedEntity) + { + return; + } + if (body is not Player) + { + return; + } + SpawnEnemyWave(); + _hasSpawnedEntity = true; + } + public Node2D? RootNode => _rootNode; public RoomSlot?[]? RoomSlots => _roomSlots; diff --git a/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs b/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs index cf2ca1f..8041108 100644 --- a/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs +++ b/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs @@ -436,7 +436,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy { //Ignore yourself when detecting room overlap //检测房间重叠时应忽略自身 - _selfArea2D = newRoom.Area2D; + _selfArea2D = newRoom.RoomArea2D; _measuringArea2D.Position = result; _measuringCollisionShape2D.Shape = newRoom.RoomCollisionShape2D.Shape; //Calculate the offset of the shape.