diff --git a/Assets/GameAssets/Maps/1000/XML/MapRegions.xml b/Assets/GameAssets/Maps/1000/XML/MapRegions.xml
new file mode 100644
index 0000000..48b6d9f
--- /dev/null
+++ b/Assets/GameAssets/Maps/1000/XML/MapRegions.xml
@@ -0,0 +1,160 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Assets/GameAssets/Maps/1000/XML/MapRegions.xml.meta b/Assets/GameAssets/Maps/1000/XML/MapRegions.xml.meta
new file mode 100644
index 0000000..636a708
--- /dev/null
+++ b/Assets/GameAssets/Maps/1000/XML/MapRegions.xml.meta
@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: a3d8a7c7ffb73084299764bef946df80
+TextScriptImporter:
+ externalObjects: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/Scripts/Map/MapManager.Load.cs b/Assets/Scripts/Map/MapManager.Region.cs
similarity index 71%
rename from Assets/Scripts/Map/MapManager.Load.cs
rename to Assets/Scripts/Map/MapManager.Region.cs
index 7da6c7b..c58202b 100644
--- a/Assets/Scripts/Map/MapManager.Load.cs
+++ b/Assets/Scripts/Map/MapManager.Region.cs
@@ -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 allMaps = new Dictionary();
+ public Dictionary allMaps = new Dictionary();
+
+ ///
+ /// µ±Ç°µØÍ¼ÇøÓò
+ ///
+ 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)
+ ///
+ /// ±£´æµØÍ¼ÅäÖÃ
+ ///
+ ///
+ 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().sprite.name;
- mapRegions.regions[i, j].regionName = trans.GetComponent().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();
- }
}
diff --git a/Assets/Scripts/Map/MapManager.Load.cs.meta b/Assets/Scripts/Map/MapManager.Region.cs.meta
similarity index 100%
rename from Assets/Scripts/Map/MapManager.Load.cs.meta
rename to Assets/Scripts/Map/MapManager.Region.cs.meta
diff --git a/Assets/Scripts/Map/MapManager.cs b/Assets/Scripts/Map/MapManager.cs
index 4a36f75..b1656a5 100644
--- a/Assets/Scripts/Map/MapManager.cs
+++ b/Assets/Scripts/Map/MapManager.cs
@@ -15,6 +15,12 @@ public partial class MapManager : MonoBehaviour
{
//µØÍ¼¿í¸ßËõ·Å
public const int CELLSCALE = 100;
+ //¸ñ×Ó¿íÏñËØ
+ public const int widthPixel = 48;
+ //¸ñ×Ó¸ßÏñËØ
+ public const int heightPixel = 32;
+ //µ¥ÕŵØÍ¼ÏñËØ
+ public const int PicMapPixel = 512;
public delegate void LoadFinishedCallback();
public LoadFinishedCallback onLoadFinishedCallback;
diff --git a/Assets/Scripts/System/MapRegions.cs b/Assets/Scripts/System/MapRegions.cs
index aba570e..69cb296 100644
--- a/Assets/Scripts/System/MapRegions.cs
+++ b/Assets/Scripts/System/MapRegions.cs
@@ -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);
diff --git a/Assets/Scripts/UI/UICellEditor.cs b/Assets/Scripts/UI/UICellEditor.cs
index 19f913f..f8e5f3f 100644
--- a/Assets/Scripts/UI/UICellEditor.cs
+++ b/Assets/Scripts/UI/UICellEditor.cs
@@ -229,15 +229,4 @@ public class UICellEditor : MonoBehaviour
{
MapManager.Instance.CleanSafe();
}
-
- public void SaveCells()
- {
- if (!UIWindow.Instance.uiCellInfo.bMapOpened)
- {
- UIWindow.Instance.ShowMessage("ÇëÏÈ´ò¿ªµØÍ¼");
- return;
- }
-
- MapManager.Instance.SaveCellsXml();
- }
}
diff --git a/Assets/Scripts/UI/UICellInfo.cs b/Assets/Scripts/UI/UICellInfo.cs
index 4e379cd..e7434c9 100644
--- a/Assets/Scripts/UI/UICellInfo.cs
+++ b/Assets/Scripts/UI/UICellInfo.cs
@@ -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("ÇëÏÈ´ò¿ªµØÍ¼");
- 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();
diff --git a/Assets/Scripts/UI/UICreateMap.cs b/Assets/Scripts/UI/UICreateMap.cs
index 43307e1..9c03727 100644
--- a/Assets/Scripts/UI/UICreateMap.cs
+++ b/Assets/Scripts/UI/UICreateMap.cs
@@ -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("ûÓÐÕÒµ½Regions½Úµã");
- 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().sprite.name;
- mapRegions.regions[i, j].regionName = trans.GetComponent().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();
diff --git a/Assets/Scripts/UI/UIMapPanel.cs b/Assets/Scripts/UI/UIMapPanel.cs
index 6a8307c..55162ac 100644
--- a/Assets/Scripts/UI/UIMapPanel.cs
+++ b/Assets/Scripts/UI/UIMapPanel.cs
@@ -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("ÕýÔÚ±£´æËùÓÐÊý¾Ý...");
+ 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("±£´æ³É¹¦");
+ //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("±£´æ³É¹¦");
_saving = false;
}
}