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 7ebecf0..14b140b 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"
@@ -5,15 +5,29 @@
"Name": "Test",
"SourcePath": null,
"Terrain": {
- "_000_010_010": null,
+ "_f": null,
+ "_vl": null,
+ "_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,
+ "_000_011_010": [
+ 16,
+ 0
+ ],
"_010_011_010": null,
"_010_011_000": null,
"_000_011_000": null,
- "_000_111_010": null,
+ "_000_111_010": [
+ 32,
+ 0
+ ],
"_010_111_010": null,
"_010_111_000": null,
"_000_111_000": null,
@@ -48,7 +62,10 @@
"_000_111_111": null,
"_011_111_110": null,
"_111_111_010": null,
- "_000_110_110": null,
+ "_000_110_110": [
+ 176,
+ 0
+ ],
"_110_111_110": null,
"_110_110_110": null,
"_110_110_000": null
diff --git a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs
index 8c4b704..053521c 100644
--- a/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs
+++ b/DungeonShooting_Godot/src/framework/map/serialize/tileSet/TileSetTerrainInfo.cs
@@ -7,6 +7,19 @@
///
public class TileSetTerrainInfo
{
+ //---------------------- 地板 ----------------------
+
+ [JsonInclude] public int[] _f;
+
+ //---------------------- 侧方墙壁 --------------------------
+
+ [JsonInclude] public int[] _vl;
+ [JsonInclude] public int[] _vc;
+ [JsonInclude] public int[] _vr;
+ [JsonInclude] public int[] _vs;
+
+ //---------------------- 顶部墙壁47格 ----------------------
+
//第一列
[JsonInclude] public int[] _000_010_010;
[JsonInclude] public int[] _010_010_010;
diff --git a/DungeonShooting_Godot/src/game/GameConfig.cs b/DungeonShooting_Godot/src/game/GameConfig.cs
index 990b710..552a45d 100644
--- a/DungeonShooting_Godot/src/game/GameConfig.cs
+++ b/DungeonShooting_Godot/src/game/GameConfig.cs
@@ -101,4 +101,17 @@
/// 寻路导航单格步长
///
public const float NavigationCellSize = 4;
+
+ ///
+ /// 地形掩码纹理大小, 顶部墙壁
+ ///
+ public static readonly Vector2I TerrainBitSize1 = new Vector2I(12, 4);
+ ///
+ /// 地形掩码纹理大小, 侧方墙壁
+ ///
+ public static readonly Vector2I TerrainBitSize2 = new Vector2I(4, 1);
+ ///
+ /// 地形掩码纹理大小, 地板
+ ///
+ public static readonly Vector2I TerrainBitSize3 = new Vector2I(1, 1);
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs b/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs
index 7376fdc..a83b131 100644
--- a/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs
+++ b/DungeonShooting_Godot/src/game/manager/EditorTileSetManager.cs
@@ -28,7 +28,49 @@
#endif
EventManager.AddEventListener(EventEnum.OnTileSetSave, OnTileSetSave);
}
-
+
+ public static void SetTileSetTerrainBit(TileSetTerrainInfo terrain, int index, byte type, int[] cellData)
+ {
+ if (type == 1) //顶部墙壁
+ {
+ switch (index)
+ {
+ //第一排
+ case 0: terrain._000_010_010 = cellData; break;
+ case 1: terrain._000_011_010 = cellData; break;
+ case 2: terrain._000_111_010 = cellData; break;
+ case 3: terrain._000_110_010 = cellData; break;
+
+ case 4: terrain._110_111_010 = cellData; break;
+ case 5: terrain._000_111_011 = cellData; break;
+ case 6: terrain._000_111_110 = cellData; break;
+ case 7: terrain._011_111_010 = cellData; break;
+
+ case 8: terrain._000_011_011 = cellData; break;
+ case 9: terrain._010_111_111 = cellData; break;
+ case 10: terrain._000_111_111 = cellData; break;
+ case 11: terrain._000_110_110 = cellData; break;
+
+ //第二排
+
+ }
+ }
+ else if (type == 2) //侧方墙壁
+ {
+ switch (index)
+ {
+ case 0: terrain._vs = cellData; break;
+ case 1: terrain._vl = cellData; break;
+ case 2: terrain._vc = cellData; break;
+ case 3: terrain._vr = cellData; break;
+ }
+ }
+ else if (type == 3) //地板
+ {
+ terrain._f = cellData;
+ }
+ }
+
//保存图块集
private static void OnTileSetSave(object o)
{
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs
index e291342..e06d614 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/TileSetEditorTerrainPanel.cs
@@ -15,9 +15,9 @@
///
public bool IsDraggingCell { get; set; }
- private UiGrid _topGrid1;
- private UiGrid _topGrid2;
- private UiGrid _topGrid3;
+ private UiGrid _topGrid1;
+ private UiGrid _topGrid2;
+ private UiGrid _topGrid3;
private UiGrid _bottomGrid;
public override void OnCreateUi()
@@ -32,9 +32,9 @@
_bottomGrid = CreateUiGrid(S_BottomCell);
_bottomGrid.SetCellOffset(Vector2I.Zero);
- _topGrid1 = InitTopGrid(S_TerrainRoot.L_TerrainTexture1.Instance);
- _topGrid2 = InitTopGrid(S_TerrainRoot.L_TerrainTexture2.Instance);
- _topGrid3 = InitTopGrid(S_TerrainRoot.L_TerrainTexture3.Instance);
+ _topGrid1 = InitTopGrid(S_TerrainRoot.L_TerrainTexture1.Instance, GameConfig.TerrainBitSize1, 1);
+ _topGrid2 = InitTopGrid(S_TerrainRoot.L_TerrainTexture2.Instance, GameConfig.TerrainBitSize2, 2);
+ _topGrid3 = InitTopGrid(S_TerrainRoot.L_TerrainTexture3.Instance, GameConfig.TerrainBitSize3, 3);
OnSetTileTexture(EditorPanel.Texture);
OnChangeTileSetBgColor(EditorPanel.BgColor);
@@ -50,21 +50,19 @@
S_MaskBrush.Instance.Visible = !IsDraggingCell;
}
- private UiGrid InitTopGrid(Control texture)
+ private UiGrid InitTopGrid(Control texture, Vector2I size, byte type)
{
var cellRoot = S_TopBg.L_TerrainRoot.L_CellRoot;
var sRightCell = cellRoot.L_RightCell;
- var terrainSize = texture.Size.AsVector2I();
- terrainSize = terrainSize / GameConfig.TileCellSize;
sRightCell.Instance.Position = texture.Position;
- var grid = CreateUiGrid(sRightCell, cellRoot.Instance);
+ var grid = CreateUiGrid(sRightCell, cellRoot.Instance);
grid.SetCellOffset(Vector2I.Zero);
- grid.SetColumns(terrainSize.X);
- for (var y = 0; y < terrainSize.Y; y++)
+ grid.SetColumns(size.X);
+ for (var y = 0; y < size.Y; y++)
{
- for (var x = 0; x < terrainSize.X; x++)
+ for (var x = 0; x < size.X; x++)
{
- grid.Add(false);
+ grid.Add(type);
}
}
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs
index a63671f..f73831e 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCell.cs
@@ -2,7 +2,7 @@
namespace UI.TileSetEditorTerrain;
-public class TerrainCell : UiCell
+public class TerrainCell : UiCell
{
public override void OnInit()
{
diff --git a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs
index e3387d9..b6d18f5 100644
--- a/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs
+++ b/DungeonShooting_Godot/src/game/ui/tileSetEditorTerrain/up/TerrainCellDropHandler.cs
@@ -7,7 +7,12 @@
///
/// 是否放置了图块
///
- public bool IsPutDownTexture { get; set; }
+ public bool IsPutDownTexture { get; private set; }
+
+ ///
+ /// 图块在 Source 中的位置, 单位: 像素
+ ///
+ public Vector2I TextureCell { get; private set; }
private TerrainCell _cell;
private TileSetEditorTerrainPanel _panel;
@@ -26,11 +31,13 @@
public override void _DropData(Vector2 atPosition, Variant data)
{
var rect = data.AsRect2I();
+ TextureCell = rect.Position;
var sprite2D = _cell.CellNode.L_CellTexture.Instance;
sprite2D.Texture = _panel.EditorPanel.Texture;
sprite2D.RegionEnabled = true;
sprite2D.RegionRect = rect;
IsPutDownTexture = true;
+ SetTerrainBitData(new []{ TextureCell.X, TextureCell.Y });
}
public override void _GuiInput(InputEvent @event)
@@ -41,6 +48,12 @@
AcceptEvent();
_cell.CellNode.L_CellTexture.Instance.Texture = null;
IsPutDownTexture = false;
+ SetTerrainBitData(null);
}
}
+
+ private void SetTerrainBitData(int[] cellData)
+ {
+ EditorTileSetManager.SetTileSetTerrainBit(_panel.EditorPanel.TileSetSourceInfo.Terrain, _cell.Index, _cell.Data, cellData);
+ }
}
\ No newline at end of file