diff --git a/locals/Log.csv b/locals/Log.csv index 9d1af99..181139a 100644 --- a/locals/Log.csv +++ b/locals/Log.csv @@ -111,4 +111,17 @@ log_no_platform_detection_raycast_found,缺少必要的平台检测射线。,Lac log_hide_display_item,项目{0}被隐藏了。,Item {0} is hidden.,アイテム{0}は非表示にされます。 log_add_display_item,添加项目{0}。,Add item {0}.,項目{0}を追加します。 log_update_display_item,更新项目{0}。,Update item {0}.,更新項目{0}です。 -log_batch_update_data,批量更新数据开始为{0}结束为{1}.,Batch update data starts with {0} and ends with {1}.,一括更新データの開始を{0}、終了を{1}とします。 \ No newline at end of file +log_batch_update_data,批量更新数据开始为{0}结束为{1}.,Batch update data starts with {0} and ends with {1}.,一括更新データの開始を{0}、終了を{1}とします。 +log_new_room_node_data_is_incomplete,新房间{0}数据不全。,New room {0} data is incomplete.,新しい部屋{0}はデータが不完全です。 +log_parent_room_does_not_exist,放置房间{0}时父级房间不存在。,The parent room does not exist when room {0} is placed.,部屋{0}を置いても親部屋は存在しません。 +log_room_template_does_not_exist,放置房间{0}房间模板不存在。,Room template does not exist when placing room {1}.,部屋{0}を置いた時点では部屋テンプレートは存在しません。 +log_room_slot_does_not_exist,放置房间{0}房间槽位不存在。,Room slot does not exist when placing room {0}.,置き部屋{0}部屋スロットは存在しません。 +log_available_rooms_are_not_available,放置房间{0}时,可用房间不存在。,"When placing room {0}, the available room does not exist.",部屋{0}を置いた場合、利用可能な部屋は存在しません。 +log_room_corresponding_to_resource_is_null,放置房间{0}时,资源{1}对应的房间为null.,"When room {0} is placed, the room corresponding to resource {1} is null.",部屋{0}を置く場合、リソース{1}に対応する部屋はnullとなります。 +log_slots_do_not_match,放置房间{0}时,槽位不匹配。,"When placing room {0}, the slots do not match.",部屋{0}を置く時、溝の位置が一致しません。 +log_slot_incomplete,放置房间{0}时,槽位不完整。,The slot is incomplete when placing room {0}.,部屋{0}を置く場合、溝の位置が不完全です。 +log_placement_position_is_empty,房间{0}放置位置为空。,The room {0} position is empty.,部屋{0}を空にします。 +log_parameter_inconsistency,参数不齐。,Parameter inconsistency.,パラメーターが不揃いです。 +log_room_slot_position_is_empty,房间位置描述为空。,Room location is described as empty.,部屋の位置は空です。 +log_room_overlap,房间重叠。,The rooms overlap.,部屋が重なります。 +log_game_over_event_is_empty,游戏结束事件为空。,End of game event is empty.,ゲームオーバーでイベントは空です。 \ No newline at end of file diff --git a/prefab/roomTemplates/dungeon/readingRoom.tscn b/prefab/roomTemplates/dungeon/readingRoom.tscn index 9f50a11..4fd3a26 100644 --- a/prefab/roomTemplates/dungeon/readingRoom.tscn +++ b/prefab/roomTemplates/dungeon/readingRoom.tscn @@ -16,7 +16,7 @@ outlines = Array[PackedVector2Array]([PackedVector2Array(33, 35, 607, 34, 609, 1 source_geometry_group_name = &"navigation_polygon_source_group" [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] -size = Vector2(639, 222) +size = Vector2(638, 222) [sub_resource type="RectangleShape2D" id="RectangleShape2D_kfmgh"] size = Vector2(579, 151.5) @@ -76,7 +76,7 @@ visible = false collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"] -position = Vector2(320.5, 112) +position = Vector2(320, 112) shape = SubResource("RectangleShape2D_kiih8") [node name="SpawnArea" type="Area2D" parent="."] diff --git a/prefab/roomTemplates/dungeon/utilityRoom.tscn b/prefab/roomTemplates/dungeon/utilityRoom.tscn index 1b9f692..fb1098e 100644 --- a/prefab/roomTemplates/dungeon/utilityRoom.tscn +++ b/prefab/roomTemplates/dungeon/utilityRoom.tscn @@ -20,7 +20,7 @@ outlines = Array[PackedVector2Array]([PackedVector2Array(35, 39, 36, 415, 0, 417 source_geometry_group_name = &"navigation_polygon_source_group" [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] -size = Vector2(728, 509) +size = Vector2(730, 509) [sub_resource type="RectangleShape2D" id="RectangleShape2D_kfmgh"] size = Vector2(509, 407) @@ -101,7 +101,7 @@ _resPathArray = PackedStringArray("res://prefab/entitys/BlackenedAboriginalWarri collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"] -position = Vector2(365, 255.5) +position = Vector2(368, 255.5) shape = SubResource("RectangleShape2D_kiih8") [node name="SpawnArea" type="Area2D" parent="."] diff --git a/prefab/roomTemplates/dungeon/verticalStair.tscn b/prefab/roomTemplates/dungeon/verticalStair.tscn index 428de3f..c1f5dd4 100644 --- a/prefab/roomTemplates/dungeon/verticalStair.tscn +++ b/prefab/roomTemplates/dungeon/verticalStair.tscn @@ -16,7 +16,7 @@ outlines = Array[PackedVector2Array]([PackedVector2Array(29, 35, 381, 34, 383, 9 source_geometry_group_name = &"navigation_polygon_source_group" [sub_resource type="RectangleShape2D" id="RectangleShape2D_kiih8"] -size = Vector2(413, 829) +size = Vector2(413, 828) [sub_resource type="RectangleShape2D" id="RectangleShape2D_kfmgh"] size = Vector2(322, 765) @@ -100,7 +100,7 @@ texture = ExtResource("2_g41lp") collision_mask = 0 [node name="CollisionShape2D" type="CollisionShape2D" parent="RoomArea"] -position = Vector2(207.5, 415.5) +position = Vector2(207.5, 416) shape = SubResource("RectangleShape2D_kiih8") [node name="SpawnArea" type="Area2D" parent="."] diff --git a/scripts/character/CharacterTemplate.cs b/scripts/character/CharacterTemplate.cs index 06fe2cb..927a94f 100644 --- a/scripts/character/CharacterTemplate.cs +++ b/scripts/character/CharacterTemplate.cs @@ -581,7 +581,6 @@ public partial class CharacterTemplate : CharacterBody2D //Character death //角色死亡 OnDie(damageTemplate); - ThrowAllItemOnDie(); return true; } @@ -660,7 +659,7 @@ public partial class CharacterTemplate : CharacterBody2D damageTemplate.Attacker.Name); } } - + ThrowAllItemOnDie(); CreateLootObject(); QueueFree(); return Task.CompletedTask; diff --git a/scripts/character/Player.cs b/scripts/character/Player.cs index 37008d9..3d87927 100644 --- a/scripts/character/Player.cs +++ b/scripts/character/Player.cs @@ -325,8 +325,10 @@ public partial class Player : CharacterTemplate { Hide(); ProcessMode = ProcessModeEnum.Disabled; + ProtectedItemContainer?.ClearAllItems(); if (EventBus.GameOverEvent == null) { + LogCat.Log("game_over_event_is_empty"); return; } diff --git a/scripts/debug/LogCat.cs b/scripts/debug/LogCat.cs index 8204383..3c215f8 100644 --- a/scripts/debug/LogCat.cs +++ b/scripts/debug/LogCat.cs @@ -16,7 +16,8 @@ public static class LogCat /// public const string Default = "Default"; public const string Debug = "Debug"; - + public const string PatchworkRoomPlacementStrategy = "PatchworkRoomPlacementStrategy"; + /// /// ItemContainerDisplay /// 项目容器显示器 @@ -148,7 +149,7 @@ public static class LogCat get => _minLogLevel; set => _minLogLevel = value; } - + private static readonly StringBuilder StringBuilder = new StringBuilder(); diff --git a/scripts/inventory/IItemContainer.cs b/scripts/inventory/IItemContainer.cs index 2ccd95c..732294a 100644 --- a/scripts/inventory/IItemContainer.cs +++ b/scripts/inventory/IItemContainer.cs @@ -122,6 +122,12 @@ public interface IItemContainer /// /// bool ClearItem(int index); + + /// + /// ClearAllItems + /// 清理全部物品 + /// + void ClearAllItems(); /// /// Gets the item in the specified location, equivalent to diff --git a/scripts/inventory/UniversalItemContainer.cs b/scripts/inventory/UniversalItemContainer.cs index 5310c2f..e4ca063 100644 --- a/scripts/inventory/UniversalItemContainer.cs +++ b/scripts/inventory/UniversalItemContainer.cs @@ -324,7 +324,7 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer if (SupportSelect && index == _selectIndex) { item.HideSelf(); - SelectedItemChangeEvent?.Invoke(new SelectedItemChangeEvent() + SelectedItemChangeEvent?.Invoke(new SelectedItemChangeEvent { NewIndex = index, OldIndex = index, @@ -336,6 +336,34 @@ public class UniversalItemContainer(int totalCapacity) : IItemContainer return result; } + public void ClearAllItems() + { + foreach (var itemDictionaryKey in _itemDictionary.Keys) + { + var item = _itemDictionary[itemDictionaryKey]; + item.QueueFreeSelf(); + ItemDataChangeEvent?.Invoke(new ItemDataChangeEvent + { + NewItem = null, + NewIndex = itemDictionaryKey, + OldIndex = itemDictionaryKey, + OldItem = null, + Type = Config.ItemDataChangeEventType.Clear + }); + if (SupportSelect && itemDictionaryKey == _selectIndex) + { + SelectedItemChangeEvent?.Invoke(new SelectedItemChangeEvent + { + NewIndex = itemDictionaryKey, + OldIndex = itemDictionaryKey, + NewItem = null, + OldItem = null + }); + } + } + _itemDictionary.Clear(); + } + public int RemoveSelectItem(int number) { diff --git a/scripts/loader/sceneLoader/GameSceneLoader.cs b/scripts/loader/sceneLoader/GameSceneLoader.cs index 40a7fee..8e0f749 100644 --- a/scripts/loader/sceneLoader/GameSceneLoader.cs +++ b/scripts/loader/sceneLoader/GameSceneLoader.cs @@ -1,6 +1,7 @@ using System.Threading.Tasks; using ColdMint.scripts.inventory; using ColdMint.scripts.map; +using ColdMint.scripts.map.events; using ColdMint.scripts.map.LayoutParsingStrategy; using ColdMint.scripts.map.layoutStrategy; using ColdMint.scripts.map.miniMap; @@ -92,9 +93,32 @@ public partial class GameSceneLoader : SceneLoaderTemplate MapGenerator.LayoutStrategy = new TestLayoutStrategy(); MapGenerator.LayoutParsingStrategy = new SequenceLayoutParsingStrategy(); MapGenerator.RoomPlacementStrategy = new PatchworkRoomPlacementStrategy(); + EventBus.GameOverEvent += OnGameOverEvent; await GenerateMap(); } + private async void OnGameOverEvent(GameOverEvent gameOverEvent) + { + if (GameSceneDepend.WeaponContainer != null) + { + NodeUtils.DeleteAllChild(GameSceneDepend.WeaponContainer); + } + if (GameSceneDepend.PacksackContainer != null) + { + NodeUtils.DeleteAllChild(GameSceneDepend.PacksackContainer); + } + if (GameSceneDepend.SpellContainer != null) + { + NodeUtils.DeleteAllChild(GameSceneDepend.SpellContainer); + } + await GenerateMap(); + } + + public override void _ExitTree() + { + EventBus.GameOverEvent -= OnGameOverEvent; + } + /// /// Generate map /// 生成地图 diff --git a/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs b/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs index 8041108..5a51651 100644 --- a/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs +++ b/scripts/map/roomPlacer/PatchworkRoomPlacementStrategy.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; +using ColdMint.scripts.debug; using ColdMint.scripts.levelGraphEditor; using ColdMint.scripts.map.dateBean; using ColdMint.scripts.map.interfaces; @@ -154,23 +155,27 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy { if (newRoomNodeData.RoomTemplateSet == null || newRoomNodeData.RoomTemplateSet.Length == 0) { + LogCat.LogWithFormat("new_room_node_data_is_incomplete", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); return null; } if (parentRoomNode == null) { + LogCat.LogWithFormat("parent_room_does_not_exist", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); return null; } var roomResArray = RoomFactory.RoomTemplateSetToRoomRes(newRoomNodeData.RoomTemplateSet); if (roomResArray.Length == 0) { + LogCat.LogWithFormat("room_template_does_not_exist", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); return null; } var roomSlots = parentRoomNode.RoomSlots; if (roomSlots == null || roomSlots.Length == 0) { + LogCat.LogWithFormat("room_slot_does_not_exist", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); return null; } @@ -183,6 +188,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy newRoomNodeData.ExitRoomEventHandlerId); if (newRoom == null) { + LogCat.LogWithFormat("room_corresponding_to_resource_is_null", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id, roomRes); continue; } @@ -190,16 +196,22 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy //创建了一个房间,尝试使用房间的槽与现有的房间槽匹配。 if (!IsMatch(parentRoomNode, newRoom, out var mainRoomSlot, out var newRoomSlot).Result) { + LogCat.LogWithFormat("slots_do_not_match", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); continue; } if (mainRoomSlot == null || newRoomSlot == null) { + LogCat.LogWithFormat("slot_incomplete", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); continue; } var position = await CalculatedPosition(parentRoomNode, newRoom, mainRoomSlot, newRoomSlot, false); - if (position == null) continue; + if (position == null) + { + LogCat.LogWithFormat("placement_position_is_empty", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); + continue; + } var roomPlacementData = new RoomPlacementData { NewRoom = newRoom, @@ -213,6 +225,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy if (usableRoomPlacementData.Count == 0) { + LogCat.LogWithFormat("available_rooms_are_not_available", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy, newRoomNodeData.Id); return null; } else @@ -374,6 +387,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy newRoomTileMapLayer == null || mainRoomSlot == null || newRoomSlot == null) { + LogCat.Log("parameter_inconsistency", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy); return null; } @@ -387,6 +401,7 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy { //If the room slot is described as null, null is returned //若房间槽描述为null,那么返回null + LogCat.Log("room_slot_position_is_empty", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy); return null; } @@ -445,11 +460,10 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy await Task.Delay(TimeSpan.FromMilliseconds(50)); if (_overlapQuantity > 0) { + LogCat.Log("room_overlap", label: LogCat.LogLabel.PatchworkRoomPlacementStrategy); return null; } } - - return result; } } \ No newline at end of file