diff --git a/DungeonShooting_Godot/resource/map/RoomConfig.json b/DungeonShooting_Godot/resource/map/RoomConfig.json index 63ff048..96ba25d 100644 --- a/DungeonShooting_Godot/resource/map/RoomConfig.json +++ b/DungeonShooting_Godot/resource/map/RoomConfig.json @@ -25,6 +25,10 @@ { "ScenePath": "res://resource/map/tileMaps/testGroup/battle/Room6.tscn", "ConfigPath": "res://resource/map/tiledata/testGroup/battle/Room6.json" + }, + { + "ScenePath": "res://resource/map/tileMaps/testGroup/battle/Room7.tscn", + "ConfigPath": "res://resource/map/tiledata/testGroup/battle/Room7.json" } ], "InletList": [ diff --git a/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room5.tscn b/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room5.tscn index 65bdeb8..32570c6 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room5.tscn +++ b/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room5.tscn @@ -8,4 +8,3 @@ format = 2 layer_0/tile_data = PackedInt32Array(65533, 0, 8, 131069, 0, 8, 196605, 0, 8, 262141, 0, 8, 327677, 131072, 2, 65534, 0, 8, 131070, 0, 8, 196606, 0, 8, 262142, 0, 8, 327678, 196608, 2, 393214, 720896, 2, -1, 0, 8, 65535, 0, 8, 131071, 0, 8, 196607, 0, 8, 262143, 0, 8, 327679, 0, 8, 393215, 196608, 2, 458751, 196608, 3, -196608, 0, 8, -131072, 0, 8, -65536, 0, 8, 0, 0, 8, 65536, 0, 8, 131072, 0, 8, 196608, 0, 8, 262144, 0, 8, 327680, 0, 8, 393216, 0, 8, 458752, 131072, 2, -196607, 0, 8, -131071, 0, 8, -65535, 0, 8, 1, 0, 8, 65537, 65536, 2, 131073, 65536, 7, 196609, 0, 8, 262145, 0, 8, 327681, 0, 8, 393217, 0, 8, 458753, 131072, 2, -196606, 0, 8, -131070, 0, 8, -65534, 0, 8, 2, 0, 8, 65538, 196608, 2, 131074, 196608, 7, 196610, 0, 8, 262146, 0, 8, 327682, 0, 8, 393218, 0, 8, 458754, 131072, 2, -196605, 0, 8, -131069, 0, 8, -65533, 0, 8, 3, 0, 8, 65539, 0, 8, 131075, 0, 8, 196611, 0, 8, 262147, 0, 8, 327683, 0, 8, 393219, 0, 8, 458755, 131072, 2, -196604, 65536, 3, -131068, 65536, 7, -65532, 0, 8, 4, 0, 8, 65540, 0, 8, 131076, 0, 8, 196612, 0, 8, 262148, 0, 8, 327684, 65536, 2, 393220, 65536, 3, 458756, 851968, 2, -131067, 65536, 4, -65531, 65536, 7, 5, 0, 8, 65541, 0, 8, 131077, 0, 8, 196613, 0, 8, 262149, 65536, 2, 327685, 851968, 2, -65530, 131072, 7, 6, 0, 8, 65542, 0, 8, 131078, 0, 8, 196614, 0, 8, 262150, 131072, 2, 7, 65536, 3, 65543, 65536, 3, 131079, 65536, 3, 196615, 65536, 3, 262151, 851968, 2, -4, 196608, 4, 65532, 196608, 3, 131068, 196608, 3, 196604, 196608, 3, 262140, 196608, 3, 327676, 720896, 2, -3, 131072, 7, -65538, 196608, 4, -2, 196608, 7, -196609, 196608, 4, -131073, 196608, 3, -65537, 196608, 7, 524287, 720896, 2, -262144, 131072, 7, -262143, 131072, 7, -262142, 131072, 7, -262141, 131072, 7, -262140, 65536, 4, -65529, 65536, 4) script = ExtResource("dungeonRoomTemplate") -EnableEdit = true diff --git a/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room7.tscn b/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room7.tscn new file mode 100644 index 0000000..2f6a681 --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tileMaps/testGroup/battle/Room7.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://bgygwfm4wwuyo"] + +[ext_resource type="TileSet" uid="uid://b00g22o1cqhe8" path="res://resource/map/tileset/TileSet1.tres" id="1_phigy"] +[ext_resource type="Script" path="res://src/framework/map/DungeonRoomTemplate.cs" id="dungeonRoomTemplate"] + +[node name="Room7" type="TileMap"] +tile_set = ExtResource("1_phigy") +format = 2 +layer_0/tile_data = PackedInt32Array(196617, 0, 8, 131081, 0, 8, 65545, 0, 8, 9, 0, 8, -65527, 0, 8, -131063, 0, 8, -196599, 0, 8, 196616, 0, 8, 131080, 0, 8, 65544, 0, 8, 8, 0, 8, -65528, 0, 8, -131064, 0, 8, -196600, 0, 8, 196615, 0, 8, 131079, 0, 8, 65543, 0, 8, 7, 0, 8, -65529, 0, 8, -131065, 0, 8, -196601, 0, 8, 196614, 0, 8, 131078, 0, 8, 65542, 0, 8, 6, 0, 8, -65530, 0, 8, -131066, 0, 8, -196602, 0, 8, 196613, 0, 8, 131077, 0, 8, 65541, 0, 8, 5, 0, 8, -65531, 0, 8, -131067, 0, 8, -196603, 0, 8, 196612, 0, 8, 131076, 0, 8, 65540, 0, 8, 4, 0, 8, -65532, 0, 8, -131068, 0, 8, -196604, 0, 8, 196611, 0, 8, 131075, 0, 8, 65539, 0, 8, 3, 0, 8, -65533, 0, 8, -131069, 0, 8, -196605, 0, 8, 196610, 0, 8, 131074, 0, 8, 65538, 0, 8, 2, 0, 8, -65534, 0, 8, -131070, 0, 8, -196606, 0, 8, 196609, 0, 8, 131073, 0, 8, 65537, 0, 8, 1, 0, 8, -65535, 0, 8, -131071, 0, 8, -196607, 0, 8, 196608, 0, 8, 131072, 0, 8, 65536, 0, 8, 0, 0, 8, -65536, 0, 8, -131072, 0, 8, -196608, 0, 8, 262143, 0, 8, 196607, 0, 8, 131071, 0, 8, 65535, 0, 8, -1, 0, 8, -65537, 0, 8, -131073, 0, 8, 262142, 0, 8, 196606, 0, 8, 131070, 0, 8, 65534, 0, 8, -2, 0, 8, -65538, 0, 8, -131074, 0, 8, -65539, 196608, 3, -131075, 196608, 3, -196611, 196608, 4, -196610, 131072, 7, -196609, 131072, 7, -3, 196608, 3, 65533, 196608, 3, 131069, 196608, 3, 196605, 196608, 3, 262141, 196608, 3, 327679, 131072, 2, 327678, 131072, 2, 327677, 720896, 2, -262144, 131072, 7, 262144, 131072, 2, -262143, 131072, 7, 262145, 131072, 2, -262142, 131072, 7, 262146, 131072, 2, -262141, 131072, 7, 262147, 131072, 2, -262140, 131072, 7, 262148, 131072, 2, -262139, 131072, 7, 262149, 131072, 2, -262138, 131072, 7, 262150, 131072, 2, -262137, 131072, 7, 262151, 131072, 2, -262136, 131072, 7, 262152, 131072, 2, -262135, 131072, 7, 262153, 131072, 2, -196598, 65536, 3, -131062, 65536, 3, -262134, 65536, 4, -65526, 65536, 3, 10, 65536, 3, 65546, 65536, 3, 131082, 65536, 3, 196618, 65536, 3, 262154, 851968, 2) +script = ExtResource("dungeonRoomTemplate") diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room1.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room1.json index f62fb46..bd65f7d 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room1.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room1.json @@ -54,5 +54,6 @@ ], "GroupName": "testGroup", "RoomType": 0, - "FileName": "Room1" + "FileName": "Room1", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room2.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room2.json index ac26334..ad5c14f 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room2.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room2.json @@ -96,5 +96,6 @@ ], "GroupName": "testGroup", "RoomType": 0, - "FileName": "Room2" + "FileName": "Room2", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room3.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room3.json index 68cad1e..7e6a611 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room3.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room3.json @@ -117,5 +117,6 @@ ], "GroupName": "testGroup", "RoomType": 0, - "FileName": "Room3" + "FileName": "Room3", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room4.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room4.json index 2c4e99b..281fc9a 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room4.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room4.json @@ -120,5 +120,6 @@ ], "GroupName": "testGroup", "RoomType": 0, - "FileName": "Room4" + "FileName": "Room4", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room5.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room5.json index 0473260..6290559 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room5.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room5.json @@ -139,5 +139,6 @@ ], "GroupName": "testGroup", "RoomType": 0, - "FileName": "Room5" + "FileName": "Room5", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room6.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room6.json index ecf93c7..c0ce6ce 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room6.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room6.json @@ -70,5 +70,6 @@ ], "GroupName": "testGroup", "RoomType": 0, - "FileName": "Room6" + "FileName": "Room6", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room7.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room7.json new file mode 100644 index 0000000..aa28b2f --- /dev/null +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/battle/Room7.json @@ -0,0 +1,38 @@ +{ + "Position": { + "X": -3, + "Y": -4 + }, + "Size": { + "X": 14, + "Y": 9 + }, + "DoorAreaInfos": [], + "NavigationList": [ + { + "Type": 0, + "Points": [ + { + "X": -24, + "Y": -40 + }, + { + "X": 152, + "Y": -40 + }, + { + "X": 152, + "Y": 56 + }, + { + "X": -24, + "Y": 56 + } + ] + } + ], + "GroupName": "testGroup", + "RoomType": 0, + "FileName": "Room7", + "Weight": 100 +} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/inlet/Room1.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/inlet/Room1.json index 1a65117..84e63f0 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/inlet/Room1.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/inlet/Room1.json @@ -33,5 +33,6 @@ ], "GroupName": "testGroup", "RoomType": 1, - "FileName": "Room1" + "FileName": "Room1", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tiledata/testGroup/outlet/Room1.json b/DungeonShooting_Godot/resource/map/tiledata/testGroup/outlet/Room1.json index 794ba12..fb367d6 100644 --- a/DungeonShooting_Godot/resource/map/tiledata/testGroup/outlet/Room1.json +++ b/DungeonShooting_Godot/resource/map/tiledata/testGroup/outlet/Room1.json @@ -33,5 +33,6 @@ ], "GroupName": "testGroup", "RoomType": 2, - "FileName": "Room1" + "FileName": "Room1", + "Weight": 100 } \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/theme/mainTheme.tres b/DungeonShooting_Godot/resource/theme/mainTheme.tres index cb054f9..fb564f6 100644 --- a/DungeonShooting_Godot/resource/theme/mainTheme.tres +++ b/DungeonShooting_Godot/resource/theme/mainTheme.tres @@ -352,7 +352,7 @@ [sub_resource type="ImageTexture" id="58"] -[sub_resource type="Image" id="Image_i0kr2"] +[sub_resource type="Image" id="Image_tbn6v"] data = { "data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 1, 255, 255, 255, 39, 255, 255, 255, 67, 255, 255, 255, 67, 255, 255, 255, 39, 255, 255, 255, 1, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 39, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 39, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 66, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 66, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 66, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 66, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 39, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 75, 255, 255, 255, 39, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 1, 255, 255, 255, 39, 255, 255, 255, 67, 255, 255, 255, 67, 255, 255, 255, 39, 255, 255, 255, 1, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "format": "RGBA8", @@ -362,7 +362,7 @@ } [sub_resource type="ImageTexture" id="60"] -image = SubResource("Image_i0kr2") +image = SubResource("Image_tbn6v") [sub_resource type="StyleBoxTexture" id="61"] content_margin_left = 2.0 @@ -372,7 +372,7 @@ texture = SubResource("60") region_rect = Rect2(0, 0, 12, 12) -[sub_resource type="Image" id="Image_36ck6"] +[sub_resource type="Image" id="Image_voo5a"] data = { "data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 191, 191, 0, 247, 247, 247, 0, 248, 248, 248, 0, 248, 248, 248, 0, 247, 247, 247, 0, 191, 191, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 191, 191, 0, 191, 191, 191, 4, 247, 247, 247, 98, 248, 248, 248, 167, 248, 248, 248, 167, 247, 247, 247, 98, 191, 191, 191, 4, 191, 191, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 247, 247, 247, 0, 247, 247, 247, 97, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 247, 247, 247, 97, 247, 247, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 248, 248, 0, 248, 248, 248, 164, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 164, 248, 248, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 248, 248, 248, 0, 248, 248, 248, 164, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 164, 248, 248, 248, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 247, 247, 247, 0, 247, 247, 247, 97, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 248, 248, 248, 186, 247, 247, 247, 97, 247, 247, 247, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 191, 191, 0, 191, 191, 191, 4, 247, 247, 247, 98, 248, 248, 248, 167, 248, 248, 248, 167, 247, 247, 247, 98, 191, 191, 191, 4, 191, 191, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 191, 191, 191, 0, 247, 247, 247, 0, 248, 248, 248, 0, 248, 248, 248, 0, 247, 247, 247, 0, 191, 191, 191, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "format": "RGBA8", @@ -382,7 +382,7 @@ } [sub_resource type="ImageTexture" id="63"] -image = SubResource("Image_36ck6") +image = SubResource("Image_voo5a") [sub_resource type="StyleBoxTexture" id="64"] content_margin_left = 2.0 @@ -392,7 +392,7 @@ texture = SubResource("63") region_rect = Rect2(0, 0, 12, 12) -[sub_resource type="Image" id="Image_h7it7"] +[sub_resource type="Image" id="Image_ivjvr"] data = { "data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 127, 127, 0, 173, 173, 173, 0, 173, 173, 173, 0, 173, 173, 173, 0, 173, 173, 173, 0, 127, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 127, 127, 0, 127, 127, 127, 4, 173, 173, 173, 97, 173, 173, 173, 166, 173, 173, 173, 166, 173, 173, 173, 97, 127, 127, 127, 4, 127, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 172, 172, 172, 0, 172, 172, 172, 96, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 172, 172, 172, 96, 172, 172, 172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 173, 173, 0, 173, 173, 173, 163, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 163, 173, 173, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 173, 173, 173, 0, 173, 173, 173, 163, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 163, 173, 173, 173, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 172, 172, 172, 0, 172, 172, 172, 96, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 173, 173, 173, 185, 172, 172, 172, 96, 172, 172, 172, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 127, 127, 0, 127, 127, 127, 4, 173, 173, 173, 97, 173, 173, 173, 166, 173, 173, 173, 166, 173, 173, 173, 97, 127, 127, 127, 4, 127, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 127, 127, 0, 173, 173, 173, 0, 173, 173, 173, 0, 173, 173, 173, 0, 173, 173, 173, 0, 127, 127, 127, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "format": "RGBA8", @@ -402,7 +402,7 @@ } [sub_resource type="ImageTexture" id="66"] -image = SubResource("Image_h7it7") +image = SubResource("Image_ivjvr") [sub_resource type="StyleBoxTexture" id="67"] content_margin_left = 2.0 @@ -412,7 +412,7 @@ texture = SubResource("66") region_rect = Rect2(0, 0, 12, 12) -[sub_resource type="Image" id="Image_8s4ly"] +[sub_resource type="Image" id="Image_dntx8"] data = { "data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 4, 255, 255, 255, 16, 255, 255, 255, 16, 255, 255, 255, 4, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 16, 255, 255, 255, 21, 255, 255, 255, 21, 255, 255, 255, 16, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 16, 255, 255, 255, 21, 255, 255, 255, 21, 255, 255, 255, 16, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 4, 255, 255, 255, 16, 255, 255, 255, 16, 255, 255, 255, 4, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "format": "RGBA8", @@ -422,7 +422,7 @@ } [sub_resource type="ImageTexture" id="69"] -image = SubResource("Image_8s4ly") +image = SubResource("Image_dntx8") [sub_resource type="StyleBoxTexture" id="70"] content_margin_left = 0.0 @@ -446,7 +446,7 @@ content_margin_right = 4.0 content_margin_bottom = 4.0 -[sub_resource type="Image" id="Image_fdo5m"] +[sub_resource type="Image" id="Image_4pwn7"] data = { "data": PackedByteArray(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 76, 255, 255, 255, 17, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 76, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 76, 255, 255, 255, 228, 255, 255, 255, 188, 255, 255, 255, 17, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 188, 255, 255, 255, 228, 255, 255, 255, 76, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 18, 255, 255, 255, 188, 255, 255, 255, 229, 255, 255, 255, 187, 255, 255, 255, 17, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 187, 255, 255, 255, 229, 255, 255, 255, 188, 255, 255, 255, 18, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 19, 255, 255, 255, 188, 255, 255, 255, 229, 255, 255, 255, 185, 255, 255, 255, 17, 255, 255, 255, 17, 255, 255, 255, 186, 255, 255, 255, 229, 255, 255, 255, 188, 255, 255, 255, 19, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 19, 255, 255, 255, 190, 255, 255, 255, 229, 255, 255, 255, 185, 255, 255, 255, 185, 255, 255, 255, 229, 255, 255, 255, 189, 255, 255, 255, 19, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 19, 255, 255, 255, 191, 255, 255, 255, 229, 255, 255, 255, 229, 255, 255, 255, 190, 255, 255, 255, 19, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 188, 255, 255, 255, 229, 255, 255, 255, 229, 255, 255, 255, 188, 255, 255, 255, 17, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 188, 255, 255, 255, 229, 255, 255, 255, 188, 255, 255, 255, 188, 255, 255, 255, 229, 255, 255, 255, 187, 255, 255, 255, 17, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 187, 255, 255, 255, 229, 255, 255, 255, 188, 255, 255, 255, 18, 255, 255, 255, 19, 255, 255, 255, 188, 255, 255, 255, 229, 255, 255, 255, 186, 255, 255, 255, 17, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 17, 255, 255, 255, 185, 255, 255, 255, 229, 255, 255, 255, 189, 255, 255, 255, 19, 255, 255, 255, 0, 255, 255, 255, 0, 255, 255, 255, 19, 255, 255, 255, 189, 255, 255, 255, 229, 255, 255, 255, 185, 255, 255, 255, 17, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 76, 255, 255, 255, 229, 255, 255, 255, 190, 255, 255, 255, 19, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 19, 255, 255, 255, 190, 255, 255, 255, 229, 255, 255, 255, 76, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 77, 255, 255, 255, 19, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 19, 255, 255, 255, 77, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 255, 255, 255, 0, 255, 255, 255, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), "format": "RGBA8", @@ -456,7 +456,7 @@ } [sub_resource type="ImageTexture" id="56"] -image = SubResource("Image_fdo5m") +image = SubResource("Image_4pwn7") [sub_resource type="StyleBoxFlat" id="57"] content_margin_left = 6.0 diff --git a/DungeonShooting_Godot/src/framework/common/Utils.cs b/DungeonShooting_Godot/src/framework/common/Utils.cs index 887510f..4b27f8e 100644 --- a/DungeonShooting_Godot/src/framework/common/Utils.cs +++ b/DungeonShooting_Godot/src/framework/common/Utils.cs @@ -15,6 +15,14 @@ { _random = new Random(); } + + /// + /// 返回一个随机的double值 + /// + public static double RandomDouble() + { + return _random.NextDouble(); + } /// /// 返回随机 boolean 值 diff --git a/DungeonShooting_Godot/src/framework/common/WeightRandom.cs b/DungeonShooting_Godot/src/framework/common/WeightRandom.cs new file mode 100644 index 0000000..f0c7511 --- /dev/null +++ b/DungeonShooting_Godot/src/framework/common/WeightRandom.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +/// +/// 带有权重的随机值处理类 +/// +public class WeightRandom +{ + private (float, int)[] _prepareAdRewardWeight; + + /// + /// 初始化权重列表 + /// + public void InitAdRewardWeight(int[] weightList) + { + var total = weightList.Sum(); + var length = weightList.Length; + var avg = 1f * total / length; + var smallAvg = new List<(float, int)>(); + var bigAvg = new List<(float, int)>(); + for (int i = 0; i < weightList.Length; i++) + { + (weightList[i] > avg ? bigAvg : smallAvg).Add((weightList[i], i)); + } + + _prepareAdRewardWeight = new (float, int)[weightList.Length]; + for (int i = 0; i < weightList.Length; i++) + { + if (smallAvg.Count > 0) + { + if (bigAvg.Count > 0) + { + _prepareAdRewardWeight[smallAvg[0].Item2] = (smallAvg[0].Item1 / avg, bigAvg[0].Item2); + bigAvg[0] = (bigAvg[0].Item1 - avg + smallAvg[0].Item1, bigAvg[0].Item2); + if (avg - bigAvg[0].Item1 > 0.0000001f) + { + smallAvg.Add(bigAvg[0]); + bigAvg.RemoveAt(0); + } + } + else + { + _prepareAdRewardWeight[smallAvg[0].Item2] = (smallAvg[0].Item1 / avg, smallAvg[0].Item2); + } + + smallAvg.RemoveAt(0); + } + else + { + _prepareAdRewardWeight[bigAvg[0].Item2] = (bigAvg[0].Item1 / avg, bigAvg[0].Item2); + bigAvg.RemoveAt(0); + } + } + } + + /// + /// 获取下一个随机索引 + /// + public int GetRandomIndex() + { + var randomNum = Utils.RandomDouble() * _prepareAdRewardWeight.Length; + var intRan = (int)Math.Floor(randomNum); + var p = _prepareAdRewardWeight[intRan]; + if (p.Item1 > randomNum - intRan) + { + return intRan; + } + else + { + return p.Item2; + } + } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/generator/DungeonRoomGenerator.cs b/DungeonShooting_Godot/src/framework/generator/DungeonRoomGenerator.cs index fb9ba47..7ce0a33 100644 --- a/DungeonShooting_Godot/src/framework/generator/DungeonRoomGenerator.cs +++ b/DungeonShooting_Godot/src/framework/generator/DungeonRoomGenerator.cs @@ -185,7 +185,7 @@ var polygonData = dungeonTile.GetPolygonData(); DungeonRoomTemplate.SaveConfig(new List(), usedRect.Position, usedRect.Size, polygonData.ToList(), - item.Value.GroupName, item.Value.RoomType, item.Value.FileName); + item.Value.GroupName, item.Value.RoomType, item.Value.FileName, dungeonRoomTemplate.Weight); dungeonRoomTemplate.QueueFree(); } } diff --git a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs index 11b1bb7..161cf34 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs @@ -114,6 +114,8 @@ throw new Exception("当前组'" + groupName + "'中没有战斗房间, 不能生成地牢!"); } } + + _roomGroup.InitWeight(); } /// @@ -137,7 +139,7 @@ EachRoom(next, cb); } } - + /// /// 生成房间 /// @@ -195,9 +197,12 @@ var list = _roomGroup.GetRoomList(roomType); if (list.Count == 0) //如果没有指定类型的房间, 就生成战斗房间 { - list = _roomGroup.BattleList; + roomSplit = _roomGroup.GetRandomRoom(DungeonRoomType.Battle); } - roomSplit = Utils.RandomChoose(list); + else + { + roomSplit = _roomGroup.GetRandomRoom(roomType); + } } else //指定了房间 { diff --git a/DungeonShooting_Godot/src/framework/map/DungeonRoomGroup.cs b/DungeonShooting_Godot/src/framework/map/DungeonRoomGroup.cs index ff99450..6ad860b 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonRoomGroup.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonRoomGroup.cs @@ -1,6 +1,8 @@  +using System; using System.Collections.Generic; using System.Text.Json.Serialization; +using Godot; /// /// 房间组数据 @@ -55,6 +57,9 @@ [JsonInclude] public List EventList = new List(); + private bool _init = false; + private Dictionary _weightRandomMap; + /// /// 获取指定类型房间集合 /// @@ -73,4 +78,56 @@ return null; } + + /// + /// 初始化权重处理 + /// + public void InitWeight() + { + if (_init) + { + return; + } + + _init = true; + _weightRandomMap = new Dictionary(); + + foreach (var roomType in Enum.GetValues()) + { + InitAdRewardWeight(roomType); + } + } + + private void InitAdRewardWeight(DungeonRoomType roomType) + { + var dungeonRoomSplits = GetRoomList(roomType); + var weightRandom = new WeightRandom(); + _weightRandomMap.Add(roomType, weightRandom); + + var list = new List(); + foreach (var roomSplit in dungeonRoomSplits) + { + list.Add(roomSplit.RoomInfo.Weight); + } + weightRandom.InitAdRewardWeight(list.ToArray()); + } + + /// + /// 根据房间类型和权重获取随机房间 + /// + public DungeonRoomSplit GetRandomRoom(DungeonRoomType roomType) + { + if (!_init) + { + GD.PrintErr("未调用DungeonRoomGroup.InitWeight()来初始化权重!"); + return null; + } + + if (_weightRandomMap.TryGetValue(roomType, out var weightRandom)) + { + return GetRoomList(roomType)[weightRandom.GetRandomIndex()]; + } + + return null; + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/DungeonRoomInfo.cs b/DungeonShooting_Godot/src/framework/map/DungeonRoomInfo.cs index 8a3e4b2..72a8801 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonRoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonRoomInfo.cs @@ -48,4 +48,10 @@ /// [JsonInclude] public string FileName; + + /// + /// 房间权重, 值越大, 生成地牢是越容易出现该房间 + /// + [JsonInclude] + public int Weight = DungeonRoomTemplate.DefaultWeight; } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/DungeonRoomTemplate.cs b/DungeonShooting_Godot/src/framework/map/DungeonRoomTemplate.cs index 7f6025d..74a3748 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonRoomTemplate.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonRoomTemplate.cs @@ -10,11 +10,34 @@ public partial class DungeonRoomTemplate : TileMap { /// + /// 默认权重值 + /// + public const int DefaultWeight = 100; + + /// /// 是否启用编辑模式 /// [Export] public bool EnableEdit = false; + /// + /// 房间权重, 值越大, 生成地牢是越容易出现该房间 + /// + [Export(PropertyHint.Range, "1, 500")] + public int Weight + { + get => _weight; + set + { + _weight = value; + _changeWeight = true; + _changeWeightTimer = 0; + } + } + private int _weight = DefaultWeight; + private bool _changeWeight = false; + private float _changeWeightTimer = 0; + #if TOOLS //是否悬停在线上 private bool _hover = false; @@ -576,6 +599,19 @@ { _clickSave = false; } + + //权重发生改变 + if (_changeWeight) + { + _changeWeightTimer += (float)delta; + if (_changeWeightTimer > 1) + { + _changeWeightTimer = 0; + _changeWeight = false; + //权重改变, 保存数据 + TriggerSave(); + } + } } private void ClearState() @@ -776,7 +812,7 @@ var polygonData = _dungeonTile.GetPolygonData(); var rect = GetUsedRect(); SaveConfig(_dungeonRoomInfo.DoorAreaInfos, rect.Position, rect.Size, polygonData.ToList(), - _dungeonRoomInfo.GroupName, _dungeonRoomInfo.RoomType, Name); + _dungeonRoomInfo.GroupName, _dungeonRoomInfo.RoomType, Name, Weight); } /// @@ -794,7 +830,8 @@ /// /// 保存房间配置 /// - public static void SaveConfig(List doorConfigs, Vector2I position, Vector2I size, List polygonData, string groupName, DungeonRoomType roomType, string fileName) + public static void SaveConfig(List doorConfigs, Vector2I position, Vector2I size, List polygonData, + string groupName, DungeonRoomType roomType, string fileName, int weight) { //存入本地 var path = GameConfig.RoomTileDataDir + groupName + "/" + DungeonRoomTypeToString(roomType); @@ -811,6 +848,7 @@ roomInfo.RoomType = roomType; roomInfo.GroupName = groupName; roomInfo.FileName = fileName; + roomInfo.Weight = weight; var config = new JsonSerializerOptions(); config.WriteIndented = true; @@ -840,6 +878,8 @@ { doorAreaInfo.CalcPosition(mapRect.Position, mapRect.Size); } + + Weight = _dungeonRoomInfo.Weight; } catch (Exception e) { @@ -885,6 +925,11 @@ { roomInfo.FileName = obj["FileName"].AsString(); } + + if (obj.ContainsKey("Weight")) + { + roomInfo.Weight = obj["Weight"].AsInt32(); + } if (obj.ContainsKey("DoorAreaInfos")) {