diff --git a/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn b/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn
index e83561b..ed54c7e 100644
--- a/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn
+++ b/DungeonShooting_Godot/prefab/ui/TileSetEditorImport.tscn
@@ -12,6 +12,7 @@
grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_rkxih")
+Layer = null
[node name="ImportPreviewBg" type="ColorRect" parent="."]
layout_mode = 1
diff --git "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test2.png" "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test2.png"
new file mode 100644
index 0000000..a045ee2
--- /dev/null
+++ "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test2.png"
Binary files differ
diff --git "a/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test2.png.import" "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test2.png.import"
new file mode 100644
index 0000000..62cda6b
--- /dev/null
+++ "b/DungeonShooting_Godot/resource/map/tileSet/\346\265\213\350\257\225\346\225\260\346\215\256/Test2.png.import"
@@ -0,0 +1,34 @@
+[remap]
+
+importer="texture"
+type="CompressedTexture2D"
+uid="uid://pgdhntg56f77"
+path="res://.godot/imported/Test2.png-4f1e41d474574169a7bc738f71691230.ctex"
+metadata={
+"vram_texture": false
+}
+
+[deps]
+
+source_file="res://resource/map/tileSet/测试数据/Test2.png"
+dest_files=["res://.godot/imported/Test2.png-4f1e41d474574169a7bc738f71691230.ctex"]
+
+[params]
+
+compress/mode=0
+compress/high_quality=false
+compress/lossy_quality=0.7
+compress/hdr_compression=1
+compress/normal_map=0
+compress/channel_pack=0
+mipmaps/generate=false
+mipmaps/limit=-1
+roughness/mode=0
+roughness/src_normal=""
+process/fix_alpha_border=true
+process/premult_alpha=false
+process/normal_map_invert_y=false
+process/hdr_as_srgb=false
+process/hdr_clamp_exposure=false
+process/size_limit=0
+detect_3d/compress_to=1
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 cb919f1..e2b6879 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"
@@ -3,7 +3,367 @@
"Sources": [
{
"Name": "Test",
- "SourcePath": null,
+ "SourcePath": "D:\\GodotProject\\DungeonShooting\\DungeonShooting_Godot\\resource\\tileSprite\\map2\\Dungeon Tileset.png",
+ "Terrain": {
+ "_f": [
+ 0,
+ 64
+ ],
+ "_vl": [
+ 16,
+ 48
+ ],
+ "_vc": null,
+ "_vr": null,
+ "_vs": null,
+ "_000_010_010": [
+ 0,
+ 0
+ ],
+ "_010_010_010": null,
+ "_010_010_000": null,
+ "_000_010_000": null,
+ "_000_011_010": null,
+ "_010_011_010": null,
+ "_010_011_000": null,
+ "_000_011_000": null,
+ "_000_111_010": null,
+ "_010_111_010": null,
+ "_010_111_000": null,
+ "_000_111_000": null,
+ "_000_110_010": null,
+ "_010_110_010": null,
+ "_010_110_000": null,
+ "_000_110_000": null,
+ "_110_111_010": null,
+ "_010_011_011": null,
+ "_011_011_010": null,
+ "_010_111_110": null,
+ "_000_111_011": null,
+ "_011_111_111": null,
+ "_111_111_011": null,
+ "_011_111_000": null,
+ "_000_111_110": null,
+ "_110_111_111": null,
+ "_111_111_110": null,
+ "_110_111_000": null,
+ "_011_111_010": null,
+ "_010_110_110": null,
+ "_110_110_010": null,
+ "_010_111_011": null,
+ "_000_011_011": null,
+ "_011_011_011": null,
+ "_011_111_011": null,
+ "_011_011_000": null,
+ "_010_111_111": null,
+ "_110_111_011": null,
+ "_111_111_111": null,
+ "_111_111_000": null,
+ "_000_111_111": null,
+ "_011_111_110": null,
+ "_111_111_010": null,
+ "_000_110_110": null,
+ "_110_111_110": null,
+ "_110_110_110": null,
+ "_110_110_000": [
+ 176,
+ 48
+ ]
+ },
+ "Combination": [
+ {
+ "Id": "638401423614996953",
+ "Name": "\u7EC4\u5408",
+ "Cells": [
+ {
+ "X": 0,
+ "Y": 48
+ },
+ {
+ "X": 16,
+ "Y": 48
+ },
+ {
+ "X": 32,
+ "Y": 48
+ },
+ {
+ "X": 48,
+ "Y": 48
+ },
+ {
+ "X": 0,
+ "Y": 48
+ },
+ {
+ "X": 16,
+ "Y": 48
+ },
+ {
+ "X": 32,
+ "Y": 48
+ },
+ {
+ "X": 48,
+ "Y": 48
+ },
+ {
+ "X": 0,
+ "Y": 48
+ },
+ {
+ "X": 16,
+ "Y": 48
+ },
+ {
+ "X": 32,
+ "Y": 48
+ },
+ {
+ "X": 48,
+ "Y": 48
+ }
+ ],
+ "Positions": [
+ {
+ "X": 0,
+ "Y": 0
+ },
+ {
+ "X": 16,
+ "Y": 0
+ },
+ {
+ "X": 32,
+ "Y": 0
+ },
+ {
+ "X": 48,
+ "Y": 0
+ },
+ {
+ "X": 0,
+ "Y": 32
+ },
+ {
+ "X": 16,
+ "Y": 32
+ },
+ {
+ "X": 32,
+ "Y": 32
+ },
+ {
+ "X": 48,
+ "Y": 32
+ },
+ {
+ "X": 32,
+ "Y": 16
+ },
+ {
+ "X": 48,
+ "Y": 16
+ },
+ {
+ "X": 64,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 16
+ }
+ ]
+ },
+ {
+ "Id": "638401423666689215",
+ "Name": "\u7EC4\u5408",
+ "Cells": [
+ {
+ "X": 80,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 96,
+ "Y": 32
+ },
+ {
+ "X": 96,
+ "Y": 32
+ },
+ {
+ "X": 96,
+ "Y": 32
+ },
+ {
+ "X": 96,
+ "Y": 16
+ },
+ {
+ "X": 96,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 96,
+ "Y": 16
+ },
+ {
+ "X": 96,
+ "Y": 16
+ },
+ {
+ "X": 96,
+ "Y": 32
+ },
+ {
+ "X": 96,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 16
+ },
+ {
+ "X": 80,
+ "Y": 32
+ }
+ ],
+ "Positions": [
+ {
+ "X": 0,
+ "Y": 48
+ },
+ {
+ "X": 0,
+ "Y": 64
+ },
+ {
+ "X": 16,
+ "Y": 64
+ },
+ {
+ "X": 16,
+ "Y": 48
+ },
+ {
+ "X": 32,
+ "Y": 64
+ },
+ {
+ "X": 32,
+ "Y": 48
+ },
+ {
+ "X": 48,
+ "Y": 64
+ },
+ {
+ "X": 48,
+ "Y": 48
+ },
+ {
+ "X": 64,
+ "Y": 64
+ },
+ {
+ "X": 64,
+ "Y": 48
+ },
+ {
+ "X": 80,
+ "Y": 64
+ },
+ {
+ "X": 80,
+ "Y": 48
+ },
+ {
+ "X": 64,
+ "Y": 32
+ },
+ {
+ "X": 80,
+ "Y": 32
+ },
+ {
+ "X": 48,
+ "Y": 16
+ },
+ {
+ "X": 48,
+ "Y": 32
+ },
+ {
+ "X": 64,
+ "Y": 16
+ },
+ {
+ "X": 32,
+ "Y": 0
+ },
+ {
+ "X": 32,
+ "Y": 16
+ },
+ {
+ "X": 48,
+ "Y": 0
+ },
+ {
+ "X": 16,
+ "Y": 0
+ },
+ {
+ "X": 16,
+ "Y": 16
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "Name": "Test2",
+ "SourcePath": "D:\\GodotProject\\DungeonShooting\\DungeonShooting_Godot\\resource\\tileSprite\\map2\\Dungeon Tileset \u002B Spikes.png",
"Terrain": {
"_f": null,
"_vl": null,
@@ -58,72 +418,7 @@
"_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
- }
- ]
- }
- ]
+ "Combination": []
}
]
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileCombinationInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileCombinationInfo.cs
index ae1f83e..5f3e619 100644
--- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileCombinationInfo.cs
+++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileCombinationInfo.cs
@@ -4,7 +4,7 @@
///
/// 组合图块数据
///
-public class TileCombinationInfo
+public class TileCombinationInfo : IClone
{
///
/// 组合唯一Id
@@ -26,4 +26,29 @@
///
[JsonInclude]
public SerializeVector2[] Positions;
+
+ public TileCombinationInfo Clone()
+ {
+ var combinationInfo = new TileCombinationInfo();
+ combinationInfo.Id = Id;
+ combinationInfo.Name = Name;
+ if (Cells != null)
+ {
+ combinationInfo.Cells = new SerializeVector2[Cells.Length];
+ for (int i = 0; i < Cells.Length; i++)
+ {
+ combinationInfo.Cells[i] = Cells[i].Clone();
+ }
+ }
+
+ if (Positions != null)
+ {
+ combinationInfo.Positions = new SerializeVector2[Positions.Length];
+ for (int i = 0; i < Positions.Length; i++)
+ {
+ combinationInfo.Positions[i] = Positions[i].Clone();
+ }
+ }
+ return combinationInfo;
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetInfo.cs
index 8719a5f..7c6c9ea 100644
--- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetInfo.cs
+++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetInfo.cs
@@ -41,4 +41,17 @@
}
return tileSetInfo;
}
+
+ public void Dispose()
+ {
+ if (Sources != null)
+ {
+ foreach (var tileSetSourceInfo in Sources)
+ {
+ tileSetSourceInfo.Dispose();
+ }
+
+ Sources = null;
+ }
+ }
}
\ 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 8670ead..66cd5c3 100644
--- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs
+++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetSourceInfo.cs
@@ -72,6 +72,10 @@
public void SetSourceImage(Image image)
{
_overWriteImage = true;
+ if (_sourceImage != null)
+ {
+ _sourceImage.Dispose();
+ }
_sourceImage = image;
}
@@ -79,10 +83,26 @@
{
var tileSetSourceInfo = new TileSetSourceInfo();
tileSetSourceInfo.Name = Name;
- tileSetSourceInfo.Terrain = Terrain;
- tileSetSourceInfo.Combination = Combination;
+ tileSetSourceInfo.Terrain = Terrain.Clone();
+ tileSetSourceInfo.Combination = new List();
+ foreach (var combination in Combination)
+ {
+ tileSetSourceInfo.Combination.Add(combination.Clone());
+ }
tileSetSourceInfo.SourcePath = SourcePath;
tileSetSourceInfo._sourceImage = _sourceImage;
return tileSetSourceInfo;
}
+
+ public void Dispose()
+ {
+ if (_sourceImage != null)
+ {
+ _sourceImage.Dispose();
+ _sourceImage = null;
+ }
+
+ Terrain = null;
+ Combination = null;
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs
index 4c7f541..53a6cb6 100644
--- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs
+++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs
@@ -5,7 +5,7 @@
///
/// 地形配置数据, 数据都为 int 数组, 下标0和1分别代表x和y, 单位: 像素
///
-public class TileSetTerrainInfo
+public class TileSetTerrainInfo : IClone
{
//---------------------- 地板 ----------------------
@@ -106,4 +106,93 @@
{
return new Vector2I(ints[0], ints[1]);
}
+
+ public TileSetTerrainInfo Clone()
+ {
+ var terrainInfo = new TileSetTerrainInfo();
+ if (_f != null) terrainInfo._f = new[] { _f[0], _f[1] };
+
+ // 地板
+ terrainInfo._f = (_f != null) ? new[] { _f[0], _f[1] } : null;
+
+ // 侧方墙壁
+ terrainInfo._vl = (_vl != null) ? new[] { _vl[0], _vl[1] } : null;
+ terrainInfo._vc = (_vc != null) ? new[] { _vc[0], _vc[1] } : null;
+ terrainInfo._vr = (_vr != null) ? new[] { _vr[0], _vr[1] } : null;
+ terrainInfo._vs = (_vs != null) ? new[] { _vs[0], _vs[1] } : null;
+
+ // 顶部墙壁47格
+ // 第一列
+ terrainInfo._000_010_010 = (_000_010_010 != null) ? new[] { _000_010_010[0], _000_010_010[1] } : null;
+ terrainInfo._010_010_010 = (_010_010_010 != null) ? new[] { _010_010_010[0], _010_010_010[1] } : null;
+ terrainInfo._010_010_000 = (_010_010_000 != null) ? new[] { _010_010_000[0], _010_010_000[1] } : null;
+ terrainInfo._000_010_000 = (_000_010_000 != null) ? new[] { _000_010_000[0], _000_010_000[1] } : null;
+
+ // 第二列
+ terrainInfo._000_011_010 = (_000_011_010 != null) ? new[] { _000_011_010[0], _000_011_010[1] } : null;
+ terrainInfo._010_011_010 = (_010_011_010 != null) ? new[] { _010_011_010[0], _010_011_010[1] } : null;
+ terrainInfo._010_011_000 = (_010_011_000 != null) ? new[] { _010_011_000[0], _010_011_000[1] } : null;
+ terrainInfo._000_011_000 = (_000_011_000 != null) ? new[] { _000_011_000[0], _000_011_000[1] } : null;
+
+ // 第三列
+ terrainInfo._000_111_010 = (_000_111_010 != null) ? new[] { _000_111_010[0], _000_111_010[1] } : null;
+ terrainInfo._010_111_010 = (_010_111_010 != null) ? new[] { _010_111_010[0], _010_111_010[1] } : null;
+ terrainInfo._010_111_000 = (_010_111_000 != null) ? new[] { _010_111_000[0], _010_111_000[1] } : null;
+ terrainInfo._000_111_000 = (_000_111_000 != null) ? new[] { _000_111_000[0], _000_111_000[1] } : null;
+
+ // 第四列
+ terrainInfo._000_110_010 = (_000_110_010 != null) ? new[] { _000_110_010[0], _000_110_010[1] } : null;
+ terrainInfo._010_110_010 = (_010_110_010 != null) ? new[] { _010_110_010[0], _010_110_010[1] } : null;
+ terrainInfo._010_110_000 = (_010_110_000 != null) ? new[] { _010_110_000[0], _010_110_000[1] } : null;
+ terrainInfo._000_110_000 = (_000_110_000 != null) ? new[] { _000_110_000[0], _000_110_000[1] } : null;
+
+ // 第五列
+ terrainInfo._110_111_010 = (_110_111_010 != null) ? new[] { _110_111_010[0], _110_111_010[1] } : null;
+ terrainInfo._010_011_011 = (_010_011_011 != null) ? new[] { _010_011_011[0], _010_011_011[1] } : null;
+ terrainInfo._011_011_010 = (_011_011_010 != null) ? new[] { _011_011_010[0], _011_011_010[1] } : null;
+ terrainInfo._010_111_110 = (_010_111_110 != null) ? new[] { _010_111_110[0], _010_111_110[1] } : null;
+
+ // 第六列
+ terrainInfo._000_111_011 = (_000_111_011 != null) ? new[] { _000_111_011[0], _000_111_011[1] } : null;
+ terrainInfo._011_111_111 = (_011_111_111 != null) ? new[] { _011_111_111[0], _011_111_111[1] } : null;
+ terrainInfo._111_111_011 = (_111_111_011 != null) ? new[] { _111_111_011[0], _111_111_011[1] } : null;
+ terrainInfo._011_111_000 = (_011_111_000 != null) ? new[] { _011_111_000[0], _011_111_000[1] } : null;
+
+ // 第七列
+ terrainInfo._000_111_110 = (_000_111_110 != null) ? new[] { _000_111_110[0], _000_111_110[1] } : null;
+ terrainInfo._110_111_111 = (_110_111_111 != null) ? new[] { _110_111_111[0], _110_111_111[1] } : null;
+ terrainInfo._111_111_110 = (_111_111_110 != null) ? new[] { _111_111_110[0], _111_111_110[1] } : null;
+ terrainInfo._110_111_000 = (_110_111_000 != null) ? new[] { _110_111_000[0], _110_111_000[1] } : null;
+
+ // 第八列
+ terrainInfo._011_111_010 = (_011_111_010 != null) ? new[] { _011_111_010[0], _011_111_010[1] } : null;
+ terrainInfo._010_110_110 = (_010_110_110 != null) ? new[] { _010_110_110[0], _010_110_110[1] } : null;
+ terrainInfo._110_110_010 = (_110_110_010 != null) ? new[] { _110_110_010[0], _110_110_010[1] } : null;
+ terrainInfo._010_111_011 = (_010_111_011 != null) ? new[] { _010_111_011[0], _010_111_011[1] } : null;
+
+ // 第九列
+ terrainInfo._000_011_011 = (_000_011_011 != null) ? new[] { _000_011_011[0], _000_011_011[1] } : null;
+ terrainInfo._011_011_011 = (_011_011_011 != null) ? new[] { _011_011_011[0], _011_011_011[1] } : null;
+ terrainInfo._011_111_011 = (_011_111_011 != null) ? new[] { _011_111_011[0], _011_111_011[1] } : null;
+ terrainInfo._011_011_000 = (_011_011_000 != null) ? new[] { _011_011_000[0], _011_011_000[1] } : null;
+
+ // 第十列
+ terrainInfo._010_111_111 = (_010_111_111 != null) ? new[] { _010_111_111[0], _010_111_111[1] } : null;
+ terrainInfo._110_111_011 = (_110_111_011 != null) ? new[] { _110_111_011[0], _110_111_011[1] } : null;
+ terrainInfo._111_111_111 = (_111_111_111 != null) ? new[] { _111_111_111[0], _111_111_111[1] } : null;
+ terrainInfo._111_111_000 = (_111_111_000 != null) ? new[] { _111_111_000[0], _111_111_000[1] } : null;
+
+ // 第十一列
+ terrainInfo._000_111_111 = (_000_111_111 != null) ? new[] { _000_111_111[0], _000_111_111[1] } : null;
+ terrainInfo._011_111_110 = (_011_111_110 != null) ? new[] { _011_111_110[0], _011_111_110[1] } : null;
+ terrainInfo._111_111_010 = (_111_111_010 != null) ? new[] { _111_111_010[0], _111_111_010[1] } : null;
+
+ // 第十二列
+ terrainInfo._000_110_110 = (_000_110_110 != null) ? new[] { _000_110_110[0], _000_110_110[1] } : null;
+ terrainInfo._110_111_110 = (_110_111_110 != null) ? new[] { _110_111_110[0], _110_111_110[1] } : null;
+ terrainInfo._110_110_110 = (_110_110_110 != null) ? new[] { _110_110_110[0], _110_110_110[1] } : null;
+ terrainInfo._110_110_000 = (_110_110_000 != null) ? new[] { _110_110_000[0], _110_110_000[1] } : null;
+
+ return terrainInfo;
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/serialize/SerializeVector2.cs b/DungeonShooting_Godot/src/framework/serialize/SerializeVector2.cs
index 4e0a888..df09b4c 100644
--- a/DungeonShooting_Godot/src/framework/serialize/SerializeVector2.cs
+++ b/DungeonShooting_Godot/src/framework/serialize/SerializeVector2.cs
@@ -5,7 +5,7 @@
///
/// 可序列化的 Vector2 对象
///
-public class SerializeVector2
+public class SerializeVector2 : IClone
{
public SerializeVector2(float x, float y)
{
@@ -56,4 +56,10 @@
{
return new Vector2I((int)X, (int)Y);
}
+
+
+ public SerializeVector2 Clone()
+ {
+ return new SerializeVector2(this);
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/event/EventEnum.cs b/DungeonShooting_Godot/src/game/event/EventEnum.cs
index 30ca385..65e4a6a 100644
--- a/DungeonShooting_Godot/src/game/event/EventEnum.cs
+++ b/DungeonShooting_Godot/src/game/event/EventEnum.cs
@@ -169,7 +169,7 @@
///
OnDeleteTileSetSource,
///
- /// 设置TileSet纹理, 参数
+ /// 设置TileSet纹理, 参数, 可能为 null
///
OnSetTileTexture,
///
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
index a87628a..fe2f6f2 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditor/TileSetEditorPanel.cs
@@ -94,9 +94,11 @@
Texture.Dispose();
}
- if (TextureImage != null)
+ TextureImage = null;
+
+ if (TileSetInfo != null)
{
- TextureImage.Dispose();
+ TileSetInfo.Dispose();
}
}
@@ -108,6 +110,19 @@
OriginTileSetInfo = tileSetInfo;
TileSetInfo = tileSetInfo.Clone();
S_Title.Instance.Text = "正在编辑:" + TileSetInfo.Name;
+
+ //初始化下拉框
+ if (TileSetInfo.Sources.Count > 0)
+ {
+ var optionButton = S_OptionButton.Instance;
+ foreach (var tileSetSourceInfo in TileSetInfo.Sources)
+ {
+ optionButton.AddItem(tileSetSourceInfo.Name);
+ }
+
+ optionButton.Selected = 0;
+ OnOptionChange(0);
+ }
}
///
@@ -115,21 +130,24 @@
///
public void SetTextureData(Image image)
{
- if (TileSetSourceInfo == null)
+ if (image == null)
{
- return;
+ InitTexture = false;
+ TextureImage = null;
}
-
- InitTexture = true;
- Texture.SetImage(image);
- if (TextureImage != null)
+ else
{
- TextureImage.Dispose();
- }
- TextureImage = image;
- CellHorizontal = image.GetWidth() / GameConfig.TileCellSize;
- CellVertical = image.GetHeight() / GameConfig.TileCellSize;
+ if (TileSetSourceInfo == null)
+ {
+ return;
+ }
+ InitTexture = true;
+ Texture.SetImage(image);
+ TextureImage = image;
+ CellHorizontal = image.GetWidth() / GameConfig.TileCellSize;
+ CellVertical = image.GetHeight() / GameConfig.TileCellSize;
+ }
//派发事件
EventManager.EmitEvent(EventEnum.OnSetTileTexture, Texture);
}
@@ -236,14 +254,17 @@
TabGrid.Visible = true;
TabGrid.SelectIndex = 0;
TileSetSourceInfo = TileSetInfo.Sources[(int)index];
+ SetTextureData(TileSetSourceInfo.GetSourceImage());
}
else
{
TabGrid.Visible = false;
TabGrid.SelectIndex = -1;
TileSetSourceInfo = null;
+ SetTextureData(null);
}
- EventManager.EmitEvent(EventEnum.OnSelectTileSetSource);
+
+ EventManager.EmitEvent(EventEnum.OnSelectTileSetSource, TileSetSourceInfo);
}
//保存
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
index 5c9163c..c2e3fe4 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorImport/TileSetEditorImportPanel.cs
@@ -182,6 +182,7 @@
Debug.Log("导入文件: " + file);
var image = Image.LoadFromFile(file);
+ _tileSetEditor.TileSetSourceInfo.SourcePath = file;
_tileSetEditor.TileSetSourceInfo.SetSourceImage(image);
_tileSetEditor.SetTextureData(image);
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs
index beca290..07ae992 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorProject/TileSetEditorProjectPanel.cs
@@ -1,3 +1,5 @@
+using System.IO;
+using System.Text.Json;
using Godot;
namespace UI.TileSetEditorProject;
@@ -19,10 +21,9 @@
_grid.SetAutoColumns(true);
_grid.SetCellOffset(new Vector2I(10, 10));
_grid.SetHorizontalExpand(true);
-
- var tileSetInfo = new TileSetInfo();
- tileSetInfo.InitData();
- tileSetInfo.Name = "测试数据";
+
+ var jsonData = File.ReadAllText("resource/map/tileSet/测试数据/TileSet.json");
+ var tileSetInfo = JsonSerializer.Deserialize(jsonData);
_grid.Add(tileSetInfo);
}