编辑器

This commit is contained in:
tangbin
2025-11-18 10:11:56 +08:00
parent 841a08f40e
commit 5af3e15719
89 changed files with 6430 additions and 19 deletions

View File

@@ -22,8 +22,8 @@ public class GridSelector : MonoBehaviour
private MeshCollider mapCollider;
private Map map;
public int horizontalNumber { get { return Mathf.FloorToInt(map.width / map.sideWidth); } }
public int verticalNumber { get { return Mathf.FloorToInt(map.height / map.sideHeight); } }
public int horizontalNumber => map.horizontalNumber;
public int verticalNumber => map.verticalNumber;
public int totalNumber { get { return horizontalNumber * verticalNumber; } }
public int moveNum;

View File

@@ -213,7 +213,9 @@ public partial class MapManager : MonoBehaviour
{
if(_curMapRegions == null) return;
float jpgscenew = PicMapPixel / 100.0f;
MapManager.Instance.GenerateMap(mapid, jpgscenew * _curMapRegions.regionRowNum, jpgscenew * _curMapRegions.regionColNum, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
int horizontalNumber = Mathf.FloorToInt((jpgscenew * _curMapRegions.regionRowNum) / (_curMapRegions.cellWidthPixel / 100.0f));
int verticalNumber = Mathf.FloorToInt((jpgscenew * _curMapRegions.regionColNum) / (_curMapRegions.cellHeightPixel / 100.0f));
MapManager.Instance.GenerateMap(mapid, horizontalNumber, verticalNumber, _curMapRegions.cellWidthPixel / 100.0f, _curMapRegions.cellHeightPixel / 100.0f);
}
private async void multithreadLoadTextrue(string fullPath,SpriteRenderer sr, HxGame.Data.Region region)
{

View File

@@ -14,10 +14,10 @@ public partial class MapManager : MonoBehaviour
public event Action onMapCreated;
public CellType cellType;
public Map GenerateMap(int mapid, float width, float height, float sideWidth, float sideHeight)
public Map GenerateMap(int mapid, int horizontalNumber, int verticalNumber, float sideWidth, float sideHeight)
{
ClearMapGrid();
map = new Map(width, height, sideWidth, sideHeight);
map = new Map(horizontalNumber, verticalNumber, sideWidth, sideHeight);
map.SetMapId(mapid);
//默认设置半透明0.3
map.ChangeGridAlpha(0.25f);
@@ -128,11 +128,15 @@ 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; private set; }
public int verticalNumber { get; private set; }
public Map(float width, float height, float sideWidth,float sideHeight)
public Map(int horizontalNumber, int verticalNumber, float sideWidth,float sideHeight)
{
this.width = width;
this.height = height;
this.horizontalNumber = horizontalNumber;
this.verticalNumber = verticalNumber;
this.width = horizontalNumber * sideWidth;
this.height = verticalNumber * sideHeight;
this.sideWidth = sideWidth;
this.sideHeight = sideHeight;
mapGrid = CreateMapGrid();
@@ -216,7 +220,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(mapId,horizontalNumber * sideWidth, verticalNumber * sideHeight, sideWidth, sideHeight);
var map = MapManager.Instance.GenerateMap(mapId,horizontalNumber, verticalNumber, sideWidth, sideHeight);
GridSelector.RenderData[] data = map.selector.GetGridData();
for (int i = 0; i < horizontalNumber * verticalNumber; i++) {
data[i].barrier = br.ReadInt32();

View File

@@ -120,7 +120,10 @@ public class SceneArea : MonoBehaviour
break;
case EditCellType.TeleportCell:
if(baseItem is UITeleportItem teleportItem)
{
transform.Find("Txt").GetComponent<TextMeshPro>().text = "map:" + teleportItem.txtNextMapID.text;
}
break;
}
}

View File

@@ -108,7 +108,7 @@ public class UICellInfo : MonoBehaviour
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);
MapManager.Instance.GenerateMap(MapManager.Instance._curOpenMapId,width, height, cellW, cellH);
var newRendData = MapManager.Instance.map?.selector?.GetGridData();
for (int i = 0; i < MapManager.Instance.map?.selector.horizontalNumber; i++)
{

View File

@@ -43,6 +43,14 @@ public class UIEditMapConfig : MonoBehaviour
void Start()
{
AddInputNameClickEvent(txtReturnMapCellPoint);
txtReturnMapCellPoint.onEndEdit.AddListener((string value) =>
{
if (!UtilityClass.IsPosValidFormat(value))
{
UIWindow.Instance.ShowMessage("<22>س<EFBFBD><D8B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>");
return;
}
});
//AddInputNameClickEvent(txtReliveMapCellPoint);
}

View File

@@ -18,6 +18,18 @@ public class UITeleportItem : UIBaseItem
AddInputNameClickEvent(txtPos);
//AddInputNameClickEvent(txtNextMapPos);
btnDel.onClick.AddListener(RemoveSelf);
txtNextMapID.onEndEdit.AddListener((string value) =>
{
sceneArea?.RefSAreaInfo();
});
txtNextMapPos.onEndEdit.AddListener((string value) =>
{
if (!UtilityClass.IsPosValidFormat(value))
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>");
return;
}
});
itemIdx = 0;
}