显示ara

This commit is contained in:
2025-06-21 01:29:18 +08:00
parent 0f78ad7a32
commit e9141b7ec1
158 changed files with 347644 additions and 3613 deletions

View File

@@ -80,6 +80,17 @@ public class GridSelector : MonoBehaviour
int hitIndex = Mathf.FloorToInt(pos.x / map.sideWidth) + Mathf.FloorToInt(pos.z / map.sideHeight) * horizontalNumber;
return hitIndex;
}
public Vector2Int getMapGrid(Vector3 pos)
{
return getMapGrid(new Vector2(pos.x,pos.y));
}
public Vector2Int getMapGrid(Vector2 pos)
{
var grid = new Vector2Int();
grid.x = Mathf.FloorToInt(pos.x / map.sideWidth);
grid.y = Mathf.FloorToInt(pos.y / map.sideHeight);
return grid;
}
private void Awake()
{
mapRenderer = GetComponent<MeshRenderer>();

View File

@@ -404,73 +404,21 @@ public partial class MapManager : MonoBehaviour
public void ShowSpecialPoint(EditCellType cellType)
{
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
if (cellsTrans == null)
{
UIWindow.Instance.ShowMessage(<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
return;
}
int size = 0;
string cellName = GetSpecialName(cellType, out size);
Transform trans = null;
for (int i = 1; i <= size; i++)
{
trans = cellsTrans.Find($"{cellName}{i}");
if (trans == null)
continue;
trans.gameObject.SetActive(true);
}
if(cellType == EditCellType.MonsterArea)
{
foreach(var item in _dicMonsterPathPointSize)
{
for (int i = 1; i <= item.Value; i++)
{
cellName = $"MonsterPath{item.Key}{i}";
trans = cellsTrans.Find(cellName);
if (trans == null)
continue;
trans.gameObject.SetActive(true);
}
}
}
}
public void HideSpecialPoint(EditCellType cellType)
{
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
if (cellsTrans == null)
{
UIWindow.Instance.ShowMessage(<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
return;
}
int size = 0;
string cellName = GetSpecialName(cellType, out size);
Transform trans = null;
for(int i=1; i<=size; i++)
{
trans = cellsTrans.Find($"{cellName}{i}");
if (trans == null)
continue;
trans.gameObject.SetActive(false);
}
}
public void RemoveSpecialPoint(EditCellType cellType, int idx = 0)
{
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
if (cellsTrans == null)
{
UIWindow.Instance.ShowMessage(<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
return;
}
string cellName = string.Empty;
switch (cellType)
@@ -518,40 +466,17 @@ public partial class MapManager : MonoBehaviour
return;
}
if (cellsTrans.Find(cellName))
if (mapAreaParent.Find(cellName))
{
DestroyImmediate(cellsTrans.Find(cellName).gameObject);
DestroyImmediate(mapAreaParent.Find(cellName).gameObject);
}
}
public void CreateSpecialPoint(int x, int y, EditCellType cellType)
{
Transform cellsTrans = UIWindow.Instance.mapTrans.Find("CellsNode");
if (cellsTrans == null)
{
UIWindow.Instance.ShowMessage(<><C3BB><EFBFBD>ҵ<EFBFBD>CellsNode<64>ڵ<EFBFBD>");
return;
}
if (_curOpenMapId <= 0)
return;
if (cellsNode == null)
return;
if (mapWidth <= 0 || mapHeight <= 0)
return;
if (_cellWidth <= 0 || _cellHeight <= 0)
return;
if (_cellRows <= 0 || _cellCols <= 0)
return;
if (y < 0 || y >= _cellRows)
return;
if (x < 0 || x >= _cellCols)
return;
UnityEngine.Object obj = null;
@@ -641,14 +566,14 @@ public partial class MapManager : MonoBehaviour
}
GameObject go = null;
if (cellsTrans.Find(cellName))
if (mapAreaParent.Find(cellName))
{
go = cellsTrans.Find(cellName).gameObject;
go = mapAreaParent.Find(cellName).gameObject;
}
else
{
go = Instantiate(obj) as GameObject;
go.transform.SetParent(cellsTrans, false);
go.transform.SetParent(mapAreaParent, false);
go.transform.localScale = new Vector3(((float)_cellWidth / CELLSCALE) - 0.1f, ((float)_cellHeight / CELLSCALE) - 0.1f, 1);
}

View File

@@ -22,7 +22,10 @@ using static UnityEngine.Rendering.DebugUI.Table;
public partial class MapManager : MonoBehaviour
{
[SerializeField]
private Transform mapRegion;
private Transform mapRegionParent;
public Transform mapGridParent;
public Transform mapAreaParent;
public Dictionary<string, (int maxRow, int maxCol)> allMaps = new Dictionary<string, (int maxRow, int maxCol)>();
/// <summary>
@@ -137,7 +140,7 @@ public partial class MapManager : MonoBehaviour
string filename = $"v{mapId}_r{row + 1}_c{col + 1}"; // <20><><EFBFBD><EFBFBD><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD>v1000_r1_c1.jpg
string spPath = PathUtil.GetMapTexure(1000, filename, "jpg");
GameObject obj = new GameObject(filename);
obj.transform.SetParent(mapRegion);
obj.transform.SetParent(mapRegionParent);
SpriteRenderer sr = obj.AddComponent<SpriteRenderer>();
float x = col * jpgscenew;
float y = (mapRownum - row - 1) * jpgscenew;
@@ -156,7 +159,7 @@ public partial class MapManager : MonoBehaviour
public void ClearMapRegions()
{
ClearMapGrid();
foreach (Transform child in mapRegion)
foreach (Transform child in mapRegionParent)
{
Destroy(child.gameObject);
}
@@ -165,7 +168,7 @@ public partial class MapManager : MonoBehaviour
public void CreateObs()
{
if(_curMapRegions == null) return;
float jpgscenew = PicMapPixel / 100;
float jpgscenew = PicMapPixel / 100.0f;
MapManager.Instance.GenerateMap(jpgscenew * _curMapRegions.regionColNum, jpgscenew * _curMapRegions.regionRowNum, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
}
private async void multithreadLoadTextrue(string fullPath,SpriteRenderer sr)

View File

@@ -153,7 +153,7 @@ public partial class Map
mapGrid = CreateMapGrid();
selector = mapGrid.AddComponent<GridSelector>();
selector.OnMapCreated(this);
mapGrid.transform.parent = MapManager.Instance.transform;
mapGrid.transform.parent = MapManager.Instance.mapGridParent;
mapGrid.transform.localPosition = Vector3.zero;
mapGrid.transform.localEulerAngles = new Vector3(-90,0,0);
//创建地图的时候需要赋值一下当前类型