diff --git a/DungeonShooting_Godot/prefab/ui/MapEditorCreateMark.tscn b/DungeonShooting_Godot/prefab/ui/MapEditorCreateMark.tscn index 5855bc9..a72afc0 100644 --- a/DungeonShooting_Godot/prefab/ui/MapEditorCreateMark.tscn +++ b/DungeonShooting_Godot/prefab/ui/MapEditorCreateMark.tscn @@ -291,7 +291,7 @@ vertical_alignment = 1 autowrap_mode = 3 -[node name="LineEdit" type="SpinBox" parent="MarginContainer/VBoxContainer/Panel/MarginContainer/VBoxContainer/ScrollContainer/MarkObject/VBoxContainer/HBoxContainer"] +[node name="WeightEdit" type="SpinBox" parent="MarginContainer/VBoxContainer/Panel/MarginContainer/VBoxContainer/ScrollContainer/MarkObject/VBoxContainer/HBoxContainer"] custom_minimum_size = Vector2(150, 43) layout_mode = 2 size_flags_vertical = 4 diff --git a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json index 0d0481c..6f78da4 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/GroupConfig.json @@ -31,7 +31,7 @@ ], "OutletList": [ { - "Ready": false, + "Ready": true, "RoomPath": "resource/map/tileMaps/TestGroup1/outlet/End1/End1_roomInfo.json", "TilePath": "resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json", "PreinstallPath": "resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json" diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json index 3afe649..2d774c3 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_preinstall.json @@ -1 +1 @@ -[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":23,"Y":-36},"Size":{"X":16,"Y":120},"DelayTime":0,"MarkList":[{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"}}]}],[{"Position":{"X":61,"Y":34},"Size":{"X":86,"Y":72},"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":100,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"}}]}]]},{"Name":"test2","Weight":150,"Remark":"","WaveList":[[{"Position":{"X":65,"Y":32},"Size":{"X":75,"Y":37},"DelayTime":0,"MarkList":[{"Id":"weapon0002","Weight":100,"Attr":{"CurrAmmon":"7","ResidueAmmo":"70"}}]}]]}] \ No newline at end of file +[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":-11,"Y":-85},"Size":{"X":110,"Y":27},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0001","Weight":100,"Attr":{"CurrAmmon":"30","ResidueAmmo":"210"}}]},{"Position":{"X":64,"Y":27},"Size":{"X":94,"Y":60},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0003","Weight":100,"Attr":{"CurrAmmon":"12","ResidueAmmo":"90"}},{"Id":"weapon0006","Weight":100,"Attr":{"CurrAmmon":"20","ResidueAmmo":"300"}}]}],[{"Position":{"X":-26,"Y":-13},"Size":{"X":76,"Y":10},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"weapon0007","Weight":200,"Attr":{"CurrAmmon":"60","ResidueAmmo":"300"}},{"Id":"enemy0001","Weight":50,"Attr":{"Weapon":"weapon0006","CurrAmmon":"20","ResidueAmmo":"20"}}]}]]},{"Name":"test2","Weight":200,"Remark":"","WaveList":[[{"Position":{"X":24,"Y":-46},"Size":{"X":16,"Y":94},"SpecialMarkType":0,"DelayTime":0,"MarkList":[{"Id":"prop5000","Weight":30,"Attr":null},{"Id":"prop0005","Weight":90,"Attr":null}]}],[{"Position":{"X":67,"Y":27},"Size":{"X":85,"Y":48},"SpecialMarkType":0,"DelayTime":1,"MarkList":[{"Id":"enemy0001","Weight":60,"Attr":{"Weapon":"weapon0001","CurrAmmon":"30","ResidueAmmo":"30"}},{"Id":"enemy0001","Weight":100,"Attr":{"Weapon":"weapon0003","CurrAmmon":"12","ResidueAmmo":"12"}}]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_roomInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_roomInfo.json index 22d425f..180c741 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_roomInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/battle/Room1/Room1_roomInfo.json @@ -1 +1 @@ -{"Position":{"X":-6,"Y":-13},"Size":{"X":15,"Y":22},"DoorAreaInfos":[{"Direction":0,"Start":160,"End":256},{"Direction":1,"Start":16,"End":272},{"Direction":3,"Start":48,"End":176},{"Direction":0,"Start":16,"End":96}],"GroupName":"TestGroup1","RoomType":0,"RoomName":"Room1","Weight":100,"Remark":""} \ No newline at end of file +{"Position":{"X":-6,"Y":-13},"Size":{"X":15,"Y":22},"DoorAreaInfos":[{"Direction":0,"Start":144,"End":240},{"Direction":1,"Start":16,"End":272},{"Direction":3,"Start":48,"End":176},{"Direction":0,"Start":16,"End":80},{"Direction":2,"Start":96,"End":208}],"GroupName":"TestGroup1","RoomType":0,"RoomName":"Room1","Weight":100,"Remark":""} \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json index cfb7f0f..362fdb1 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/inlet/Start1/Start1_preinstall.json @@ -1 +1 @@ -[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":128,"Y":113},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]}]]}] \ No newline at end of file +[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[{"Position":{"X":137,"Y":137},"Size":{"X":0,"Y":0},"SpecialMarkType":1,"DelayTime":0,"MarkList":[]}]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json index 0637a08..ce70790 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_preinstall.json @@ -1 +1 @@ -[] \ No newline at end of file +[{"Name":"test1","Weight":100,"Remark":"","WaveList":[[]]}] \ No newline at end of file diff --git a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json index 3f92b0e..34d5dc3 100644 --- a/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json +++ b/DungeonShooting_Godot/resource/map/tileMaps/TestGroup1/outlet/End1/End1_tileInfo.json @@ -1 +1 @@ -{"NavigationList":[{"Type":0,"Points":[-56,-72,104,-72,104,64,-56,64]}],"Floor":[-4,-5,0,0,8,-4,-4,0,0,8,-4,-3,0,0,8,-4,-2,0,0,8,-4,-1,0,0,8,-4,0,0,0,8,-4,1,0,0,8,-4,2,0,0,8,-4,3,0,0,8,-3,-5,0,0,8,-3,-4,0,0,8,-3,-3,0,0,8,-3,-2,0,0,8,-3,-1,0,0,8,-3,0,0,0,8,-3,1,0,0,8,-3,2,0,0,8,-3,3,0,0,8,-2,-5,0,0,8,-2,-4,0,0,8,-2,-3,0,0,8,-2,-2,0,0,8,-2,-1,0,0,8,-2,0,0,0,8,-2,1,0,0,8,-2,2,0,0,8,-2,3,0,0,8,-1,-5,0,0,8,-1,-4,0,0,8,-1,-3,0,0,8,-1,-2,0,0,8,-1,-1,0,0,8,-1,0,0,0,8,-1,1,0,0,8,-1,2,0,0,8,-1,3,0,0,8,0,-5,0,0,8,0,-4,0,0,8,0,-3,0,0,8,0,-2,0,0,8,0,-1,0,0,8,0,0,0,0,8,0,1,0,0,8,0,2,0,0,8,0,3,0,0,8,1,-5,0,0,8,1,-4,0,0,8,1,-3,0,0,8,1,-2,0,0,8,1,-1,0,0,8,1,0,0,0,8,1,1,0,0,8,1,2,0,0,8,1,3,0,0,8,2,-5,0,0,8,2,-4,0,0,8,2,-3,0,0,8,2,-2,0,0,8,2,-1,0,0,8,2,0,0,0,8,2,1,0,0,8,2,2,0,0,8,2,3,0,0,8,3,-5,0,0,8,3,-4,0,0,8,3,-3,0,0,8,3,-2,0,0,8,3,-1,0,0,8,3,0,0,0,8,3,1,0,0,8,3,2,0,0,8,3,3,0,0,8,4,-5,0,0,8,4,-4,0,0,8,4,-3,0,0,8,4,-2,0,0,8,4,-1,0,0,8,4,0,0,0,8,4,1,0,0,8,4,2,0,0,8,4,3,0,0,8,5,-5,0,0,8,5,-4,0,0,8,5,-3,0,0,8,5,-2,0,0,8,5,-1,0,0,8,5,0,0,0,8,5,1,0,0,8,5,2,0,0,8,5,3,0,0,8,6,-5,0,0,8,6,-4,0,0,8,6,-3,0,0,8,6,-2,0,0,8,6,-1,0,0,8,6,0,0,0,8,6,1,0,0,8,6,2,0,0,8,6,3,0,0,8],"Middle":[-4,-6,0,2,7,-3,-6,0,2,7,-2,-6,0,2,7,-1,-6,0,2,7,0,-6,0,2,7,1,-6,0,2,7,2,-6,0,2,7,3,-6,0,2,7,4,-6,0,2,7,5,-6,0,2,7,6,-6,0,2,7],"Top":[-5,-6,0,3,4,-5,-5,0,3,3,-5,-4,0,3,3,-5,-3,0,3,3,-5,-2,0,3,3,-5,-1,0,3,3,-5,0,0,3,3,-5,1,0,3,3,-5,2,0,3,3,-5,3,0,3,3,-5,4,0,11,2,-4,4,0,2,2,-3,4,0,2,2,-2,4,0,2,2,-1,4,0,2,2,0,4,0,2,2,1,4,0,2,2,2,4,0,2,2,3,4,0,2,2,4,4,0,2,2,5,4,0,2,2,6,4,0,2,2,7,-6,0,1,4,7,-5,0,1,3,7,-4,0,1,3,7,-3,0,1,3,7,-2,0,1,3,7,-1,0,1,3,7,0,0,1,3,7,1,0,1,3,7,2,0,1,3,7,3,0,1,3,7,4,0,13,2]} \ No newline at end of file +{"NavigationList":[{"Type":0,"Points":[-56,-72,104,-72,104,64,-56,64]}],"Floor":[6,3,0,0,8,6,2,0,0,8,6,1,0,0,8,6,0,0,0,8,6,-1,0,0,8,6,-2,0,0,8,6,-3,0,0,8,6,-4,0,0,8,6,-5,0,0,8,5,3,0,0,8,5,2,0,0,8,5,1,0,0,8,5,0,0,0,8,5,-1,0,0,8,5,-2,0,0,8,5,-3,0,0,8,5,-4,0,0,8,5,-5,0,0,8,4,3,0,0,8,4,2,0,0,8,4,1,0,0,8,4,0,0,0,8,4,-1,0,0,8,4,-2,0,0,8,4,-3,0,0,8,4,-4,0,0,8,4,-5,0,0,8,3,3,0,0,8,3,2,0,0,8,3,1,0,0,8,3,0,0,0,8,3,-1,0,0,8,3,-2,0,0,8,3,-3,0,0,8,3,-4,0,0,8,3,-5,0,0,8,2,3,0,0,8,2,2,0,0,8,2,1,0,0,8,2,0,0,0,8,2,-1,0,0,8,2,-2,0,0,8,2,-3,0,0,8,2,-4,0,0,8,2,-5,0,0,8,1,3,0,0,8,1,2,0,0,8,1,1,0,0,8,1,0,0,0,8,1,-1,0,0,8,1,-2,0,0,8,1,-3,0,0,8,1,-4,0,0,8,1,-5,0,0,8,0,3,0,0,8,0,2,0,0,8,0,1,0,0,8,0,0,0,0,8,0,-1,0,0,8,0,-2,0,0,8,0,-3,0,0,8,0,-4,0,0,8,0,-5,0,0,8,-1,3,0,0,8,-1,2,0,0,8,-1,1,0,0,8,-1,0,0,0,8,-1,-1,0,0,8,-1,-2,0,0,8,-1,-3,0,0,8,-1,-4,0,0,8,-1,-5,0,0,8,-2,3,0,0,8,-2,2,0,0,8,-2,1,0,0,8,-2,0,0,0,8,-2,-1,0,0,8,-2,-2,0,0,8,-2,-3,0,0,8,-2,-4,0,0,8,-2,-5,0,0,8,-3,3,0,0,8,-3,2,0,0,8,-3,1,0,0,8,-3,0,0,0,8,-3,-1,0,0,8,-3,-2,0,0,8,-3,-3,0,0,8,-3,-4,0,0,8,-3,-5,0,0,8,-4,3,0,0,8,-4,2,0,0,8,-4,1,0,0,8,-4,0,0,0,8,-4,-1,0,0,8,-4,-2,0,0,8,-4,-3,0,0,8,-4,-4,0,0,8,-4,-5,0,0,8],"Middle":[-4,-6,0,2,7,-3,-6,0,2,7,-2,-6,0,2,7,-1,-6,0,2,7,0,-6,0,2,7,1,-6,0,2,7,2,-6,0,2,7,3,-6,0,2,7,4,-6,0,2,7,5,-6,0,2,7,6,-6,0,2,7],"Top":[-5,-6,0,3,4,-5,-5,0,3,3,-5,-4,0,3,3,-5,-3,0,3,3,-5,-2,0,3,3,-5,-1,0,3,3,-5,0,0,3,3,-5,1,0,3,3,-5,2,0,3,3,-5,3,0,3,3,-5,4,0,11,2,-4,4,0,2,2,-3,4,0,2,2,-2,4,0,2,2,-1,4,0,2,2,0,4,0,2,2,1,4,0,2,2,2,4,0,2,2,3,4,0,2,2,4,4,0,2,2,5,4,0,2,2,6,4,0,2,2,7,-6,0,1,4,7,-5,0,1,3,7,-4,0,1,3,7,-3,0,1,3,7,-2,0,1,3,7,-1,0,1,3,7,0,0,1,3,7,1,0,1,3,7,2,0,1,3,7,3,0,1,3,7,4,0,13,2]} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/common/SeedRandom.cs b/DungeonShooting_Godot/src/framework/common/SeedRandom.cs index bc33910..35da336 100644 --- a/DungeonShooting_Godot/src/framework/common/SeedRandom.cs +++ b/DungeonShooting_Godot/src/framework/common/SeedRandom.cs @@ -145,4 +145,31 @@ return RandomRangeInt(0, weightList.Count - 1); } + + /// + /// 从权重列表中随机抽取下标值 + /// + public int RandomWeight(int[] weightList) + { + // 计算总权重 + var totalWeight = 0; + foreach (var weight in weightList) + { + totalWeight += weight; + } + + var randomNumber = _random.Next(totalWeight); + var currentWeight = 0; + for (var i = 0; i < weightList.Length; i++) + { + var value = weightList[i]; + currentWeight += value; + if (randomNumber < currentWeight) + { + return i; + } + } + + return RandomRangeInt(0, weightList.Length - 1); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/common/Utils.cs b/DungeonShooting_Godot/src/framework/common/Utils.cs index 6d6802c..ea77986 100644 --- a/DungeonShooting_Godot/src/framework/common/Utils.cs +++ b/DungeonShooting_Godot/src/framework/common/Utils.cs @@ -171,94 +171,4 @@ return pos.X >= rect2.Position.X && pos.X <= rect2.Position.X + rect2.Size.X && pos.Y >= rect2.Position.Y && pos.Y <= rect2.Position.Y + rect2.Size.Y; } - - /// - /// 使用快速排序算法对 arr 进行排序操作 - /// - /// 需要进行排序的数组 - /// 自定义比较规则 - public static void QuickSort(T[] arr, Comparison comparison) - { - QuickSort(arr, 0, arr.Length - 1, comparison); - } - - /// - /// 使用快速排序算法对 arr 进行排序操作 - /// - /// 需要进行排序的数组 - /// 自定义比较规则 - public static void QuickSort(List arr, Comparison comparison) - { - QuickSort(arr, 0, arr.Count - 1, comparison); - } - - private static void QuickSort(T[] arr, int low, int high, Comparison comparison) - { - if (low < high) - { - int pivotIndex = Partition(arr, low, high, comparison); - QuickSort(arr, low, pivotIndex - 1, comparison); - QuickSort(arr, pivotIndex + 1, high, comparison); - } - } - - private static void QuickSort(List arr, int low, int high, Comparison comparison) - { - if (low < high) - { - int pivotIndex = Partition(arr, low, high, comparison); - QuickSort(arr, low, pivotIndex - 1, comparison); - QuickSort(arr, pivotIndex + 1, high, comparison); - } - } - - private static int Partition(T[] arr, int low, int high, Comparison comparison) - { - T pivot = arr[high]; - int i = low - 1; - - for (int j = low; j < high; j++) - { - if (comparison(arr[j], pivot) < 0) - { - i++; - Swap(arr, i, j); - } - } - - Swap(arr, i + 1, high); - return i + 1; - } - - private static int Partition(List arr, int low, int high, Comparison comparison) - { - T pivot = arr[high]; - int i = low - 1; - - for (int j = low; j < high; j++) - { - if (comparison(arr[j], pivot) < 0) - { - i++; - Swap(arr, i, j); - } - } - - Swap(arr, i + 1, high); - return i + 1; - } - - private static void Swap(T[] arr, int i, int j) - { - T temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } - - private static void Swap(List arr, int i, int j) - { - T temp = arr[i]; - arr[i] = arr[j]; - arr[j] = temp; - } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs index 1e7bbba..ac86df0 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTileMap.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; +using System.Linq; using Godot; /// @@ -108,10 +109,27 @@ var pos = new Vector2I(roomInfo.Position.X + posX - rectPos.X, roomInfo.Position.Y + posY - rectPos.Y); _tileRoot.SetCell(GameConfig.TopMapLayer, pos, sourceId, new Vector2I(atlasCoordsX, atlasCoordsY)); } + //随机选择预设 + RoomPreinstallInfo preinstallInfo; + if (roomInfo.RoomSplit.Preinstall.Count == 1) + { + preinstallInfo = roomInfo.RoomSplit.Preinstall[0]; + } + else + { + var weights = roomInfo.RoomSplit.Preinstall.Select(info => info.Weight).ToArray(); + var index = random.RandomWeight(weights); + preinstallInfo = roomInfo.RoomSplit.Preinstall[index]; + } + + var roomPreinstall = new RoomPreinstall(roomInfo, preinstallInfo); + roomInfo.RoomPreinstall = roomPreinstall; + //执行预处理操作 + roomPreinstall.Pretreatment(random); //初始化标记 //roomInfo.RoomSplit.Preinstall. - + //roomInfo.RoomSplit.TileInfo. // var template = ResourceManager.Load(roomInfo.RoomSplit.ScenePath); // var tileInstance = template.Instantiate(); diff --git a/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionAttribute.cs b/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionAttribute.cs index dc0ee12..746d0e1 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionAttribute.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionAttribute.cs @@ -1,10 +1,10 @@ -using System; - -/// -/// 用于 ActivityMark 字段上, 表示当前字段是一个表达式字段 -/// -[AttributeUsage(AttributeTargets.Field)] -public class ActivityExpressionAttribute : Attribute -{ - -} \ No newline at end of file +// using System; +// +// /// +// /// 用于 ActivityMark 字段上, 表示当前字段是一个表达式字段 +// /// +// [AttributeUsage(AttributeTargets.Field)] +// public class ActivityExpressionAttribute : Attribute +// { +// +// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionData.cs b/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionData.cs index 9fc30b9..9e9dc7d 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionData.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/ActivityExpressionData.cs @@ -1,22 +1,22 @@ -using System.Collections.Generic; - -/// -/// -/// -public class ActivityExpressionData -{ - /// - /// 物体名称 - /// - public string Id; - - /// - /// 传入参数 - /// - public Dictionary Args = new Dictionary(); - - public ActivityExpressionData(string id) - { - Id = id; - } -} \ No newline at end of file +// using System.Collections.Generic; +// +// /// +// /// +// /// +// public class ActivityExpressionData +// { +// /// +// /// 物体名称 +// /// +// public string Id; +// +// /// +// /// 传入参数 +// /// +// public Dictionary Args = new Dictionary(); +// +// public ActivityExpressionData(string id) +// { +// Id = id; +// } +// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/mark/ActivityMark.cs b/DungeonShooting_Godot/src/framework/map/mark/ActivityMark.cs index 05a79af..dbe19b2 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/ActivityMark.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/ActivityMark.cs @@ -1,415 +1,415 @@ - -using System; -using System.Collections; -using System.Collections.Generic; -using System.Reflection; -using System.Text.RegularExpressions; -using Godot; - -/// -/// 物体生成标记 -/// -[Tool, GlobalClass] -public partial class ActivityMark : Node2D -{ - /// - /// 物体类型 - /// - [Export] - public ActivityType Type = ActivityType.None; - - /// - /// 创建物体的表达式, 该表达式计算出的id会自动加上 Type 前缀 - /// 例如: 0001(w:100,ca:15,ra:30);0002(w:120,ca:10,ra:20) - /// - [Export(PropertyHint.Expression), ActivityExpression] - public string ItemExpression; - - /// - /// 所在层级 - /// - [Export] - public RoomLayerEnum Layer = RoomLayerEnum.NormalLayer; - - /// - /// 该标记在第几波调用 BeReady, - /// 一个房间内所以敌人清完即可进入下一波 - /// - [Export] - public int WaveNumber = 1; - - /// - /// 延时执行时间,单位:秒 - /// - [Export] - public float DelayTime = 0; - - /// - /// 物体会在该矩形区域内随机位置生成 - /// - [Export] - public Vector2I BirthRect = Vector2I.Zero; - - /// - /// 绘制的颜色 - /// - [Export] - public Color DrawColor = new Color(1, 1, 1, 1); - - /// - /// 物体初始海拔高度 - /// - [ExportGroup("Vertical")] - [Export(PropertyHint.Range, "0, 128")] - public int Altitude = 8; - - /// - /// 物体初始纵轴速度 - /// - [Export(PropertyHint.Range, "-1000,1000,0.1")] - public float VerticalSpeed = 0; - - /// - /// 当前标记所在Tile节点 - /// - public TileMap TileRoot; - - /// - /// 随机数对象 - /// - public SeedRandom Random { get; private set; } - - //是否已经结束 - private bool _isOver = true; - private float _overTimer = 1; - private float _timer = 0; - private RoomInfo _tempRoomInfo; - - //已经计算好要生成的物体 - private Dictionary _currentExpression = new Dictionary(); - - //存储所有 ActivityMark 和子类中被 [ActivityExpression] 标记的字段名称 - private static Dictionary> _activityExpressionMap = new Dictionary>(); - - /// - /// 对生成的物体执行后续操作 - /// - public virtual void Doing(ActivityObjectResult result, RoomInfo roomInfo) - { - } - - public ActivityMark() - { - //扫描所有 ActivityExpression - var type = GetType(); - if (!_activityExpressionMap.ContainsKey(type)) - { - // 获取类型信息 - var fieldInfos = new List(); - var tempList = type.GetFields(BindingFlags.Instance | BindingFlags.Public); - foreach (var s in tempList) - { - if (s.GetCustomAttribute() != null) - { - fieldInfos.Add(s.Name); - } - } - - _activityExpressionMap.Add(type, fieldInfos); - } - } - - public override void _Process(double delta) - { -#if TOOLS - if (Engine.IsEditorHint()) - { - QueueRedraw(); - return; - } -#endif - if (_isOver) - { - _overTimer += (float)delta; - if (_overTimer >= 1) - { - SetActive(false); - } - } - else - { - if (DelayTime > 0) - { - _timer += (float)delta; - if (_timer >= DelayTime) - { - Doing(_tempRoomInfo); - _tempRoomInfo = null; - _isOver = true; - } - } - } - } - - /// - /// 标记准备好了 - /// - public void BeReady(RoomInfo roomInfo) - { - if (_currentExpression == null || Type == ActivityType.Player) - { - return; - } - _isOver = false; - _overTimer = 0; - SetActive(true); - if (DelayTime <= 0) - { - Doing(roomInfo); - _isOver = true; - } - else - { - _timer = 0; - _tempRoomInfo = roomInfo; - } - } - - /// - /// 是否已经结束 - /// - public bool IsOver() - { - return _isOver && _overTimer >= 1; - } - - private void Doing(RoomInfo roomInfo) - { - var result = CreateActivityObjectFromExpression(Type, nameof(ItemExpression)); - - if (result == null || result.ActivityObject == null) - { - return; - } - - result.ActivityObject.VerticalSpeed = VerticalSpeed; - result.ActivityObject.Altitude = Altitude; - var pos = Position; - if (BirthRect != Vector2I.Zero) - { - result.ActivityObject.Position = new Vector2( - Random.RandomRangeInt((int)pos.X - BirthRect.X / 2, (int)pos.X + BirthRect.X / 2), - Random.RandomRangeInt((int)pos.Y - BirthRect.Y / 2, (int)pos.Y + BirthRect.Y / 2) - ); - } - else - { - result.ActivityObject.Position = pos; - } - - result.ActivityObject.StartCoroutine(OnActivityObjectBirth(result.ActivityObject)); - result.ActivityObject.PutDown(Layer); - - var effect1 = ResourceManager.LoadAndInstantiate(ResourcePath.prefab_effect_Effect1_tscn); - effect1.Position = result.ActivityObject.Position + new Vector2(0, -Altitude); - effect1.AddToActivityRoot(RoomLayerEnum.NormalLayer); - - Doing(result, roomInfo); - } - - /// - /// 生成 ActivityObject 时调用, 用于出生时的动画效果 - /// - private IEnumerator OnActivityObjectBirth(ActivityObject instance) - { - var a = 1.0f; - instance.SetBlendColor(Colors.White); - //禁用自定义行为 - instance.EnableCustomBehavior = false; - //禁用下坠 - instance.EnableVerticalMotion = false; - - for (var i = 0; i < 10; i++) - { - instance.SetBlendSchedule(a); - yield return 0; - } - - while (a > 0) - { - instance.SetBlendSchedule(a); - a -= 0.05f; - yield return 0; - } - - //启用自定义行为 - instance.EnableCustomBehavior = true; - //启用下坠 - instance.EnableVerticalMotion = true; - } - -#if TOOLS - public override void _Draw() - { - if (Engine.IsEditorHint() || GameApplication.Instance.Debug) - { - var drawColor = DrawColor; - - //如果在编辑器中选中了该节点, 则绘更改绘制颜色的透明度 - var selectedNodes = Plugin.Plugin.Instance?.GetEditorInterface()?.GetSelection()?.GetSelectedNodes(); - if (selectedNodes != null && selectedNodes.Contains(this)) - { - drawColor.A = 1f; - } - else - { - drawColor.A = 0.5f; - } - - DrawLine(new Vector2(-2, -2), new Vector2(2, 2), drawColor, 1f); - DrawLine(new Vector2(-2, 2), new Vector2(2, -2), drawColor, 1f); - - if (BirthRect != Vector2.Zero) - { - DrawRect(new Rect2(-BirthRect / 2, BirthRect), drawColor, false, 0.5f); - } - - DrawString(ResourceManager.DefaultFont12Px, new Vector2(-14, 12), WaveNumber.ToString(), HorizontalAlignment.Center, 28, 12); - } - } -#endif - - /// - /// 设置当前节点是否是活动状态 - /// - private void SetActive(bool flag) - { - // SetProcess(flag); - // SetPhysicsProcess(flag); - // SetProcessInput(flag); - // Visible = flag; - - var parent = GetParent(); - if (flag) - { - if (parent == null) - { - TileRoot.AddChild(this); - } - else if (parent != TileRoot) - { - parent.RemoveChild(this); - TileRoot.AddChild(this); - } - Owner = TileRoot; - } - else - { - if (parent != null) - { - parent.RemoveChild(this); - Owner = null; - } - } - } - - //----------------------------------------------------------------------------------------------------- - - /// - /// 执行预处理操作 - /// - public void Pretreatment(SeedRandom random) - { - Random = random; - if (_activityExpressionMap.TryGetValue(GetType(), out var list)) - { - foreach (var field in list) - { - Pretreatment(field); - } - } - } - - private void Pretreatment(string field) - { - var expressionStr = GetType().GetField(field)?.GetValue(this) as string; - if (string.IsNullOrEmpty(expressionStr)) - { - _currentExpression.Add(field, new ActivityExpressionData("")); - return; - } - var activityExpression = Parse(expressionStr); - if (activityExpression.Count > 0) - { - //权重列表 - var list = new List(); - for (var i = 0; i < activityExpression.Count; i++) - { - var item = activityExpression[i]; - if (item.Args.TryGetValue("weight", out var weight)) //获取自定义权重值 - { - list.Add(int.Parse(weight)); - } - else //默认权重100 - { - item.Args.Add("weight", "100"); - list.Add(100); - } - } - //根据权重随机值 - var index = Random.RandomWeight(list); - _currentExpression.Add(field, activityExpression[index]); - } - else - { - _currentExpression.Add(field, new ActivityExpressionData("")); - } - } - - private List Parse(string str) - { - var list = new List(); - var exps = str.Split(';'); - - for (var i = 0; i < exps.Length; i++) - { - var exp = exps[i]; - //去除空格 - exp = Regex.Replace(exp, "\\s", ""); - if (string.IsNullOrEmpty(exp)) - { - continue; - } - - //验证语法 - if (Regex.IsMatch(exp, "^\\w+(\\((\\w+:\\w+)*(,\\w+:\\w+)*\\))?$")) - { - if (!exp.Contains('(')) //没有参数 - { - list.Add(new ActivityExpressionData(exp)); - } - else - { - var name = Regex.Match(exp, "^\\w+").Value; - var activityExpression = new ActivityExpressionData(name); - var paramsResult = Regex.Matches(exp, "\\w+:\\w+"); - if (paramsResult.Count > 0) - { - foreach (Match result in paramsResult) - { - var valSplit = result.Value.Split(':'); - activityExpression.Args.Add(valSplit[0], valSplit[1]); - } - } - list.Add(activityExpression); - } - } - else //语法异常 - { - throw new Exception("表达式语法错误: " + exp); - } - } - - return list; - } -} \ No newline at end of file +// +// using System; +// using System.Collections; +// using System.Collections.Generic; +// using System.Reflection; +// using System.Text.RegularExpressions; +// using Godot; +// +// /// +// /// 物体生成标记 +// /// +// [Tool, GlobalClass] +// public partial class ActivityMark : Node2D +// { +// /// +// /// 物体类型 +// /// +// [Export] +// public ActivityType Type = ActivityType.None; +// +// /// +// /// 创建物体的表达式, 该表达式计算出的id会自动加上 Type 前缀 +// /// 例如: 0001(w:100,ca:15,ra:30);0002(w:120,ca:10,ra:20) +// /// +// [Export(PropertyHint.Expression), ActivityExpression] +// public string ItemExpression; +// +// /// +// /// 所在层级 +// /// +// [Export] +// public RoomLayerEnum Layer = RoomLayerEnum.NormalLayer; +// +// /// +// /// 该标记在第几波调用 BeReady, +// /// 一个房间内所以敌人清完即可进入下一波 +// /// +// [Export] +// public int WaveNumber = 1; +// +// /// +// /// 延时执行时间,单位:秒 +// /// +// [Export] +// public float DelayTime = 0; +// +// /// +// /// 物体会在该矩形区域内随机位置生成 +// /// +// [Export] +// public Vector2I BirthRect = Vector2I.Zero; +// +// /// +// /// 绘制的颜色 +// /// +// [Export] +// public Color DrawColor = new Color(1, 1, 1, 1); +// +// /// +// /// 物体初始海拔高度 +// /// +// [ExportGroup("Vertical")] +// [Export(PropertyHint.Range, "0, 128")] +// public int Altitude = 8; +// +// /// +// /// 物体初始纵轴速度 +// /// +// [Export(PropertyHint.Range, "-1000,1000,0.1")] +// public float VerticalSpeed = 0; +// +// /// +// /// 当前标记所在Tile节点 +// /// +// public TileMap TileRoot; +// +// /// +// /// 随机数对象 +// /// +// public SeedRandom Random { get; private set; } +// +// //是否已经结束 +// private bool _isOver = true; +// private float _overTimer = 1; +// private float _timer = 0; +// private RoomInfo _tempRoomInfo; +// +// //已经计算好要生成的物体 +// private Dictionary _currentExpression = new Dictionary(); +// +// //存储所有 ActivityMark 和子类中被 [ActivityExpression] 标记的字段名称 +// private static Dictionary> _activityExpressionMap = new Dictionary>(); +// +// /// +// /// 对生成的物体执行后续操作 +// /// +// public virtual void Doing(ActivityObjectResult result, RoomInfo roomInfo) +// { +// } +// +// public ActivityMark() +// { +// //扫描所有 ActivityExpression +// var type = GetType(); +// if (!_activityExpressionMap.ContainsKey(type)) +// { +// // 获取类型信息 +// var fieldInfos = new List(); +// var tempList = type.GetFields(BindingFlags.Instance | BindingFlags.Public); +// foreach (var s in tempList) +// { +// if (s.GetCustomAttribute() != null) +// { +// fieldInfos.Add(s.Name); +// } +// } +// +// _activityExpressionMap.Add(type, fieldInfos); +// } +// } +// +// public override void _Process(double delta) +// { +// #if TOOLS +// if (Engine.IsEditorHint()) +// { +// QueueRedraw(); +// return; +// } +// #endif +// if (_isOver) +// { +// _overTimer += (float)delta; +// if (_overTimer >= 1) +// { +// SetActive(false); +// } +// } +// else +// { +// if (DelayTime > 0) +// { +// _timer += (float)delta; +// if (_timer >= DelayTime) +// { +// Doing(_tempRoomInfo); +// _tempRoomInfo = null; +// _isOver = true; +// } +// } +// } +// } +// +// /// +// /// 标记准备好了 +// /// +// public void BeReady(RoomInfo roomInfo) +// { +// if (_currentExpression == null || Type == ActivityType.Player) +// { +// return; +// } +// _isOver = false; +// _overTimer = 0; +// SetActive(true); +// if (DelayTime <= 0) +// { +// Doing(roomInfo); +// _isOver = true; +// } +// else +// { +// _timer = 0; +// _tempRoomInfo = roomInfo; +// } +// } +// +// /// +// /// 是否已经结束 +// /// +// public bool IsOver() +// { +// return _isOver && _overTimer >= 1; +// } +// +// private void Doing(RoomInfo roomInfo) +// { +// var result = CreateActivityObjectFromExpression(Type, nameof(ItemExpression)); +// +// if (result == null || result.ActivityObject == null) +// { +// return; +// } +// +// result.ActivityObject.VerticalSpeed = VerticalSpeed; +// result.ActivityObject.Altitude = Altitude; +// var pos = Position; +// if (BirthRect != Vector2I.Zero) +// { +// result.ActivityObject.Position = new Vector2( +// Random.RandomRangeInt((int)pos.X - BirthRect.X / 2, (int)pos.X + BirthRect.X / 2), +// Random.RandomRangeInt((int)pos.Y - BirthRect.Y / 2, (int)pos.Y + BirthRect.Y / 2) +// ); +// } +// else +// { +// result.ActivityObject.Position = pos; +// } +// +// result.ActivityObject.StartCoroutine(OnActivityObjectBirth(result.ActivityObject)); +// result.ActivityObject.PutDown(Layer); +// +// var effect1 = ResourceManager.LoadAndInstantiate(ResourcePath.prefab_effect_Effect1_tscn); +// effect1.Position = result.ActivityObject.Position + new Vector2(0, -Altitude); +// effect1.AddToActivityRoot(RoomLayerEnum.NormalLayer); +// +// Doing(result, roomInfo); +// } +// +// /// +// /// 生成 ActivityObject 时调用, 用于出生时的动画效果 +// /// +// private IEnumerator OnActivityObjectBirth(ActivityObject instance) +// { +// var a = 1.0f; +// instance.SetBlendColor(Colors.White); +// //禁用自定义行为 +// instance.EnableCustomBehavior = false; +// //禁用下坠 +// instance.EnableVerticalMotion = false; +// +// for (var i = 0; i < 10; i++) +// { +// instance.SetBlendSchedule(a); +// yield return 0; +// } +// +// while (a > 0) +// { +// instance.SetBlendSchedule(a); +// a -= 0.05f; +// yield return 0; +// } +// +// //启用自定义行为 +// instance.EnableCustomBehavior = true; +// //启用下坠 +// instance.EnableVerticalMotion = true; +// } +// +// #if TOOLS +// public override void _Draw() +// { +// if (Engine.IsEditorHint() || GameApplication.Instance.Debug) +// { +// var drawColor = DrawColor; +// +// //如果在编辑器中选中了该节点, 则绘更改绘制颜色的透明度 +// var selectedNodes = Plugin.Plugin.Instance?.GetEditorInterface()?.GetSelection()?.GetSelectedNodes(); +// if (selectedNodes != null && selectedNodes.Contains(this)) +// { +// drawColor.A = 1f; +// } +// else +// { +// drawColor.A = 0.5f; +// } +// +// DrawLine(new Vector2(-2, -2), new Vector2(2, 2), drawColor, 1f); +// DrawLine(new Vector2(-2, 2), new Vector2(2, -2), drawColor, 1f); +// +// if (BirthRect != Vector2.Zero) +// { +// DrawRect(new Rect2(-BirthRect / 2, BirthRect), drawColor, false, 0.5f); +// } +// +// DrawString(ResourceManager.DefaultFont12Px, new Vector2(-14, 12), WaveNumber.ToString(), HorizontalAlignment.Center, 28, 12); +// } +// } +// #endif +// +// /// +// /// 设置当前节点是否是活动状态 +// /// +// private void SetActive(bool flag) +// { +// // SetProcess(flag); +// // SetPhysicsProcess(flag); +// // SetProcessInput(flag); +// // Visible = flag; +// +// var parent = GetParent(); +// if (flag) +// { +// if (parent == null) +// { +// TileRoot.AddChild(this); +// } +// else if (parent != TileRoot) +// { +// parent.RemoveChild(this); +// TileRoot.AddChild(this); +// } +// Owner = TileRoot; +// } +// else +// { +// if (parent != null) +// { +// parent.RemoveChild(this); +// Owner = null; +// } +// } +// } +// +// //----------------------------------------------------------------------------------------------------- +// +// /// +// /// 执行预处理操作 +// /// +// public void Pretreatment(SeedRandom random) +// { +// Random = random; +// if (_activityExpressionMap.TryGetValue(GetType(), out var list)) +// { +// foreach (var field in list) +// { +// Pretreatment(field); +// } +// } +// } +// +// private void Pretreatment(string field) +// { +// var expressionStr = GetType().GetField(field)?.GetValue(this) as string; +// if (string.IsNullOrEmpty(expressionStr)) +// { +// _currentExpression.Add(field, new ActivityExpressionData("")); +// return; +// } +// var activityExpression = Parse(expressionStr); +// if (activityExpression.Count > 0) +// { +// //权重列表 +// var list = new List(); +// for (var i = 0; i < activityExpression.Count; i++) +// { +// var item = activityExpression[i]; +// if (item.Args.TryGetValue("weight", out var weight)) //获取自定义权重值 +// { +// list.Add(int.Parse(weight)); +// } +// else //默认权重100 +// { +// item.Args.Add("weight", "100"); +// list.Add(100); +// } +// } +// //根据权重随机值 +// var index = Random.RandomWeight(list); +// _currentExpression.Add(field, activityExpression[index]); +// } +// else +// { +// _currentExpression.Add(field, new ActivityExpressionData("")); +// } +// } +// +// private List Parse(string str) +// { +// var list = new List(); +// var exps = str.Split(';'); +// +// for (var i = 0; i < exps.Length; i++) +// { +// var exp = exps[i]; +// //去除空格 +// exp = Regex.Replace(exp, "\\s", ""); +// if (string.IsNullOrEmpty(exp)) +// { +// continue; +// } +// +// //验证语法 +// if (Regex.IsMatch(exp, "^\\w+(\\((\\w+:\\w+)*(,\\w+:\\w+)*\\))?$")) +// { +// if (!exp.Contains('(')) //没有参数 +// { +// list.Add(new ActivityExpressionData(exp)); +// } +// else +// { +// var name = Regex.Match(exp, "^\\w+").Value; +// var activityExpression = new ActivityExpressionData(name); +// var paramsResult = Regex.Matches(exp, "\\w+:\\w+"); +// if (paramsResult.Count > 0) +// { +// foreach (Match result in paramsResult) +// { +// var valSplit = result.Value.Split(':'); +// activityExpression.Args.Add(valSplit[0], valSplit[1]); +// } +// } +// list.Add(activityExpression); +// } +// } +// else //语法异常 +// { +// throw new Exception("表达式语法错误: " + exp); +// } +// } +// +// return list; +// } +// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/mark/ActivityMark_HandlerExpression.cs b/DungeonShooting_Godot/src/framework/map/mark/ActivityMark_HandlerExpression.cs index ba82742..2baed5c 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/ActivityMark_HandlerExpression.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/ActivityMark_HandlerExpression.cs @@ -1,72 +1,72 @@ - -using System; -using Godot; - -public partial class ActivityMark -{ - /// - /// 根据预制表达式创建物体并返回 - /// - /// 物体类型 - /// 预制表达式字段名称, 注意是字段名称, 而不是内容 - public ActivityObjectResult CreateActivityObjectFromExpression(ActivityType type, string expressionFieldName) where T : ActivityObject - { - if (_currentExpression.TryGetValue(expressionFieldName, out var expressionData)) - { - if (expressionData.Id == "null") - { - return null; - } - var id = ActivityId.GetIdPrefix(type) + expressionData.Id; - var activityObject = ActivityObject.Create(id); - if (activityObject == null) - { - return null; - } - - HandlerExpressionArgs(type, activityObject, expressionData); - return new ActivityObjectResult(activityObject, expressionData); - } - - GD.PrintErr("未找到表达式字段: " + expressionFieldName + ", 请检查是否有该字段或者该字段加上了[ActivityExpression]标记"); - return null; - } - - private void HandlerExpressionArgs(ActivityType type, ActivityObject instance, ActivityExpressionData expressionData) - { - switch (type) - { - case ActivityType.None: - break; - case ActivityType.Player: - break; - case ActivityType.Test: - break; - case ActivityType.Role: - break; - case ActivityType.Enemy: - break; - case ActivityType.Weapon: - { - var weapon = (Weapon)instance; - //当前弹夹弹药量 - if (expressionData.Args.TryGetValue("CurrAmmon", out var currAmmon)) - { - weapon.SetCurrAmmo(int.Parse(currAmmon)); - } - //备用弹药量 - if (expressionData.Args.TryGetValue("ResidueAmmo", out var residueAmmo)) - { - weapon.SetResidueAmmo(int.Parse(residueAmmo)); - } - } - break; - case ActivityType.Bullet: - break; - case ActivityType.Shell: - break; - case ActivityType.Other: - break; - } - } -} \ No newline at end of file +// +// using System; +// using Godot; +// +// public partial class ActivityMark +// { +// /// +// /// 根据预制表达式创建物体并返回 +// /// +// /// 物体类型 +// /// 预制表达式字段名称, 注意是字段名称, 而不是内容 +// public ActivityObjectResult CreateActivityObjectFromExpression(ActivityType type, string expressionFieldName) where T : ActivityObject +// { +// if (_currentExpression.TryGetValue(expressionFieldName, out var expressionData)) +// { +// if (expressionData.Id == "null") +// { +// return null; +// } +// var id = ActivityId.GetIdPrefix(type) + expressionData.Id; +// var activityObject = ActivityObject.Create(id); +// if (activityObject == null) +// { +// return null; +// } +// +// HandlerExpressionArgs(type, activityObject, expressionData); +// return new ActivityObjectResult(activityObject, expressionData); +// } +// +// GD.PrintErr("未找到表达式字段: " + expressionFieldName + ", 请检查是否有该字段或者该字段加上了[ActivityExpression]标记"); +// return null; +// } +// +// private void HandlerExpressionArgs(ActivityType type, ActivityObject instance, ActivityExpressionData expressionData) +// { +// switch (type) +// { +// case ActivityType.None: +// break; +// case ActivityType.Player: +// break; +// case ActivityType.Test: +// break; +// case ActivityType.Role: +// break; +// case ActivityType.Enemy: +// break; +// case ActivityType.Weapon: +// { +// var weapon = (Weapon)instance; +// //当前弹夹弹药量 +// if (expressionData.Args.TryGetValue("CurrAmmon", out var currAmmon)) +// { +// weapon.SetCurrAmmo(int.Parse(currAmmon)); +// } +// //备用弹药量 +// if (expressionData.Args.TryGetValue("ResidueAmmo", out var residueAmmo)) +// { +// weapon.SetResidueAmmo(int.Parse(residueAmmo)); +// } +// } +// break; +// case ActivityType.Bullet: +// break; +// case ActivityType.Shell: +// break; +// case ActivityType.Other: +// break; +// } +// } +// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/mark/ActivityObjectResult.cs b/DungeonShooting_Godot/src/framework/map/mark/ActivityObjectResult.cs index 2127981..01b4e2e 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/ActivityObjectResult.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/ActivityObjectResult.cs @@ -1,22 +1,22 @@ - -/// -/// 通过表达式创建的 ActivityObject 对象结果集 -/// -public class ActivityObjectResult where T : ActivityObject -{ - /// - /// 实例 - /// - public T ActivityObject; - - /// - /// 创建该对象使用的表达式数据 - /// - public ActivityExpressionData ExpressionData; - - public ActivityObjectResult(T activityObject, ActivityExpressionData expressionData) - { - ActivityObject = activityObject; - ExpressionData = expressionData; - } -} \ No newline at end of file +// +// /// +// /// 通过表达式创建的 ActivityObject 对象结果集 +// /// +// public class ActivityObjectResult where T : ActivityObject +// { +// /// +// /// 实例 +// /// +// public T ActivityObject; +// +// /// +// /// 创建该对象使用的表达式数据 +// /// +// public ActivityExpressionData ExpressionData; +// +// public ActivityObjectResult(T activityObject, ActivityExpressionData expressionData) +// { +// ActivityObject = activityObject; +// ExpressionData = expressionData; +// } +// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs b/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs index 7c0fdc3..241c72b 100644 --- a/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs +++ b/DungeonShooting_Godot/src/framework/map/mark/EnemyMark.cs @@ -1,91 +1,91 @@ - -using Godot; - -/// -/// 针对敌人生成位置的标记 -/// -[Tool, GlobalClass] -public partial class EnemyMark : ActivityMark -{ - /// - /// 脸默认朝向 - /// - public enum FaceDirectionValueEnum - { - /// - /// 随机 - /// - Random, - /// - /// 左边 - /// - Left, - /// - /// 右边 - /// - Right - } - - /// - /// 武器1 id, id会自动加上武器前缀 - /// - [Export(PropertyHint.Expression), ActivityExpression] - public string Weapon1Id; - /// - /// 武器2 id, id会自动加上武器前缀 - /// - [Export(PropertyHint.Expression), ActivityExpression] - public string Weapon2Id; - /// - /// 脸默认的朝向 - /// - [Export] - public FaceDirectionValueEnum FaceDirection = FaceDirectionValueEnum.Random; - - public override void _Ready() - { - Type = ActivityType.Enemy; - Layer = RoomLayerEnum.YSortLayer; - Altitude = 0; - } - - public override void Doing(ActivityObjectResult result, RoomInfo roomInfo) - { - //创建敌人 - var instance = (Enemy)result.ActivityObject; - var pos = instance.Position; - - //脸的朝向 - if (FaceDirection == FaceDirectionValueEnum.Random) - { - instance.Face = Random.RandomBoolean() ? global::FaceDirection.Left : global::FaceDirection.Right; - } - else if (FaceDirection == FaceDirectionValueEnum.Left) - { - instance.Face = global::FaceDirection.Left; - } - else - { - instance.Face = global::FaceDirection.Right; - } - - if (!string.IsNullOrWhiteSpace(Weapon1Id)) - CreateWeapon(instance, pos, nameof(Weapon1Id)); - if (!string.IsNullOrWhiteSpace(Weapon2Id)) - CreateWeapon(instance, pos, nameof(Weapon2Id)); - } - - //生成武器 - private void CreateWeapon(Enemy enemy, Vector2 pos, string fieldName) - { - var result = CreateActivityObjectFromExpression(ActivityType.Weapon, fieldName); - if (result != null) - { - //如果不能放下, 则直接扔地上 - if (!enemy.PickUpWeapon(result.ActivityObject)) - { - result.ActivityObject.PutDown(pos, RoomLayerEnum.NormalLayer); - } - } - } -} \ No newline at end of file +// +// using Godot; +// +// /// +// /// 针对敌人生成位置的标记 +// /// +// [Tool, GlobalClass] +// public partial class EnemyMark : ActivityMark +// { +// /// +// /// 脸默认朝向 +// /// +// public enum FaceDirectionValueEnum +// { +// /// +// /// 随机 +// /// +// Random, +// /// +// /// 左边 +// /// +// Left, +// /// +// /// 右边 +// /// +// Right +// } +// +// /// +// /// 武器1 id, id会自动加上武器前缀 +// /// +// [Export(PropertyHint.Expression), ActivityExpression] +// public string Weapon1Id; +// /// +// /// 武器2 id, id会自动加上武器前缀 +// /// +// [Export(PropertyHint.Expression), ActivityExpression] +// public string Weapon2Id; +// /// +// /// 脸默认的朝向 +// /// +// [Export] +// public FaceDirectionValueEnum FaceDirection = FaceDirectionValueEnum.Random; +// +// public override void _Ready() +// { +// Type = ActivityType.Enemy; +// Layer = RoomLayerEnum.YSortLayer; +// Altitude = 0; +// } +// +// public override void Doing(ActivityObjectResult result, RoomInfo roomInfo) +// { +// //创建敌人 +// var instance = (Enemy)result.ActivityObject; +// var pos = instance.Position; +// +// //脸的朝向 +// if (FaceDirection == FaceDirectionValueEnum.Random) +// { +// instance.Face = Random.RandomBoolean() ? global::FaceDirection.Left : global::FaceDirection.Right; +// } +// else if (FaceDirection == FaceDirectionValueEnum.Left) +// { +// instance.Face = global::FaceDirection.Left; +// } +// else +// { +// instance.Face = global::FaceDirection.Right; +// } +// +// if (!string.IsNullOrWhiteSpace(Weapon1Id)) +// CreateWeapon(instance, pos, nameof(Weapon1Id)); +// if (!string.IsNullOrWhiteSpace(Weapon2Id)) +// CreateWeapon(instance, pos, nameof(Weapon2Id)); +// } +// +// //生成武器 +// private void CreateWeapon(Enemy enemy, Vector2 pos, string fieldName) +// { +// var result = CreateActivityObjectFromExpression(ActivityType.Weapon, fieldName); +// if (result != null) +// { +// //如果不能放下, 则直接扔地上 +// if (!enemy.PickUpWeapon(result.ActivityObject)) +// { +// result.ActivityObject.PutDown(pos, RoomLayerEnum.NormalLayer); +// } +// } +// } +// } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/preinstall/ActivityMark.cs b/DungeonShooting_Godot/src/framework/map/preinstall/ActivityMark.cs new file mode 100644 index 0000000..b4c72cf --- /dev/null +++ b/DungeonShooting_Godot/src/framework/map/preinstall/ActivityMark.cs @@ -0,0 +1,31 @@ + +using System.Collections.Generic; +using Godot; + +public class ActivityMark +{ + /// + /// 物体 Id + /// + public string Id { get; set; } + + /// + /// 刷新位置 + /// + public Vector2 Position { get; set; } + + /// + /// 额外属性 + /// + public Dictionary Attr { get; set; } + + /// + /// 特殊标记类型 + /// + public SpecialMarkType MarkType { get; set; } + + /// + /// 延时时间, 单位: 秒 + /// + public float DelayTime { get; set; } +} \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs b/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs index 193b40b..4a98867 100644 --- a/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs +++ b/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs @@ -1,6 +1,140 @@  -public class RoomPreinstall +using System; +using System.Collections.Generic; +using System.Linq; +using Godot; + +/// +/// 房间预设处理类 +/// +public class RoomPreinstall : IDestroy { + public bool IsDestroyed { get; private set; } + + /// + /// 所属房间对象 + /// + public RoomInfo RoomInfo { get; } + /// + /// 绑定的预设数据 + /// + public RoomPreinstallInfo RoomPreinstallInfo { get; } + + /// + /// 总波数 + /// + public int WaveCount => RoomPreinstallInfo.WaveList.Count; + + /// + /// 波数和标记数据列表 + /// + public List> WaveList { get; } = new List>(); + + private bool _runPretreatment = false; + + public RoomPreinstall(RoomInfo roomInfo, RoomPreinstallInfo roomPreinstallInfo) + { + RoomInfo = roomInfo; + RoomPreinstallInfo = roomPreinstallInfo; + } + + /// + /// 预处理操作 + /// + public void Pretreatment(SeedRandom random) + { + if (_runPretreatment) + { + return; + } + + _runPretreatment = true; + + //确定房间内要生成写啥 + foreach (var markInfos in RoomPreinstallInfo.WaveList) + { + var wave = new List(); + WaveList.Add(wave); + foreach (var markInfo in markInfos) + { + var mark = new ActivityMark(); + if (markInfo.SpecialMarkType == SpecialMarkType.Normal) //普通标记 + { + MarkInfoItem markInfoItem; + if (markInfo.MarkList.Count == 0) + { + continue; + } + else if (markInfo.MarkList.Count == 1) + { + markInfoItem = markInfo.MarkList[0]; + } + else + { + var tempArray = markInfo.MarkList.Select(item => item.Weight).ToArray(); + var index = random.RandomWeight(tempArray); + markInfoItem = markInfo.MarkList[index]; + } + + mark.Id = markInfoItem.Id; + mark.Attr = markInfoItem.Attr; + } + else if (markInfo.SpecialMarkType == SpecialMarkType.BirthPoint) //玩家出生标记 + { + + } + else + { + GD.PrintErr("暂未支持的类型: " + markInfo.SpecialMarkType); + continue; + } + + mark.DelayTime = markInfo.DelayTime; + mark.MarkType = markInfo.SpecialMarkType; + //随机刷新坐标 + var pos = markInfo.Position.AsVector2(); + var birthRect = markInfo.Size.AsVector2(); + var tempPos = new Vector2( + random.RandomRangeInt((int)(pos.X - birthRect.X / 2), (int)(pos.X + birthRect.X / 2)), + random.RandomRangeInt((int)(pos.Y - birthRect.Y / 2), (int)(pos.Y + birthRect.Y / 2)) + ); + var offset = RoomInfo.GetOffsetPosition(); + //var offset = RoomInfo.RoomSplit.RoomInfo.Position.AsVector2I(); + mark.Position = RoomInfo.GetWorldPosition() + (tempPos - offset); + + wave.Add(mark); + } + + //排序操作 + wave.Sort((a, b) => (int)(a.DelayTime * 1000 - b.DelayTime * 1000)); + } + } + + /// + /// 获取房间内的玩家生成标记 + /// + public ActivityMark GetPlayerBirthMark() + { + if (WaveList.Count == 0) + { + return null; + } + + var activityMarks = WaveList[0]; + var activityMark = activityMarks.FirstOrDefault(mark => mark.MarkType == SpecialMarkType.BirthPoint); + return activityMark; + } + + public void Destroy() + { + if (IsDestroyed) + { + return; + } + + IsDestroyed = true; + WaveList.Clear(); + } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs index 70f37e4..378d537 100644 --- a/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/room/RoomInfo.cs @@ -65,9 +65,9 @@ public RoomInfo Prev; /// - /// 物体生成标记 + /// 当前房间使用的预设 /// - public List ActivityMarks = new List(); + public RoomPreinstall RoomPreinstall; /// /// 当前房间归属区域 @@ -86,11 +86,11 @@ public bool IsDestroyed { get; private set; } - private bool _beReady = false; - private bool _waveStart = false; - private int _currWaveIndex = 0; - private int _currWaveNumber = 0; - private List _currActivityMarks = new List(); + // private bool _beReady = false; + // private bool _waveStart = false; + // private int _currWaveIndex = 0; + // private int _currWaveNumber = 0; + //private List _currActivityMarks = new List(); /// /// 获取房间的全局坐标, 单位: 像素 @@ -174,11 +174,17 @@ nextRoom.Destroy(); } Next.Clear(); - foreach (var activityMark in ActivityMarks) + if (RoomPreinstall != null) { - activityMark.QueueFree(); + RoomPreinstall.Destroy(); + RoomPreinstall = null; } - ActivityMarks.Clear(); + + // foreach (var activityMark in ActivityMarks) + // { + // activityMark.QueueFree(); + // } + // ActivityMarks.Clear(); if (StaticImageCanvas != null) { @@ -192,38 +198,38 @@ /// public void BeReady() { - //没有标记, 啥都不要做 - if (ActivityMarks.Count == 0) - { - _beReady = true; - IsSeclusion = false; - return; - } - IsSeclusion = true; - _waveStart = false; - - if (!_beReady) - { - _beReady = true; - //按照 WaveNumber 排序 - ActivityMarks.Sort((x, y) => - { - return x.WaveNumber - y.WaveNumber; - }); - } - - //不是初始房间才能关门 - if (RoomSplit.RoomInfo.RoomType != DungeonRoomType.Inlet) - { - //关门 - foreach (var doorInfo in Doors) - { - doorInfo.Door.CloseDoor(); - } - } - - //执行第一波生成 - NextWave(); + // //没有标记, 啥都不要做 + // if (ActivityMarks.Count == 0) + // { + // _beReady = true; + // IsSeclusion = false; + // return; + // } + // IsSeclusion = true; + // _waveStart = false; + // + // if (!_beReady) + // { + // _beReady = true; + // //按照 WaveNumber 排序 + // ActivityMarks.Sort((x, y) => + // { + // return x.WaveNumber - y.WaveNumber; + // }); + // } + // + // //不是初始房间才能关门 + // if (RoomSplit.RoomInfo.RoomType != DungeonRoomType.Inlet) + // { + // //关门 + // foreach (var doorInfo in Doors) + // { + // doorInfo.Door.CloseDoor(); + // } + // } + // + // //执行第一波生成 + // NextWave(); } /// @@ -231,23 +237,23 @@ /// public void OnClearRoom() { - if (_currWaveIndex >= ActivityMarks.Count) //所有 mark 都走完了 - { - IsSeclusion = false; - _currActivityMarks.Clear(); - //开门 - if (RoomSplit.RoomInfo.RoomType != DungeonRoomType.Inlet) - { - foreach (var doorInfo in Doors) - { - doorInfo.Door.OpenDoor(); - } - } - } - else //执行下一波 - { - NextWave(); - } + // if (_currWaveIndex >= ActivityMarks.Count) //所有 mark 都走完了 + // { + // IsSeclusion = false; + // _currActivityMarks.Clear(); + // //开门 + // if (RoomSplit.RoomInfo.RoomType != DungeonRoomType.Inlet) + // { + // foreach (var doorInfo in Doors) + // { + // doorInfo.Door.OpenDoor(); + // } + // } + // } + // else //执行下一波 + // { + // NextWave(); + // } } /// @@ -255,13 +261,13 @@ /// public bool IsCurrWaveOver() { - for (var i = 0; i < _currActivityMarks.Count; i++) - { - if (!_currActivityMarks[i].IsOver()) - { - return false; - } - } + // for (var i = 0; i < _currActivityMarks.Count; i++) + // { + // if (!_currActivityMarks[i].IsOver()) + // { + // return false; + // } + // } return true; } @@ -271,29 +277,29 @@ /// private void NextWave() { - if (!_waveStart) - { - _waveStart = true; - _currWaveIndex = 0; - _currWaveNumber = ActivityMarks[0].WaveNumber; - } - GD.Print("执行下一波, 当前: " + _currWaveNumber); - - _currActivityMarks.Clear(); - //根据标记生成对象 - for (; _currWaveIndex < ActivityMarks.Count; _currWaveIndex++) - { - var mark = ActivityMarks[_currWaveIndex]; - if (mark.WaveNumber != _currWaveNumber) //当前这波已经执行完成了 - { - _currWaveNumber = mark.WaveNumber; - break; - } - else //生成操作 - { - mark.BeReady(this); - _currActivityMarks.Add(mark); - } - } + // if (!_waveStart) + // { + // _waveStart = true; + // _currWaveIndex = 0; + // _currWaveNumber = ActivityMarks[0].WaveNumber; + // } + // GD.Print("执行下一波, 当前: " + _currWaveNumber); + // + // _currActivityMarks.Clear(); + // //根据标记生成对象 + // for (; _currWaveIndex < ActivityMarks.Count; _currWaveIndex++) + // { + // var mark = ActivityMarks[_currWaveIndex]; + // if (mark.WaveNumber != _currWaveNumber) //当前这波已经执行完成了 + // { + // _currWaveNumber = mark.WaveNumber; + // break; + // } + // else //生成操作 + // { + // mark.BeReady(this); + // _currActivityMarks.Add(mark); + // } + // } } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/serialize/MarkInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/MarkInfo.cs index 56d82bb..41bdd08 100644 --- a/DungeonShooting_Godot/src/framework/map/serialize/MarkInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/serialize/MarkInfo.cs @@ -26,7 +26,7 @@ public SpecialMarkType SpecialMarkType = SpecialMarkType.Normal; /// - /// 延时时间 + /// 延时时间, 单位: 秒 /// [JsonInclude] public float DelayTime; diff --git a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs index 2d907e0..23afa6b 100644 --- a/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs +++ b/DungeonShooting_Godot/src/framework/ui/grid/UiGrid.cs @@ -319,6 +319,7 @@ //取消选中 SelectIndex = -1; var uiCells = _cellList.ToArray(); + _cellList.Clear(); foreach (var uiCell in uiCells) { ReclaimCellInstance(uiCell); @@ -349,7 +350,7 @@ var selectIndex = SelectIndex; var selectCell = GetCell(selectIndex); //执行排序操作 - Utils.QuickSort(_cellList, (a, b) => a.OnSort(b)); + _cellList.Sort((a, b) => a.OnSort(b)); if (selectIndex >= 0) { selectIndex = _cellList.FindIndex(cell => cell == selectCell); diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index f393378..7f1e5a5 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -135,7 +135,7 @@ //SoundManager.PlayMusic(ResourcePath.resource_sound_bgm_Intro_ogg, -17f); //初始房间创建玩家标记 - var playerBirthMark = StartRoomInfo.ActivityMarks.FirstOrDefault(mark => mark.Type == ActivityType.Player); + var playerBirthMark = StartRoomInfo.RoomPreinstall.GetPlayerBirthMark(); //创建玩家 var player = ActivityObject.Create(ActivityObject.Ids.Id_role0001); if (playerBirthMark != null) diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MapEditorCreateMark.cs b/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MapEditorCreateMark.cs index d23a9a4..de98cff 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MapEditorCreateMark.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MapEditorCreateMark.cs @@ -758,12 +758,12 @@ } /// - /// 类型: , 路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.HBoxContainer.LineEdit + /// 类型: , 路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.HBoxContainer.WeightEdit /// - public class LineEdit : UiNode + public class WeightEdit : UiNode { - public LineEdit(MapEditorCreateMarkPanel uiPanel, Godot.SpinBox node) : base(uiPanel, node) { } - public override LineEdit Clone() => new (UiPanel, (Godot.SpinBox)Instance.Duplicate()); + public WeightEdit(MapEditorCreateMarkPanel uiPanel, Godot.SpinBox node) : base(uiPanel, node) { } + public override WeightEdit Clone() => new (UiPanel, (Godot.SpinBox)Instance.Duplicate()); } /// @@ -868,17 +868,17 @@ private TypeLabel _L_TypeLabel; /// - /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.LineEdit + /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.WeightEdit /// - public LineEdit L_LineEdit + public WeightEdit L_WeightEdit { get { - if (_L_LineEdit == null) _L_LineEdit = new LineEdit(UiPanel, Instance.GetNode("LineEdit")); - return _L_LineEdit; + if (_L_WeightEdit == null) _L_WeightEdit = new WeightEdit(UiPanel, Instance.GetNode("WeightEdit")); + return _L_WeightEdit; } } - private LineEdit _L_LineEdit; + private WeightEdit _L_WeightEdit; /// /// 使用 Instance 属性获取当前节点实例对象, 节点类型: , 节点路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.CenterContainer @@ -1449,9 +1449,9 @@ public TypeLabel S_TypeLabel => L_MarginContainer.L_VBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_MarkObject.L_VBoxContainer.L_HBoxContainer.L_TypeLabel; /// - /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.HBoxContainer.LineEdit + /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.HBoxContainer.WeightEdit /// - public LineEdit S_LineEdit => L_MarginContainer.L_VBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_MarkObject.L_VBoxContainer.L_HBoxContainer.L_LineEdit; + public WeightEdit S_WeightEdit => L_MarginContainer.L_VBoxContainer.L_Panel.L_MarginContainer.L_VBoxContainer.L_ScrollContainer.L_MarkObject.L_VBoxContainer.L_HBoxContainer.L_WeightEdit; /// /// 场景中唯一名称的节点, 节点类型: , 节点路径: MapEditorCreateMark.MarginContainer.VBoxContainer.Panel.MarginContainer.VBoxContainer.ScrollContainer.MarkObject.VBoxContainer.HBoxContainer.CenterContainer diff --git a/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MarkObjectCell.cs b/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MarkObjectCell.cs index 3ad5565..b64ec05 100644 --- a/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MarkObjectCell.cs +++ b/DungeonShooting_Godot/src/game/ui/mapEditorCreateMark/MarkObjectCell.cs @@ -52,10 +52,12 @@ if (data.SpecialMarkType == SpecialMarkType.BirthPoint) //出生标记 { CellNode.L_VBoxContainer.L_HBoxContainer.L_CenterContainer.L_DeleteButton.Instance.Visible = false; + CellNode.L_VBoxContainer.L_HBoxContainer.L_WeightEdit.Instance.Visible = false; } else //普通标记 { CellNode.L_VBoxContainer.L_HBoxContainer.L_CenterContainer.L_DeleteButton.Instance.Visible = true; + CellNode.L_VBoxContainer.L_HBoxContainer.L_WeightEdit.Instance.Visible = true; } } @@ -89,6 +91,12 @@ } } } + + if (Data.SpecialMarkType == SpecialMarkType.Normal) + { + markInfoItem.Weight = (int)CellNode.L_VBoxContainer.L_HBoxContainer.L_WeightEdit.Instance.Value; + } + return markInfoItem; }