完善坐标系

This commit is contained in:
2025-06-27 01:08:56 +08:00
parent 7d724f9857
commit afc3a96bdf
15 changed files with 240 additions and 183 deletions

View File

@@ -69,26 +69,28 @@ public partial class MapManager : MonoBehaviour
_curMapRegions.cellWidthPixel = widthPixel;
_curMapRegions.cellHeightPixel = heightPixel;
_curMapRegions.regions = new Region[mapRownum, mapColumn];
int maxRow = mapColumn;
int maxCol = mapRownum;
float jpgscenew = PicMapPixel / 100.0f;
for (int row = 0; row < mapRownum; row++)
for (int row = 0; row < mapRownum; row++) //14 * 11
{
for (int col = 0; col < mapColumn; col++)
{
string filename = $"v{mapId}_r{row + 1}_c{col + 1}"; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>v1000_r1_c1.jpg
string filename = $"v{mapId}_r{mapColumn - col}_c{row + 1}"; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>v1000_r11_c1.jpg
string spPath = PathUtil.GetMapTexure(1000, filename, "jpg");
GameObject obj = new GameObject(filename);
obj.transform.SetParent(mapRegionParent);
SpriteRenderer sr = obj.AddComponent<SpriteRenderer>();
float x = col * jpgscenew;
float y = (mapRownum - row - 1) * jpgscenew;
float x = row * jpgscenew;
float y = col * jpgscenew;
obj.transform.position = new Vector2(x, y);
_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}"; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>v1000_r1_c1.jpg
_curMapRegions.regions[row, col].regionName = filename;
}
}
MapManager.Instance.ReseCamera(jpgscenew * mapColumn, jpgscenew * mapRownum);
@@ -106,7 +108,7 @@ public partial class MapManager : MonoBehaviour
{
if(_curMapRegions == null) return;
float jpgscenew = PicMapPixel / 100.0f;
MapManager.Instance.GenerateMap(jpgscenew * _curMapRegions.regionColNum, jpgscenew * _curMapRegions.regionRowNum, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
MapManager.Instance.GenerateMap(jpgscenew * _curMapRegions.regionRowNum, jpgscenew * _curMapRegions.regionColNum, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
}
private async void multithreadLoadTextrue(string fullPath,SpriteRenderer sr)
{

View File

@@ -216,7 +216,36 @@ public class UICellEditor : MonoBehaviour
{
MapManager.Instance.HideCells();
}
public void EditorAreaToggleChange(Toggle t)
{
if (t.isOn)
{
switch (t.name)
{
case "MoveToggle":
editorGrid = CellType.Move;
break;
case "BlockToggle":
editorGrid = CellType.Obstacle;
break;
case "HideToggle":
editorGrid = CellType.Hide;
break;
case "SafeToggle":
editorGrid = CellType.Safe;
break;
case "StallToggle":
editorGrid = CellType.Stall;
break;
}
MapManager.Instance.map?.selector.RefreshPlaneRender();
}
if (editorAreaToggle.ActiveToggles().Count() == 0)
{
Debug.Log(<><C3BB>ѡ<EFBFBD>б<D0B1><E0BCAD><EFBFBD><EFBFBD>");
editorGrid = CellType.None;
}
}
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>
/// </summary>

View File

@@ -63,8 +63,8 @@ public class UICellInfo : MonoBehaviour
if (MapManager.Instance.map == null || MapManager.Instance.map.selector == null)
return;
if(MapManager.Instance._curMapRegions == null) return;
txtMapWidth.text = MapManager.Instance._curMapRegions.regionColNum.ToString();
txtMapHeight.text = MapManager.Instance._curMapRegions.regionRowNum.ToString();
txtMapWidth.text = MapManager.Instance._curMapRegions.regionRowNum.ToString();
txtMapHeight.text = MapManager.Instance._curMapRegions.regionColNum.ToString();
txtCellRows.text = MapManager.Instance.map.selector.horizontalNumber.ToString();
txtCellCols.text = MapManager.Instance.map.selector.verticalNumber.ToString();
txtTotalCells.text = MapManager.Instance.map.selector.totalNumber.ToString();

View File

@@ -69,8 +69,8 @@ public class UIMapPanel : MonoBehaviour
if (maxRow > 0 && maxCol > 0)
{
MapManager.Instance.allMaps[mapId] = (maxRow, maxCol);
Debug.Log($"Map {mapId} loaded with max dimensions: {maxRow}x{maxCol}");
MapManager.Instance.allMaps[mapId] = (maxCol, maxRow);
Debug.Log($"Map {mapId} loaded with max dimensions: {maxCol}x{maxRow}");
}
else
{