diff --git "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" index 14b140b..cb919f1 100644 --- "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" +++ "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/TileSet.json" @@ -10,24 +10,15 @@ "_vc": null, "_vr": null, "_vs": null, - "_000_010_010": [ - 0, - 0 - ], + "_000_010_010": null, "_010_010_010": null, "_010_010_000": null, "_000_010_000": null, - "_000_011_010": [ - 16, - 0 - ], + "_000_011_010": null, "_010_011_010": null, "_010_011_000": null, "_000_011_000": null, - "_000_111_010": [ - 32, - 0 - ], + "_000_111_010": null, "_010_111_010": null, "_010_111_000": null, "_000_111_000": null, @@ -62,14 +53,77 @@ "_000_111_111": null, "_011_111_110": null, "_111_111_010": null, - "_000_110_110": [ - 176, - 0 - ], + "_000_110_110": null, "_110_111_110": null, "_110_110_110": null, "_110_110_000": null - } + }, + "Combination": [ + { + "Id": "638401395919585853", + "Name": "\u7EC4\u5408", + "Cells": [ + { + "X": 0, + "Y": 0 + }, + { + "X": 0, + "Y": 16 + }, + { + "X": 0, + "Y": 32 + }, + { + "X": 176, + "Y": 32 + }, + { + "X": 176, + "Y": 48 + }, + { + "X": 176, + "Y": 32 + }, + { + "X": 176, + "Y": 48 + } + ], + "Positions": [ + { + "X": 0, + "Y": 0 + }, + { + "X": 0, + "Y": 16 + }, + { + "X": 0, + "Y": 32 + }, + { + "X": 16, + "Y": 32 + }, + { + "X": 16, + "Y": 48 + }, + { + "X": 32, + "Y": 16 + }, + { + "X": 32, + "Y": 32 + } + ] + } + ] } ] } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs index 5873d44..8670ead 100644 --- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs @@ -1,4 +1,5 @@ +using System.Collections.Generic; using System.Text.Json.Serialization; using Godot; @@ -24,6 +25,12 @@ /// [JsonInclude] public TileSetTerrainInfo Terrain; + + /// + /// 组合数据 + /// + [JsonInclude] + public List Combination; [JsonIgnore] private Image _sourceImage; @@ -36,6 +43,7 @@ public void InitData() { Terrain = new TileSetTerrainInfo(); + Combination = new List(); } /// @@ -72,6 +80,7 @@ var tileSetSourceInfo = new TileSetSourceInfo(); tileSetSourceInfo.Name = Name; tileSetSourceInfo.Terrain = Terrain; + tileSetSourceInfo.Combination = Combination; tileSetSourceInfo.SourcePath = SourcePath; tileSetSourceInfo._sourceImage = _sourceImage; return tileSetSourceInfo; diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs index 053521c..4c7f541 100644 --- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs +++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs @@ -3,7 +3,7 @@ using Godot; /// -/// 地形配置数据 +/// 地形配置数据, 数据都为 int 数组, 下标0和1分别代表x和y, 单位: 像素 /// public class TileSetTerrainInfo { diff --git a/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs b/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs index a83b131..0241586 100644 --- a/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs +++ b/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs @@ -29,6 +29,9 @@ EventManager.AddEventListener(EventEnum.OnTileSetSave, OnTileSetSave); } + /// + /// 将地形掩码存入 TileSetTerrainInfo 中 + /// public static void SetTileSetTerrainBit(TileSetTerrainInfo terrain, int index, byte type, int[] cellData) { if (type == 1) //顶部墙壁 @@ -52,7 +55,52 @@ case 11: terrain._000_110_110 = cellData; break; //第二排 + case 12: terrain._010_010_010 = cellData; break; + case 13: terrain._010_011_010 = cellData; break; + case 14: terrain._010_111_010 = cellData; break; + case 15: terrain._010_110_010 = cellData; break; + case 16: terrain._010_011_011 = cellData; break; + case 17: terrain._011_111_111 = cellData; break; + case 18: terrain._110_111_111 = cellData; break; + case 19: terrain._010_110_110 = cellData; break; + + case 20: terrain._011_011_011 = cellData; break; + case 21: terrain._011_111_110 = cellData; break; + case 22: break; + case 23: terrain._110_111_110 = cellData; break; + + //第三排 + case 24: terrain._010_010_000 = cellData; break; + case 25: terrain._010_011_000 = cellData; break; + case 26: terrain._010_111_000 = cellData; break; + case 27: terrain._010_110_000 = cellData; break; + + case 28: terrain._011_011_010 = cellData; break; + case 29: terrain._111_111_011 = cellData; break; + case 30: terrain._111_111_110 = cellData; break; + case 31: terrain._110_110_010 = cellData; break; + + case 32: terrain._011_111_011 = cellData; break; + case 33: terrain._111_111_111 = cellData; break; + case 34: terrain._110_111_011 = cellData; break; + case 35: terrain._110_110_110 = cellData; break; + + //第四排 + case 36: terrain._000_010_000 = cellData; break; + case 37: terrain._000_011_000 = cellData; break; + case 38: terrain._000_111_000 = cellData; break; + case 39: terrain._000_110_000 = cellData; break; + + case 40: terrain._010_111_110 = cellData; break; + case 41: terrain._011_111_000 = cellData; break; + case 42: terrain._110_111_000 = cellData; break; + case 43: terrain._010_111_011 = cellData; break; + + case 44: terrain._011_011_000 = cellData; break; + case 45: terrain._111_111_000 = cellData; break; + case 46: terrain._111_111_010 = cellData; break; + case 47: terrain._110_110_000 = cellData; break; } } else if (type == 2) //侧方墙壁 @@ -77,10 +125,11 @@ if (o is TileSetInfo tileSetInfo) { var dir = CustomMapPath + tileSetInfo.Name; - if (!Directory.Exists(dir)) + if (Directory.Exists(dir)) { - Directory.CreateDirectory(dir); + Directory.Delete(dir, true); } + Directory.CreateDirectory(dir); var path = dir + "/TileSet.json"; diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs index 40351a0..55a0c9f 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/leftTop/TileEditCombination.cs @@ -175,8 +175,9 @@ var cells = tempCell.ToArray(); var positions = tempPos.ToArray(); - var color = UiNode.UiPanel.EditorPanel.BgColor; - var src = UiNode.UiPanel.EditorPanel.TextureImage; + var tileSetEditorPanel = UiNode.UiPanel.EditorPanel; + var color = tileSetEditorPanel.BgColor; + var src = tileSetEditorPanel.TextureImage; var image = ImportCombinationData.GetPreviewTexture(src, cells, positions); var texture = ImageTexture.CreateFromImage(image); EditorWindowManager.ShowImportCombination("组合", color, texture, (name) => diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs index 388bef7..95bbe07 100644 --- a/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs +++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorCombination/right/TileSelected.cs @@ -5,6 +5,7 @@ public partial class TileSelected : VBoxContainer, IUiNodeScript { private TileSetEditorCombination.RightBg _rightBg; + //存放所有组合数据 private UiGrid _grid; public void SetUiNode(IUiNode uiNode) @@ -28,6 +29,7 @@ { if (obj is ImportCombinationData data) { + _rightBg.UiPanel.EditorPanel.TileSetSourceInfo.Combination.Add(data.CombinationInfo); _grid.Add(data); _grid.Sort(); } @@ -41,6 +43,7 @@ if (obj is ImportCombinationData data) { var uiCell = _grid.Find(c => c.Data.CombinationInfo.Id == data.CombinationInfo.Id); + _rightBg.UiPanel.EditorPanel.TileSetSourceInfo.Combination.Remove(data.CombinationInfo); if (uiCell != null) { _grid.RemoveByIndex(uiCell.Index);