稍微修改
This commit is contained in:
@@ -17951,7 +17951,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -82.3, y: 215}
|
||||
m_AnchoredPosition: {x: -167.3, y: 215}
|
||||
m_SizeDelta: {x: 30, y: 20}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &888453850
|
||||
@@ -25050,7 +25050,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: 49.4, y: 214.2}
|
||||
m_AnchoredPosition: {x: -37.1, y: 214.2}
|
||||
m_SizeDelta: {x: 50, y: 20}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1278429982
|
||||
@@ -29069,7 +29069,7 @@ RectTransform:
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -18.5, y: 214.5}
|
||||
m_AnchoredPosition: {x: -104, y: 214.5}
|
||||
m_SizeDelta: {x: 50, y: 20}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1466376496
|
||||
|
||||
@@ -22,8 +22,8 @@ public class GridSelector : MonoBehaviour
|
||||
private MeshCollider mapCollider;
|
||||
|
||||
private Map map;
|
||||
public int horizontalNumber { get { return Mathf.CeilToInt(map.width / map.sideWidth); } }
|
||||
public int verticalNumber { get { return Mathf.CeilToInt(map.height / map.sideHeight); } }
|
||||
public int horizontalNumber { get { return Mathf.FloorToInt(map.width / map.sideWidth); } }
|
||||
public int verticalNumber { get { return Mathf.FloorToInt(map.height / map.sideHeight); } }
|
||||
public int totalNumber { get { return horizontalNumber * verticalNumber; } }
|
||||
|
||||
public int moveNum;
|
||||
@@ -335,6 +335,7 @@ public class GridSelector : MonoBehaviour
|
||||
}
|
||||
else if (selectedGridIndex.Count == 1)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
int beginIndex = selectedGridIndex[0];
|
||||
GetXyByIndex(beginIndex, out int x, out int y);
|
||||
string labelText = string.Format(
|
||||
@@ -346,8 +347,7 @@ public class GridSelector : MonoBehaviour
|
||||
labelText,
|
||||
style
|
||||
);
|
||||
//GUI.Label(new Rect(width - 820, 20, 400, 50), string.Format("所选点XY序列:({0},{1}) 高度{2} 点类型 {3}", x, y, ((dataArray[beginIndex].barrier >> 16) - 10000)/100.0f, CellTypeColors.GetAreaStr((dataArray[beginIndex].barrier)), style));
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -183,7 +183,7 @@ public partial class MapManager : MonoBehaviour
|
||||
{
|
||||
for (int col = 0; col < mapColumn; col++)
|
||||
{
|
||||
string filename = $"v{mapId}_r{mapColumn - col}_c{row + 1}"; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>v1000_r11_c1.jpg
|
||||
string filename = isSmallPic ? $"v{mapId}_r{mapColumn - col}_c{row + 1}" : $"r{mapColumn - col}_c{row + 1}"; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>v1000_r11_c1.jpg
|
||||
string spPath = PathUtil.GetMapTexure(mapId, filename, "jpg");
|
||||
GameObject obj = new GameObject(filename);
|
||||
obj.transform.SetParent(mapRegionParent);
|
||||
|
||||
@@ -23,6 +23,8 @@ public partial class MapManager : MonoBehaviour
|
||||
//<2F><><EFBFBD>ŵ<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>
|
||||
public int PicMapPixel => int.Parse(mapPic.text);
|
||||
|
||||
public bool isSmallPic => PicMapPixel == 512;
|
||||
|
||||
public delegate void LoadFinishedCallback();
|
||||
public LoadFinishedCallback onLoadFinishedCallback;
|
||||
//public delegate void CloseMapCallback();
|
||||
|
||||
@@ -24,9 +24,9 @@ public class UICellInfo : MonoBehaviour
|
||||
public bool bMapOpened;
|
||||
public Text txtSelectInfo;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
@@ -63,8 +63,8 @@ public class UICellInfo : MonoBehaviour
|
||||
{
|
||||
MapManager.Instance.HideMapGrid();
|
||||
}
|
||||
public void ShowMapCellInfo()
|
||||
{
|
||||
public void ShowMapCellInfo()
|
||||
{
|
||||
if (MapManager.Instance.map == null || MapManager.Instance.map.selector == null)
|
||||
return;
|
||||
if (MapManager.Instance._curMapRegions == null) return;
|
||||
@@ -78,74 +78,74 @@ public class UICellInfo : MonoBehaviour
|
||||
txtMoveCells.text = MapManager.Instance.map.selector.moveNum.ToString();
|
||||
}
|
||||
|
||||
public void ShowMapWidthAndHeight(int mapId)
|
||||
{
|
||||
if (!MapManager.Instance.allMaps.TryGetValue(mapId.ToString(), out var mapInfo))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
public void ShowMapWidthAndHeight(int mapId)
|
||||
{
|
||||
if (!MapManager.Instance.allMaps.TryGetValue(mapId.ToString(), out var mapInfo))
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
txtMapWidth.text = mapInfo.maxRow.ToString();
|
||||
txtMapHeight.text = mapInfo.maxCol.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
|
||||
/// </summary>
|
||||
public void LoadCell()
|
||||
{
|
||||
MapManager.Instance.LoadMapObs(MapManager.Instance._curOpenMapId);
|
||||
public void LoadCell()
|
||||
{
|
||||
MapManager.Instance.LoadMapObs(MapManager.Instance._curOpenMapId);
|
||||
ShowMapCellInfo();
|
||||
}
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// <summary>
|
||||
/// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
/// </summary>
|
||||
public void ReCalculateCell()
|
||||
{
|
||||
int oldhorizontalNumber = MapManager.Instance.map?.selector?.horizontalNumber ?? 0;
|
||||
int oldverticalNumber = MapManager.Instance.map?.selector?.verticalNumber ?? 0;
|
||||
var oldRendData = MapManager.Instance.map?.selector?.GetGridData();
|
||||
int width = int.Parse(txtCellRows.text);
|
||||
int height = int.Parse(txtCellCols.text);
|
||||
float cellW = int.Parse(txtCellWidth.text) / 100.0f;
|
||||
float cellH = int.Parse(txtCellHeight.text) / 100.0f;
|
||||
public void ReCalculateCell()
|
||||
{
|
||||
int oldhorizontalNumber = MapManager.Instance.map?.selector?.horizontalNumber ?? 0;
|
||||
int oldverticalNumber = MapManager.Instance.map?.selector?.verticalNumber ?? 0;
|
||||
var oldRendData = MapManager.Instance.map?.selector?.GetGridData();
|
||||
int width = int.Parse(txtCellRows.text);
|
||||
int height = int.Parse(txtCellCols.text);
|
||||
float cellW = int.Parse(txtCellWidth.text) / 100.0f;
|
||||
float cellH = int.Parse(txtCellHeight.text) / 100.0f;
|
||||
MapManager.Instance.GenerateMap(MapManager.Instance._curOpenMapId,width * cellW, height * cellH, cellW, cellH);
|
||||
var newRendData = MapManager.Instance.map?.selector?.GetGridData();
|
||||
for (int i = 0; i < MapManager.Instance.map?.selector.horizontalNumber; i++)
|
||||
{
|
||||
for (int j = 0; j < MapManager.Instance.map?.selector.verticalNumber; j++)
|
||||
{
|
||||
if (i < oldhorizontalNumber && j < oldverticalNumber)
|
||||
{
|
||||
int oldindex = i + j * oldhorizontalNumber;
|
||||
//ȡ<><C8A1><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
int index = MapManager.Instance.map.selector.GetIndexByXY(i, j);
|
||||
newRendData[index] = oldRendData[oldindex];
|
||||
for (int i = 0; i < MapManager.Instance.map?.selector.horizontalNumber; i++)
|
||||
{
|
||||
for (int j = 0; j < MapManager.Instance.map?.selector.verticalNumber; j++)
|
||||
{
|
||||
if (i < oldhorizontalNumber && j < oldverticalNumber)
|
||||
{
|
||||
int oldindex = i + j * oldhorizontalNumber;
|
||||
//ȡ<><C8A1><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>
|
||||
int index = MapManager.Instance.map.selector.GetIndexByXY(i, j);
|
||||
newRendData[index] = oldRendData[oldindex];
|
||||
}
|
||||
else {//<2F>¸<EFBFBD><C2B8><EFBFBD>
|
||||
int index = MapManager.Instance.map.selector.GetIndexByXY(i, j);
|
||||
newRendData[index] = new RenderData();
|
||||
newRendData[index].barrier = (int)CellType.Obstacle;
|
||||
|
||||
newRendData[index].barrier = (int)CellType.Obstacle;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
MapManager.Instance.map.selector.RefreshPlaneRender();
|
||||
ShowMapCellInfo();
|
||||
}
|
||||
public void Update()
|
||||
{
|
||||
bool isOpen = false;
|
||||
do {
|
||||
if (MapManager.Instance.map == null) break;
|
||||
if (MapManager.Instance.map.selector == null) break;
|
||||
if (MapManager.Instance.map.selector.selectedGridIndex.Count == 1)
|
||||
{
|
||||
int beginIndex = MapManager.Instance.map.selector.selectedGridIndex[0];
|
||||
MapManager.Instance.map.selector.GetXyByIndex(beginIndex, out int x, out int y);
|
||||
txtSelectInfo.text = string.Format("<22><>ѡ<EFBFBD><D1A1>:{0},{1} <20><>Ϣ:{2}", x, y, CellTypeColors.GetAreaStr((MapManager.Instance.map.selector.dataArray[beginIndex].barrier)));
|
||||
isOpen = true;
|
||||
}
|
||||
} while (false);
|
||||
txtSelectInfo.transform.parent.gameObject.SetActive(isOpen);
|
||||
public void Update()
|
||||
{
|
||||
bool isOpen = false;
|
||||
do {
|
||||
if (MapManager.Instance.map == null) break;
|
||||
if (MapManager.Instance.map.selector == null) break;
|
||||
if (MapManager.Instance.map.selector.selectedGridIndex.Count == 1)
|
||||
{
|
||||
int beginIndex = MapManager.Instance.map.selector.selectedGridIndex[0];
|
||||
MapManager.Instance.map.selector.GetXyByIndex(beginIndex, out int x, out int y);
|
||||
txtSelectInfo.text = string.Format("<22><>ѡ<EFBFBD><D1A1>:{0},{1} <20><>Ϣ:{2}", x, y, CellTypeColors.GetAreaStr((MapManager.Instance.map.selector.dataArray[beginIndex].barrier)));
|
||||
isOpen = true;
|
||||
}
|
||||
} while (false);
|
||||
txtSelectInfo.transform.parent.gameObject.SetActive(isOpen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,18 @@ public class UIMapPanel : MonoBehaviour
|
||||
return;
|
||||
}
|
||||
MapManager.Instance.allMaps.Clear();
|
||||
string[] mapFolders = Directory.GetDirectories(mapsDirectory);
|
||||
foreach (string folderPath in mapFolders)
|
||||
string[] mapFolders = Directory.GetDirectories(mapsDirectory);
|
||||
// <20><> mapId <20><><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
var sortedMapFolders = mapFolders
|
||||
.OrderBy(folderPath =>
|
||||
{
|
||||
string folderName = Path.GetFileName(folderPath); // <20><><EFBFBD><EFBFBD> "v1000"
|
||||
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>ֲ<EFBFBD><D6B2><EFBFBD>
|
||||
var match = Regex.Match(folderName, @"\d+");
|
||||
return match.Success ? int.Parse(match.Value) : int.MaxValue;
|
||||
})
|
||||
.ToArray();
|
||||
foreach (string folderPath in sortedMapFolders)
|
||||
{
|
||||
string[] pathSplit = folderPath.Split(Path.DirectorySeparatorChar);
|
||||
string mapId = pathSplit[pathSplit.Length - 1]; // <20><><EFBFBD><EFBFBD> "v1000"
|
||||
@@ -50,7 +60,7 @@ public class UIMapPanel : MonoBehaviour
|
||||
string[] imageFiles = Directory.GetFiles(textureDirectory, "*.jpg");
|
||||
int maxRow = 0;
|
||||
int maxCol = 0;
|
||||
string pattern = $@"{mapId}_r(\d+)_c(\d+)"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ƥ<EFBFBD><C6A5> v1000_rXX_cYY
|
||||
string pattern = $@"r(\d+)_c(\d+)"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ƥ<EFBFBD><C6A5> v1000_rXX_cYY
|
||||
Regex regex = new Regex(pattern);
|
||||
|
||||
foreach (string filePath in imageFiles)
|
||||
@@ -159,7 +169,7 @@ public class UIMapPanel : MonoBehaviour
|
||||
int col = (index % width) + 1;
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õ<EFBFBD>ͼID<49><44>
|
||||
string newFileName = $"v{mapId}_r{row}_c{col}";
|
||||
string newFileName = $"r{row}_c{col}";
|
||||
string newFilePath = Path.Combine(mapsDirectory, newFileName + fileExtension);
|
||||
|
||||
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD>
|
||||
@@ -190,7 +200,7 @@ public class UIMapPanel : MonoBehaviour
|
||||
private bool IsAlreadyRenamed(string[] imageFiles, int mapId)
|
||||
{
|
||||
// Ŀ<><C4BF><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>v{mapId}_r<5F><72><EFBFBD><EFBFBD>_c<5F><63><EFBFBD><EFBFBD>
|
||||
string pattern = $"^v{mapId}_r\\d+_c\\d+$";
|
||||
string pattern = $"^r\\d+_c\\d+$";
|
||||
var regex = new System.Text.RegularExpressions.Regex(pattern);
|
||||
|
||||
foreach (string filePath in imageFiles)
|
||||
@@ -218,7 +228,7 @@ public class UIMapPanel : MonoBehaviour
|
||||
{
|
||||
bool hasMapFormat = false;
|
||||
bool hasTargetFormat = false;
|
||||
string pattern = $"^v{mapId}_r\\d+_c\\d+$";
|
||||
string pattern = $"^r\\d+_c\\d+$";
|
||||
var regex = new System.Text.RegularExpressions.Regex(pattern);
|
||||
|
||||
foreach (string filePath in imageFiles)
|
||||
|
||||
Reference in New Issue
Block a user