No longer throws all items after the player dies, and recreates the map after the player dies.

玩家死亡后不再扔出所有物品,在玩家死亡后重新创建地图。
This commit is contained in:
Cold-Mint 2024-10-17 16:08:21 +08:00
parent d36c909dec
commit 9352f2c32b
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
11 changed files with 102 additions and 15 deletions

View File

@ -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}とします。
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.,ゲームオーバーでイベントは空です。
1 id zh en ja
111 log_hide_display_item 项目{0}被隐藏了。 Item {0} is hidden. アイテム{0}は非表示にされます。
112 log_add_display_item 添加项目{0}。 Add item {0}. 項目{0}を追加します。
113 log_update_display_item 更新项目{0}。 Update item {0}. 更新項目{0}です。
114 log_batch_update_data 批量更新数据开始为{0}结束为{1}. Batch update data starts with {0} and ends with {1}. 一括更新データの開始を{0}、終了を{1}とします。
115 log_new_room_node_data_is_incomplete 新房间{0}数据不全。 New room {0} data is incomplete. 新しい部屋{0}はデータが不完全です。
116 log_parent_room_does_not_exist 放置房间{0}时父级房间不存在。 The parent room does not exist when room {0} is placed. 部屋{0}を置いても親部屋は存在しません。
117 log_room_template_does_not_exist 放置房间{0}房间模板不存在。 Room template does not exist when placing room {1}. 部屋{0}を置いた時点では部屋テンプレートは存在しません。
118 log_room_slot_does_not_exist 放置房间{0}房间槽位不存在。 Room slot does not exist when placing room {0}. 置き部屋{0}部屋スロットは存在しません。
119 log_available_rooms_are_not_available 放置房间{0}时,可用房间不存在。 When placing room {0}, the available room does not exist. 部屋{0}を置いた場合、利用可能な部屋は存在しません。
120 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となります。
121 log_slots_do_not_match 放置房间{0}时,槽位不匹配。 When placing room {0}, the slots do not match. 部屋{0}を置く時、溝の位置が一致しません。
122 log_slot_incomplete 放置房间{0}时,槽位不完整。 The slot is incomplete when placing room {0}. 部屋{0}を置く場合、溝の位置が不完全です。
123 log_placement_position_is_empty 房间{0}放置位置为空。 The room {0} position is empty. 部屋{0}を空にします。
124 log_parameter_inconsistency 参数不齐。 Parameter inconsistency. パラメーターが不揃いです。
125 log_room_slot_position_is_empty 房间位置描述为空。 Room location is described as empty. 部屋の位置は空です。
126 log_room_overlap 房间重叠。 The rooms overlap. 部屋が重なります。
127 log_game_over_event_is_empty 游戏结束事件为空。 End of game event is empty. ゲームオーバーでイベントは空です。

View File

@ -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="."]

View File

@ -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="."]

View File

@ -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="."]

View File

@ -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;

View File

@ -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;
}

View File

@ -16,7 +16,8 @@ public static class LogCat
/// </summary>
public const string Default = "Default";
public const string Debug = "Debug";
public const string PatchworkRoomPlacementStrategy = "PatchworkRoomPlacementStrategy";
/// <summary>
/// <para>ItemContainerDisplay</para>
/// <para>项目容器显示器</para>
@ -148,7 +149,7 @@ public static class LogCat
get => _minLogLevel;
set => _minLogLevel = value;
}
private static readonly StringBuilder StringBuilder = new StringBuilder();

View File

@ -122,6 +122,12 @@ public interface IItemContainer
/// <param name="index"></param>
/// <returns></returns>
bool ClearItem(int index);
/// <summary>
/// <para>ClearAllItems</para>
/// <para>清理全部物品</para>
/// </summary>
void ClearAllItems();
/// <summary>
/// <para>Gets the item in the specified location, equivalent to <see cref="GetItem"/></para>

View File

@ -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)
{

View File

@ -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;
}
/// <summary>
/// <para>Generate map</para>
/// <para>生成地图</para>

View File

@ -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;
}
}