diff --git a/Assets/Scripts/Map/GridSelector.cs b/Assets/Scripts/Map/GridSelector.cs index 2325f57..8690630 100644 --- a/Assets/Scripts/Map/GridSelector.cs +++ b/Assets/Scripts/Map/GridSelector.cs @@ -26,6 +26,8 @@ public class GridSelector : MonoBehaviour public int verticalNumber { get { return Mathf.CeilToInt(map.height / map.sideHeight); } } public int totalNumber { get { return horizontalNumber * verticalNumber; } } + public int moveNum; + private ComputeBuffer inputbuffer; private RenderData[] dataArray; @@ -39,7 +41,7 @@ public class GridSelector : MonoBehaviour public void OnMapCreated(Map map) { this.map = map; - + moveNum = 0; mapRenderer.material.SetVector("_Size", new Vector4(horizontalNumber, verticalNumber)); mapRenderer.material.SetFloat("_UserInput", 1); inputbuffer = new ComputeBuffer(totalNumber, Marshal.SizeOf(typeof(RenderData))); @@ -414,14 +416,14 @@ public class GridSelector : MonoBehaviour } public void RefreshPlaneRender() { - int runNum = 0; + moveNum = 0; for (int i = 0; i < dataArray.Length; i++) { //int barrier = dataArray[i].barrier; setDataColor(i); CellType cell = (CellType)dataArray[i].barrier; if (cell.HasFlag(CellType.Move)) { - runNum++; + moveNum++; } } inputbuffer.SetData(dataArray); diff --git a/Assets/Scripts/Map/MapManager.Region.cs b/Assets/Scripts/Map/MapManager.Region.cs index c58202b..bea1f1a 100644 --- a/Assets/Scripts/Map/MapManager.Region.cs +++ b/Assets/Scripts/Map/MapManager.Region.cs @@ -28,7 +28,7 @@ public partial class MapManager : MonoBehaviour /// /// 当前地图区域 /// - private MapRegions _curMapRegions; + public MapRegions _curMapRegions; public bool LoadObsXml() { if (_curOpenMapId < 0) @@ -174,6 +174,7 @@ public partial class MapManager : MonoBehaviour } MapManager.Instance.ReseCamera(jpgscenew * mapColumn, jpgscenew * mapRownum); MapManager.Instance.GenerateMap(jpgscenew * mapColumn, jpgscenew * mapRownum, widthPixel / 100.0f, heightPixel / 100.0f); + UICellInfo.Instance.ShowMapCellInfo(); } public void ClearMapRegions() diff --git a/Assets/Scripts/UI/UICellInfo.cs b/Assets/Scripts/UI/UICellInfo.cs index e7434c9..1572a55 100644 --- a/Assets/Scripts/UI/UICellInfo.cs +++ b/Assets/Scripts/UI/UICellInfo.cs @@ -8,6 +8,7 @@ using UnityEngine.UI; ///功能:加载格子数据,重新计算格子,显示格子,隐藏格子 public class UICellInfo : MonoBehaviour { + public static UICellInfo Instance; public Text txtMapWidth; public Text txtMapHeight; public Text txtTotalCells; @@ -19,10 +20,12 @@ public class UICellInfo : MonoBehaviour public bool bMapOpened; + private void Awake() + { + Instance = this; + } private void Start() { - MapManager.Instance.onLoadFinishedCallback = OnLoadFinished; - Cleanup(); } @@ -40,20 +43,6 @@ public class UICellInfo : MonoBehaviour bMapOpened = false; } - void OnCreatedMap(int mapId, int mapWidth, int mapHeight) - { - bMapOpened = true; - txtMapWidth.text = mapWidth.ToString(); - txtMapHeight.text = mapHeight.ToString(); - } - - void OnLoadFinished() - { - txtMapWidth.text = MapManager.Instance.mapWidth.ToString(); - txtMapHeight.text = MapManager.Instance.mapHeight.ToString(); - bMapOpened = true; - } - public void CloseMap() { Cleanup(); @@ -69,6 +58,20 @@ public class UICellInfo : MonoBehaviour { MapManager.Instance.HideMapGrid(); } + public void ShowMapCellInfo() + { + if (MapManager.Instance.map == null || MapManager.Instance.map.selector == null) + return; + if(MapManager.Instance._curMapRegions == null) return; + txtMapWidth.text = MapManager.Instance._curMapRegions.regionColNum.ToString(); + txtMapHeight.text = MapManager.Instance._curMapRegions.regionRowNum.ToString(); + txtCellRows.text = MapManager.Instance.map.selector.horizontalNumber.ToString(); + txtCellCols.text = MapManager.Instance.map.selector.verticalNumber.ToString(); + txtTotalCells.text = MapManager.Instance.map.selector.totalNumber.ToString(); + txtCellWidth.text = MapManager.widthPixel.ToString(); + txtCellHeight.text = MapManager.heightPixel.ToString(); + txtMoveCells.text = MapManager.Instance.map.selector.moveNum.ToString(); + } public void CalculationCells() { diff --git a/Assets/Scripts/UI/UIMonsterPanel.cs b/Assets/Scripts/UI/UIMonsterPanel.cs index ec12d90..a3873b4 100644 --- a/Assets/Scripts/UI/UIMonsterPanel.cs +++ b/Assets/Scripts/UI/UIMonsterPanel.cs @@ -392,7 +392,7 @@ public class UIMonsterPanel : MonoBehaviour DestroyImmediate(itemParent.GetChild(0).gameObject); } - _dicGroupItem.Clear(); + _dicGroupItem?.Clear(); itemIdx = 0; } }