bao
This commit is contained in:
@@ -312,64 +312,14 @@ public class UICreateMap : MonoBehaviour
|
||||
btnAutoCleanupRegion.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
public void SaveRegions()
|
||||
{
|
||||
if (!CheckValid())
|
||||
return;
|
||||
|
||||
Transform regionsTrans = UIWindow.Instance.mapTrans.Find("Regions");
|
||||
if (regionsTrans == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("û<><C3BB><EFBFBD>ҵ<EFBFBD>Regions<6E>ڵ<EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
MapRegions mapRegions = new MapRegions();
|
||||
mapRegions.mapWidth = Convert.ToInt32(txtMapWidth.text);
|
||||
mapRegions.mapHeight = Convert.ToInt32(txtMapHeight.text);
|
||||
mapRegions.regionWidth = Convert.ToInt32(txtRegionWidth.text);
|
||||
mapRegions.regionHeight = Convert.ToInt32(txtRegionHeight.text);
|
||||
|
||||
int row = mapRegions.mapWidth / MapManager.CELLSCALE / mapRegions.regionWidth;
|
||||
int col = mapRegions.mapHeight / MapManager.CELLSCALE / mapRegions.regionHeight;
|
||||
|
||||
Transform trans = null;
|
||||
mapRegions.regions = new Region[row, col];
|
||||
for (int i = 0; i < row; i++)
|
||||
{
|
||||
for (int j = 0; j < col; j++)
|
||||
{
|
||||
mapRegions.regions[i, j] = new Region();
|
||||
mapRegions.regions[i, j].indexX = i;
|
||||
mapRegions.regions[i, j].indexY = j;
|
||||
|
||||
string regionName = $"{i}_{j}";
|
||||
trans = regionsTrans.Find(regionName);
|
||||
if(trans == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage($"û<><C3BB><EFBFBD>ҵ<EFBFBD>region<6F>ڵ<EFBFBD> name={regionName}");
|
||||
return;
|
||||
}
|
||||
|
||||
//mapRegions.regions[i, j].regionName = trans.GetComponent<Image>().sprite.name;
|
||||
mapRegions.regions[i, j].regionName = trans.GetComponent<RawImage>().texture.name;
|
||||
}
|
||||
}
|
||||
|
||||
mapRegions.SaveXML(Convert.ToInt32(txtMapID.text));
|
||||
}
|
||||
|
||||
public void LoadMapRegions(int mapId)
|
||||
{
|
||||
//MapRegions mapRegions = new MapRegions();
|
||||
//if (!mapRegions.LoadXML(mapId))
|
||||
// return;
|
||||
if (!_curMapRegions.LoadXML(mapId))
|
||||
return;
|
||||
|
||||
txtMapID.text = mapId.ToString();
|
||||
txtMapWidth.text = _curMapRegions.mapWidth.ToString();
|
||||
txtMapHeight.text = _curMapRegions.mapHeight.ToString();
|
||||
txtMapWidth.text = _curMapRegions.regionRowNum.ToString();
|
||||
txtMapHeight.text = _curMapRegions.regionColNum.ToString();
|
||||
txtRegionWidth.text = _curMapRegions.regionWidth.ToString();
|
||||
txtRegionHeight.text = _curMapRegions.regionHeight.ToString();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user