This commit is contained in:
2025-06-16 23:59:28 +08:00
parent 60fe962606
commit 1a5115c678
10 changed files with 260 additions and 156 deletions

View File

@@ -0,0 +1,160 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<config>
<Settings mapID="1000" regionRowNum="11" regionColNum="14" regionWidth="512" regionHeight="512" cellWidthPixel="48" cellHeightPixel="32" />
<Regions>
<Region IndexX="0" IndexY="0" regionName="v1000_r11_c1" />
<Region IndexX="0" IndexY="1" regionName="v1000_r11_c2" />
<Region IndexX="0" IndexY="2" regionName="v1000_r11_c3" />
<Region IndexX="0" IndexY="3" regionName="v1000_r11_c4" />
<Region IndexX="0" IndexY="4" regionName="v1000_r11_c5" />
<Region IndexX="0" IndexY="5" regionName="v1000_r11_c6" />
<Region IndexX="0" IndexY="6" regionName="v1000_r11_c7" />
<Region IndexX="0" IndexY="7" regionName="v1000_r11_c8" />
<Region IndexX="0" IndexY="8" regionName="v1000_r11_c9" />
<Region IndexX="0" IndexY="9" regionName="v1000_r11_c10" />
<Region IndexX="0" IndexY="10" regionName="v1000_r11_c11" />
<Region IndexX="0" IndexY="11" regionName="v1000_r11_c12" />
<Region IndexX="0" IndexY="12" regionName="v1000_r11_c13" />
<Region IndexX="0" IndexY="13" regionName="v1000_r11_c14" />
<Region IndexX="1" IndexY="0" regionName="v1000_r10_c1" />
<Region IndexX="1" IndexY="1" regionName="v1000_r10_c2" />
<Region IndexX="1" IndexY="2" regionName="v1000_r10_c3" />
<Region IndexX="1" IndexY="3" regionName="v1000_r10_c4" />
<Region IndexX="1" IndexY="4" regionName="v1000_r10_c5" />
<Region IndexX="1" IndexY="5" regionName="v1000_r10_c6" />
<Region IndexX="1" IndexY="6" regionName="v1000_r10_c7" />
<Region IndexX="1" IndexY="7" regionName="v1000_r10_c8" />
<Region IndexX="1" IndexY="8" regionName="v1000_r10_c9" />
<Region IndexX="1" IndexY="9" regionName="v1000_r10_c10" />
<Region IndexX="1" IndexY="10" regionName="v1000_r10_c11" />
<Region IndexX="1" IndexY="11" regionName="v1000_r10_c12" />
<Region IndexX="1" IndexY="12" regionName="v1000_r10_c13" />
<Region IndexX="1" IndexY="13" regionName="v1000_r10_c14" />
<Region IndexX="2" IndexY="0" regionName="v1000_r9_c1" />
<Region IndexX="2" IndexY="1" regionName="v1000_r9_c2" />
<Region IndexX="2" IndexY="2" regionName="v1000_r9_c3" />
<Region IndexX="2" IndexY="3" regionName="v1000_r9_c4" />
<Region IndexX="2" IndexY="4" regionName="v1000_r9_c5" />
<Region IndexX="2" IndexY="5" regionName="v1000_r9_c6" />
<Region IndexX="2" IndexY="6" regionName="v1000_r9_c7" />
<Region IndexX="2" IndexY="7" regionName="v1000_r9_c8" />
<Region IndexX="2" IndexY="8" regionName="v1000_r9_c9" />
<Region IndexX="2" IndexY="9" regionName="v1000_r9_c10" />
<Region IndexX="2" IndexY="10" regionName="v1000_r9_c11" />
<Region IndexX="2" IndexY="11" regionName="v1000_r9_c12" />
<Region IndexX="2" IndexY="12" regionName="v1000_r9_c13" />
<Region IndexX="2" IndexY="13" regionName="v1000_r9_c14" />
<Region IndexX="3" IndexY="0" regionName="v1000_r8_c1" />
<Region IndexX="3" IndexY="1" regionName="v1000_r8_c2" />
<Region IndexX="3" IndexY="2" regionName="v1000_r8_c3" />
<Region IndexX="3" IndexY="3" regionName="v1000_r8_c4" />
<Region IndexX="3" IndexY="4" regionName="v1000_r8_c5" />
<Region IndexX="3" IndexY="5" regionName="v1000_r8_c6" />
<Region IndexX="3" IndexY="6" regionName="v1000_r8_c7" />
<Region IndexX="3" IndexY="7" regionName="v1000_r8_c8" />
<Region IndexX="3" IndexY="8" regionName="v1000_r8_c9" />
<Region IndexX="3" IndexY="9" regionName="v1000_r8_c10" />
<Region IndexX="3" IndexY="10" regionName="v1000_r8_c11" />
<Region IndexX="3" IndexY="11" regionName="v1000_r8_c12" />
<Region IndexX="3" IndexY="12" regionName="v1000_r8_c13" />
<Region IndexX="3" IndexY="13" regionName="v1000_r8_c14" />
<Region IndexX="4" IndexY="0" regionName="v1000_r7_c1" />
<Region IndexX="4" IndexY="1" regionName="v1000_r7_c2" />
<Region IndexX="4" IndexY="2" regionName="v1000_r7_c3" />
<Region IndexX="4" IndexY="3" regionName="v1000_r7_c4" />
<Region IndexX="4" IndexY="4" regionName="v1000_r7_c5" />
<Region IndexX="4" IndexY="5" regionName="v1000_r7_c6" />
<Region IndexX="4" IndexY="6" regionName="v1000_r7_c7" />
<Region IndexX="4" IndexY="7" regionName="v1000_r7_c8" />
<Region IndexX="4" IndexY="8" regionName="v1000_r7_c9" />
<Region IndexX="4" IndexY="9" regionName="v1000_r7_c10" />
<Region IndexX="4" IndexY="10" regionName="v1000_r7_c11" />
<Region IndexX="4" IndexY="11" regionName="v1000_r7_c12" />
<Region IndexX="4" IndexY="12" regionName="v1000_r7_c13" />
<Region IndexX="4" IndexY="13" regionName="v1000_r7_c14" />
<Region IndexX="5" IndexY="0" regionName="v1000_r6_c1" />
<Region IndexX="5" IndexY="1" regionName="v1000_r6_c2" />
<Region IndexX="5" IndexY="2" regionName="v1000_r6_c3" />
<Region IndexX="5" IndexY="3" regionName="v1000_r6_c4" />
<Region IndexX="5" IndexY="4" regionName="v1000_r6_c5" />
<Region IndexX="5" IndexY="5" regionName="v1000_r6_c6" />
<Region IndexX="5" IndexY="6" regionName="v1000_r6_c7" />
<Region IndexX="5" IndexY="7" regionName="v1000_r6_c8" />
<Region IndexX="5" IndexY="8" regionName="v1000_r6_c9" />
<Region IndexX="5" IndexY="9" regionName="v1000_r6_c10" />
<Region IndexX="5" IndexY="10" regionName="v1000_r6_c11" />
<Region IndexX="5" IndexY="11" regionName="v1000_r6_c12" />
<Region IndexX="5" IndexY="12" regionName="v1000_r6_c13" />
<Region IndexX="5" IndexY="13" regionName="v1000_r6_c14" />
<Region IndexX="6" IndexY="0" regionName="v1000_r5_c1" />
<Region IndexX="6" IndexY="1" regionName="v1000_r5_c2" />
<Region IndexX="6" IndexY="2" regionName="v1000_r5_c3" />
<Region IndexX="6" IndexY="3" regionName="v1000_r5_c4" />
<Region IndexX="6" IndexY="4" regionName="v1000_r5_c5" />
<Region IndexX="6" IndexY="5" regionName="v1000_r5_c6" />
<Region IndexX="6" IndexY="6" regionName="v1000_r5_c7" />
<Region IndexX="6" IndexY="7" regionName="v1000_r5_c8" />
<Region IndexX="6" IndexY="8" regionName="v1000_r5_c9" />
<Region IndexX="6" IndexY="9" regionName="v1000_r5_c10" />
<Region IndexX="6" IndexY="10" regionName="v1000_r5_c11" />
<Region IndexX="6" IndexY="11" regionName="v1000_r5_c12" />
<Region IndexX="6" IndexY="12" regionName="v1000_r5_c13" />
<Region IndexX="6" IndexY="13" regionName="v1000_r5_c14" />
<Region IndexX="7" IndexY="0" regionName="v1000_r4_c1" />
<Region IndexX="7" IndexY="1" regionName="v1000_r4_c2" />
<Region IndexX="7" IndexY="2" regionName="v1000_r4_c3" />
<Region IndexX="7" IndexY="3" regionName="v1000_r4_c4" />
<Region IndexX="7" IndexY="4" regionName="v1000_r4_c5" />
<Region IndexX="7" IndexY="5" regionName="v1000_r4_c6" />
<Region IndexX="7" IndexY="6" regionName="v1000_r4_c7" />
<Region IndexX="7" IndexY="7" regionName="v1000_r4_c8" />
<Region IndexX="7" IndexY="8" regionName="v1000_r4_c9" />
<Region IndexX="7" IndexY="9" regionName="v1000_r4_c10" />
<Region IndexX="7" IndexY="10" regionName="v1000_r4_c11" />
<Region IndexX="7" IndexY="11" regionName="v1000_r4_c12" />
<Region IndexX="7" IndexY="12" regionName="v1000_r4_c13" />
<Region IndexX="7" IndexY="13" regionName="v1000_r4_c14" />
<Region IndexX="8" IndexY="0" regionName="v1000_r3_c1" />
<Region IndexX="8" IndexY="1" regionName="v1000_r3_c2" />
<Region IndexX="8" IndexY="2" regionName="v1000_r3_c3" />
<Region IndexX="8" IndexY="3" regionName="v1000_r3_c4" />
<Region IndexX="8" IndexY="4" regionName="v1000_r3_c5" />
<Region IndexX="8" IndexY="5" regionName="v1000_r3_c6" />
<Region IndexX="8" IndexY="6" regionName="v1000_r3_c7" />
<Region IndexX="8" IndexY="7" regionName="v1000_r3_c8" />
<Region IndexX="8" IndexY="8" regionName="v1000_r3_c9" />
<Region IndexX="8" IndexY="9" regionName="v1000_r3_c10" />
<Region IndexX="8" IndexY="10" regionName="v1000_r3_c11" />
<Region IndexX="8" IndexY="11" regionName="v1000_r3_c12" />
<Region IndexX="8" IndexY="12" regionName="v1000_r3_c13" />
<Region IndexX="8" IndexY="13" regionName="v1000_r3_c14" />
<Region IndexX="9" IndexY="0" regionName="v1000_r2_c1" />
<Region IndexX="9" IndexY="1" regionName="v1000_r2_c2" />
<Region IndexX="9" IndexY="2" regionName="v1000_r2_c3" />
<Region IndexX="9" IndexY="3" regionName="v1000_r2_c4" />
<Region IndexX="9" IndexY="4" regionName="v1000_r2_c5" />
<Region IndexX="9" IndexY="5" regionName="v1000_r2_c6" />
<Region IndexX="9" IndexY="6" regionName="v1000_r2_c7" />
<Region IndexX="9" IndexY="7" regionName="v1000_r2_c8" />
<Region IndexX="9" IndexY="8" regionName="v1000_r2_c9" />
<Region IndexX="9" IndexY="9" regionName="v1000_r2_c10" />
<Region IndexX="9" IndexY="10" regionName="v1000_r2_c11" />
<Region IndexX="9" IndexY="11" regionName="v1000_r2_c12" />
<Region IndexX="9" IndexY="12" regionName="v1000_r2_c13" />
<Region IndexX="9" IndexY="13" regionName="v1000_r2_c14" />
<Region IndexX="10" IndexY="0" regionName="v1000_r1_c1" />
<Region IndexX="10" IndexY="1" regionName="v1000_r1_c2" />
<Region IndexX="10" IndexY="2" regionName="v1000_r1_c3" />
<Region IndexX="10" IndexY="3" regionName="v1000_r1_c4" />
<Region IndexX="10" IndexY="4" regionName="v1000_r1_c5" />
<Region IndexX="10" IndexY="5" regionName="v1000_r1_c6" />
<Region IndexX="10" IndexY="6" regionName="v1000_r1_c7" />
<Region IndexX="10" IndexY="7" regionName="v1000_r1_c8" />
<Region IndexX="10" IndexY="8" regionName="v1000_r1_c9" />
<Region IndexX="10" IndexY="9" regionName="v1000_r1_c10" />
<Region IndexX="10" IndexY="10" regionName="v1000_r1_c11" />
<Region IndexX="10" IndexY="11" regionName="v1000_r1_c12" />
<Region IndexX="10" IndexY="12" regionName="v1000_r1_c13" />
<Region IndexX="10" IndexY="13" regionName="v1000_r1_c14" />
</Regions>
</config>

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: a3d8a7c7ffb73084299764bef946df80
TextScriptImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -17,12 +17,18 @@ using UnityEngine.Rendering;
using UnityEngine.UI;
using UnityEngine.UIElements;
using static MapManager;
using static UnityEngine.Rendering.DebugUI.Table;
public partial class MapManager : MonoBehaviour
{
[SerializeField]
private Transform mapRegion;
public Dictionary<string, (int maxRow, int maxCol)> allMaps = new Dictionary<string, (int maxRow, int maxCol)>();
public Dictionary<string, (int maxRow, int maxCol)> allMaps = new Dictionary<string, (int maxRow, int maxCol)>();
/// <summary>
/// 当前地图区域
/// </summary>
private MapRegions _curMapRegions;
public bool LoadObsXml()
{
if (_curOpenMapId < 0)
@@ -90,53 +96,44 @@ public partial class MapManager : MonoBehaviour
}
return true;
}
public void LoadRegionXML(int mapId)
/// <summary>
/// 保存地图配置
/// </summary>
/// <param name="mapId"></param>
public void SaveRegionXML()
{
Transform regionsTrans = UIWindow.Instance.mapTrans.Find("Regions");
if (regionsTrans == null)
int mapId = _curOpenMapId;
if (!allMaps.TryGetValue(_curOpenMapId.ToString(), out var curMap))
{
UIWindow.Instance.ShowMessage("没有找到Regions节点");
UIWindow.Instance.ShowMessage($"没有扫描到当前地图 [{_curOpenMapId}]");
return;
}
MapRegions mapRegions = new MapRegions();
mapRegions.mapWidth = Convert.ToInt32(txtMapWidth.text);
mapRegions.mapHeight = Convert.ToInt32(txtMapHeight.text);
mapRegions.regionWidth = Convert.ToInt32(txtRegionWidth.text);
mapRegions.regionHeight = Convert.ToInt32(txtRegionHeight.text);
int row = mapRegions.mapWidth / MapManager.CELLSCALE / mapRegions.regionWidth;
int col = mapRegions.mapHeight / MapManager.CELLSCALE / mapRegions.regionHeight;
Transform trans = null;
mapRegions.regions = new Region[row, col];
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
mapRegions.regions[i, j] = new Region();
mapRegions.regions[i, j].indexX = i;
mapRegions.regions[i, j].indexY = j;
string regionName = $"{i}_{j}";
trans = regionsTrans.Find(regionName);
if (trans == null)
{
UIWindow.Instance.ShowMessage($"没有找到region节点 name={regionName}");
return;
}
//mapRegions.regions[i, j].regionName = trans.GetComponent<Image>().sprite.name;
mapRegions.regions[i, j].regionName = trans.GetComponent<RawImage>().texture.name;
}
}
mapRegions.SaveXML(mapId);
_curMapRegions?.SaveXML(mapId);
//MapRegions mapRegions = new MapRegions();
//mapRegions.regionRowNum = curMap.maxRow;
//mapRegions.regionColNum = curMap.maxCol;
//mapRegions.regionWidth = PicMapPixel;
//mapRegions.regionHeight = PicMapPixel;
//mapRegions.cellWidthPixel = widthPixel;
//mapRegions.cellHeightPixel = heightPixel;
//mapRegions.regions = new Region[mapRegions.regionRowNum, mapRegions.regionColNum];
//for (int row = 0; row < mapRegions.regionRowNum; row++)
//{
// for (int col = 0; col < mapRegions.regionColNum; col++)
// {
// mapRegions.regions[row, col] = new Region();
// mapRegions.regions[row, col].indexX = row;
// mapRegions.regions[row, col].indexY = col;
// int ldx = mapRegions.regionRowNum - row;
// int ldy = col + 1;
// mapRegions.regions[row, col].regionName = $"v{mapId}_r{ldx}_c{ldy}"; // 构造文件名v1000_r1_c1.jpg
// }
//}
//mapRegions.SaveXML(mapId);
}
public void LoadMapRegions(int mapId)
public void LoadMapRegionSprites(int mapId)
{
_curOpenMapId = mapId;
if (!allMaps.TryGetValue(mapId.ToString(),out var mapInfo))
{
UIWindow.Instance.ShowMessage("µØÍ¼²»´æÔÚ¡£¡£¡£");
@@ -144,10 +141,16 @@ public partial class MapManager : MonoBehaviour
}
int mapRownum = mapInfo.maxRow;
int mapColumn = mapInfo.maxCol;
//平铺;
float jpgscenew = 512f / 100;
MapManager.Instance.ReseCamera(jpgscenew * mapColumn, jpgscenew * mapRownum);
MapManager.Instance.GenerateMap(jpgscenew * mapColumn, jpgscenew * mapRownum, 0.48f, 0.32f);
_curMapRegions = new MapRegions();
_curOpenMapId = mapId;
_curMapRegions.regionRowNum = mapRownum;
_curMapRegions.regionColNum = mapColumn;
_curMapRegions.regionWidth = PicMapPixel;
_curMapRegions.regionHeight = PicMapPixel;
_curMapRegions.cellWidthPixel = widthPixel;
_curMapRegions.cellHeightPixel = heightPixel;
_curMapRegions.regions = new Region[mapRownum, mapColumn];
float jpgscenew = PicMapPixel / 100;
for (int row = 0; row < mapRownum; row++)
{
for (int col = 0; col < mapColumn; col++)
@@ -160,9 +163,18 @@ public partial class MapManager : MonoBehaviour
float x = col * jpgscenew;
float y = (mapRownum - row - 1) * jpgscenew;
obj.transform.position = new Vector2(x, y);
multithreadLoadTextrue(spPath,sr);
}
_curMapRegions.regions[row, col] = new Region();
_curMapRegions.regions[row, col].indexX = row;
_curMapRegions.regions[row, col].indexY = col;
multithreadLoadTextrue(spPath, sr);
int ldx = mapRownum - row;
int ldy = col + 1;
_curMapRegions.regions[row, col].regionName = $"v{mapId}_r{ldx}_c{ldy}"; // 构造文件名v1000_r1_c1.jpg
}
}
MapManager.Instance.ReseCamera(jpgscenew * mapColumn, jpgscenew * mapRownum);
MapManager.Instance.GenerateMap(jpgscenew * mapColumn, jpgscenew * mapRownum, widthPixel / 100.0f, heightPixel / 100.0f);
}
public void ClearMapRegions()
{
@@ -244,8 +256,4 @@ public partial class MapManager : MonoBehaviour
//}
}
internal void SaveCellsXml()
{
throw new NotImplementedException();
}
}

View File

@@ -15,6 +15,12 @@ public partial class MapManager : MonoBehaviour
{
//<2F><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public const int CELLSCALE = 100;
//<2F><><EFBFBD>ӿ<EFBFBD><D3BF><EFBFBD><EFBFBD><EFBFBD>
public const int widthPixel = 48;
//<2F><><EFBFBD>Ӹ<EFBFBD><D3B8><EFBFBD><EFBFBD><EFBFBD>
public const int heightPixel = 32;
//<2F><><EFBFBD>ŵ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
public const int PicMapPixel = 512;
public delegate void LoadFinishedCallback();
public LoadFinishedCallback onLoadFinishedCallback;

View File

@@ -18,10 +18,12 @@ namespace HxGame.Data
[Serializable]
public class MapRegions
{
public int mapWidth;
public int mapHeight;
public int regionWidth;
public int regionHeight;
public int regionRowNum;
public int regionColNum;
public float regionWidth;
public float regionHeight;
public float cellWidthPixel;
public float cellHeightPixel;
public Region[,] regions;
@@ -57,10 +59,12 @@ namespace HxGame.Data
private void SaveMapInfoConfig(int mapId, XmlElement xmlSettings)
{
xmlSettings.SetAttribute("mapID", mapId.ToString());
xmlSettings.SetAttribute("mapWidth", mapWidth.ToString());
xmlSettings.SetAttribute("mapHeight", mapHeight.ToString());
xmlSettings.SetAttribute("regionRowNum", regionRowNum.ToString());
xmlSettings.SetAttribute("regionColNum", regionColNum.ToString());
xmlSettings.SetAttribute("regionWidth", regionWidth.ToString());
xmlSettings.SetAttribute("regionHeight", regionHeight.ToString());
xmlSettings.SetAttribute("cellWidthPixel", cellWidthPixel.ToString());
xmlSettings.SetAttribute("cellHeightPixel", cellHeightPixel.ToString());
}
private void SaveRegions(XmlDocument xml, XmlElement xmlRegions)
@@ -108,20 +112,19 @@ namespace HxGame.Data
private void LoadMapInfoConfig(XmlNode xmlSettings)
{
mapWidth = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("mapWidth").Value);
mapHeight = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("mapHeight").Value);
regionRowNum = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("regionRowNum").Value);
regionColNum = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("regionColNum").Value);
regionWidth = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("regionWidth").Value);
regionHeight = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("regionHeight").Value);
regionHeight = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("regionHeight").Value);
cellWidthPixel = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("cellWidthPixel").Value);
cellHeightPixel = Convert.ToInt32(xmlSettings.Attributes.GetNamedItem("cellHeightPixel").Value);
}
private void LoadRegions(XmlNode xmlRegions)
{
int row = mapWidth / MapManager.CELLSCALE / regionWidth;
int col = mapHeight / MapManager.CELLSCALE / regionHeight;
XmlNode xmlNode = null;
XmlNodeList xmlNodeList = xmlRegions.ChildNodes;
regions = new Region[row, col];
regions = new Region[regionRowNum, regionColNum];
for (int i = 0; i < xmlNodeList.Count; i++)
{
xmlNode = xmlNodeList.Item(i);

View File

@@ -229,15 +229,4 @@ public class UICellEditor : MonoBehaviour
{
MapManager.Instance.CleanSafe();
}
public void SaveCells()
{
if (!UIWindow.Instance.uiCellInfo.bMapOpened)
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD>ȴ򿪵<C8B4>ͼ");
return;
}
MapManager.Instance.SaveCellsXml();
}
}

View File

@@ -60,25 +60,6 @@ public class UICellInfo : MonoBehaviour
UIWindow.Instance.uiCellEditor.togEdit.isOn = false;
UIWindow.Instance.uiCellEditor.togPathTest.isOn = false;
}
public void LoadCells()
{
if (!bMapOpened)
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD>ȴ򿪵<C8B4>ͼ");
return;
}
if (!MapManager.Instance.LoadObsXml())
CalculationCells();
txtCellWidth.text = MapManager.Instance.CellWidth.ToString();
txtCellHeight.text = MapManager.Instance.CellHeight.ToString();
txtCellRows.text = MapManager.Instance.CellRows.ToString();
txtCellCols.text = MapManager.Instance.CellCols.ToString();
txtTotalCells.text = (MapManager.Instance.CellRows * MapManager.Instance.CellCols).ToString();
}
public void ShowCells()
{
MapManager.Instance.ShowMapGrid();

View File

@@ -312,64 +312,14 @@ public class UICreateMap : MonoBehaviour
btnAutoCleanupRegion.gameObject.SetActive(false);
}
public void SaveRegions()
{
if (!CheckValid())
return;
Transform regionsTrans = UIWindow.Instance.mapTrans.Find("Regions");
if (regionsTrans == null)
{
UIWindow.Instance.ShowMessage(<><C3BB><EFBFBD>ҵ<EFBFBD>Regions<6E>ڵ<EFBFBD>");
return;
}
MapRegions mapRegions = new MapRegions();
mapRegions.mapWidth = Convert.ToInt32(txtMapWidth.text);
mapRegions.mapHeight = Convert.ToInt32(txtMapHeight.text);
mapRegions.regionWidth = Convert.ToInt32(txtRegionWidth.text);
mapRegions.regionHeight = Convert.ToInt32(txtRegionHeight.text);
int row = mapRegions.mapWidth / MapManager.CELLSCALE / mapRegions.regionWidth;
int col = mapRegions.mapHeight / MapManager.CELLSCALE / mapRegions.regionHeight;
Transform trans = null;
mapRegions.regions = new Region[row, col];
for (int i = 0; i < row; i++)
{
for (int j = 0; j < col; j++)
{
mapRegions.regions[i, j] = new Region();
mapRegions.regions[i, j].indexX = i;
mapRegions.regions[i, j].indexY = j;
string regionName = $"{i}_{j}";
trans = regionsTrans.Find(regionName);
if(trans == null)
{
UIWindow.Instance.ShowMessage($"û<><C3BB><EFBFBD>ҵ<EFBFBD>region<6F>ڵ<EFBFBD> name={regionName}");
return;
}
//mapRegions.regions[i, j].regionName = trans.GetComponent<Image>().sprite.name;
mapRegions.regions[i, j].regionName = trans.GetComponent<RawImage>().texture.name;
}
}
mapRegions.SaveXML(Convert.ToInt32(txtMapID.text));
}
public void LoadMapRegions(int mapId)
{
//MapRegions mapRegions = new MapRegions();
//if (!mapRegions.LoadXML(mapId))
// return;
if (!_curMapRegions.LoadXML(mapId))
return;
txtMapID.text = mapId.ToString();
txtMapWidth.text = _curMapRegions.mapWidth.ToString();
txtMapHeight.text = _curMapRegions.mapHeight.ToString();
txtMapWidth.text = _curMapRegions.regionRowNum.ToString();
txtMapHeight.text = _curMapRegions.regionColNum.ToString();
txtRegionWidth.text = _curMapRegions.regionWidth.ToString();
txtRegionHeight.text = _curMapRegions.regionHeight.ToString();

View File

@@ -114,8 +114,7 @@ public class UIMapPanel : MonoBehaviour
}
int mapId = Convert.ToInt32(dropMap.options[dropMap.value].text);
_curOpenMapId = mapId;
MapManager.Instance.LoadMapRegions(_curOpenMapId);
UIWindow.Instance.uiCellInfo.LoadCells();
MapManager.Instance.LoadMapRegionSprites(_curOpenMapId);
//UIWindow.Instance.uiCellInfo.ShowCells();
//UIWindow.Instance.uiEditMapConfig.LoadMapConfig(mapId);
//UIWindow.Instance.uiMonstersPanel.LoadMonsterConfig(mapId);
@@ -174,15 +173,16 @@ public class UIMapPanel : MonoBehaviour
{
_saving = true;
Debug.Log("<22><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
MapManager.Instance.SaveRegionXML();
//UIWindow.Instance.uiCreateMap.SaveRegions();
UIWindow.Instance.uiCellEditor.SaveCells();
UIWindow.Instance.uiEditMapConfig.SaveMapConfig();
UIWindow.Instance.uiMonstersPanel.SaveMonsterConfig();
UIWindow.Instance.uiNpcsPanel.SaveNpcsConfig();
UIWindow.Instance.uiTriggersPanel.SaveTriggersConfig();
UIWindow.Instance.uiJuBaosPanel.SaveJuBaoConfig();
UIWindow.Instance.uiFuBensPanel.SaveFuBenConfig();
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
//UIWindow.Instance.uiCellEditor.SaveCells();
//UIWindow.Instance.uiEditMapConfig.SaveMapConfig();
//UIWindow.Instance.uiMonstersPanel.SaveMonsterConfig();
//UIWindow.Instance.uiNpcsPanel.SaveNpcsConfig();
//UIWindow.Instance.uiTriggersPanel.SaveTriggersConfig();
//UIWindow.Instance.uiJuBaosPanel.SaveJuBaoConfig();
//UIWindow.Instance.uiFuBensPanel.SaveFuBenConfig();
//UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD>");
_saving = false;
}
}