提交所有

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

File diff suppressed because it is too large Load Diff

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();

View File

@@ -3,6 +3,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.VFX;
///<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ - <20><>ɫ<EFBFBD><C9AB>
///<2F><><EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݣ<EFBFBD><DDA3><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
@@ -13,8 +14,8 @@ public class UICellInfo : MonoBehaviour
public Text txtMapHeight;
public Text txtTotalCells;
public Text txtMoveCells;
public Text txtCellRows;
public Text txtCellCols;
public InputField txtCellRows;
public InputField txtCellCols;
public InputField txtCellWidth;
public InputField txtCellHeight;
@@ -72,4 +73,24 @@ public class UICellInfo : MonoBehaviour
txtCellHeight.text = MapManager.heightPixel.ToString();
txtMoveCells.text = MapManager.Instance.map.selector.moveNum.ToString();
}
/// <summary>
/// <20><><EFBFBD>ظ<EFBFBD><D8B8><EFBFBD>
/// </summary>
public void LoadCell()
{
MapManager.Instance.LoadMapObs(UIWindow.Instance.uiMapPanel.CurOpenMapId);
ShowMapCellInfo();
}
/// <summary>
/// <20><><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public void ReCalculateCell()
{
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(UIWindow.Instance.uiMapPanel.CurOpenMapId,width * cellW, height * cellH, cellW, cellH);
ShowMapCellInfo();
}
}

View File

@@ -128,7 +128,7 @@ public class UIMapPanel : MonoBehaviour
//<2F><><EFBFBD><EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD><C3A3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (MapManager.Instance.map == null)
{
MapManager.Instance.CreateObs();
MapManager.Instance.CreateObs(_curOpenMapId);
}
UICellInfo.Instance.ShowMapCellInfo();
}