提交所有

This commit is contained in:
2025-07-10 13:45:07 +08:00
parent afc3a96bdf
commit 2467a88fb4
6 changed files with 665 additions and 363 deletions

View File

@@ -104,11 +104,11 @@ public partial class MapManager : MonoBehaviour
}
}
public void CreateObs()
public void CreateObs(int mapid)
{
if(_curMapRegions == null) return;
float jpgscenew = PicMapPixel / 100.0f;
MapManager.Instance.GenerateMap(jpgscenew * _curMapRegions.regionRowNum, jpgscenew * _curMapRegions.regionColNum, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
MapManager.Instance.GenerateMap(mapid, jpgscenew * _curMapRegions.regionRowNum, jpgscenew * _curMapRegions.regionColNum, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
}
private async void multithreadLoadTextrue(string fullPath,SpriteRenderer sr)
{

View File

@@ -14,11 +14,11 @@ public partial class MapManager : MonoBehaviour
public event Action onMapCreated;
public CellType cellType;
public Map GenerateMap(float width, float height, float sideWidth, float sideHeight)
public Map GenerateMap(int mapid, float width, float height, float sideWidth, float sideHeight)
{
ClearMapGrid();
map = new Map(width, height, sideWidth, sideHeight);
map.SetMapId(1000);
map.SetMapId(mapid);
//默认设置半透明0.3
map.ChangeGridAlpha(0.4f);
onMapCreated?.Invoke();
@@ -67,19 +67,6 @@ public partial class MapManager : MonoBehaviour
return;
map.mapGrid.gameObject.SetActive(!map.mapGrid.activeInHierarchy);
}
/// <summary>
/// 获取地图位置的高度
/// </summary>
/// <param name="pos"></param>
/// <returns></returns>
public int GetMapY(Vector3 pos)
{
int posIndex = Mathf.FloorToInt(pos.x + Mathf.FloorToInt(pos.z) * map.horizontalNumber);
return map.selector.GetGridData()[posIndex].barrier;
}
/// <summary>
/// 是否打开了地图
/// </summary>
@@ -141,8 +128,6 @@ public partial class Map
public float height { get; private set; }
public float sideWidth { get; private set; }
public float sideHeight { get; private set; }
public int horizontalNumber { get { return (int)(width / sideWidth); } }
public int verticalNumber { get { return (int)(height / sideHeight); } }
public Map(float width, float height, float sideWidth,float sideHeight)
{
@@ -231,8 +216,7 @@ public partial class Map
int verticalNumber = br.ReadInt32();
float sideWidth = br.ReadInt32() / 100f; // 读取时直接除以 100
float sideHeight = br.ReadInt32() / 100f; // 读取时直接除以 100
var map = MapManager.Instance.GenerateMap(horizontalNumber * sideWidth, verticalNumber * sideHeight, sideWidth, sideHeight);
map.SetMapId(mapId);
var map = MapManager.Instance.GenerateMap(mapId,horizontalNumber * sideWidth, verticalNumber * sideHeight, sideWidth, sideHeight);
GridSelector.RenderData[] data = map.selector.GetGridData();
for (int i = 0; i < horizontalNumber * verticalNumber; i++) {
data[i].barrier = br.ReadInt32();