2025-06-14 13:46:24 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
|
|
|
|
|
///<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>
|
|
|
|
|
|
public class UICellInfo : MonoBehaviour
|
|
|
|
|
|
{
|
|
|
|
|
|
public Text txtMapWidth;
|
|
|
|
|
|
public Text txtMapHeight;
|
|
|
|
|
|
public Text txtTotalCells;
|
|
|
|
|
|
public Text txtMoveCells;
|
|
|
|
|
|
public Text txtCellRows;
|
|
|
|
|
|
public Text txtCellCols;
|
|
|
|
|
|
public InputField txtCellWidth;
|
|
|
|
|
|
public InputField txtCellHeight;
|
|
|
|
|
|
|
|
|
|
|
|
public bool bMapOpened;
|
|
|
|
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
|
|
{
|
|
|
|
|
|
MapManager.Instance.onLoadFinishedCallback = OnLoadFinished;
|
|
|
|
|
|
|
|
|
|
|
|
Cleanup();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Cleanup()
|
|
|
|
|
|
{
|
|
|
|
|
|
txtMapWidth.text = string.Empty;
|
|
|
|
|
|
txtMapHeight.text = string.Empty;
|
|
|
|
|
|
txtTotalCells.text = string.Empty;
|
|
|
|
|
|
txtMoveCells.text = string.Empty;
|
|
|
|
|
|
txtCellRows.text = string.Empty;
|
|
|
|
|
|
txtCellCols.text = string.Empty;
|
|
|
|
|
|
|
|
|
|
|
|
txtCellWidth.text = string.Empty;
|
|
|
|
|
|
txtCellHeight.text = string.Empty;
|
|
|
|
|
|
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();
|
|
|
|
|
|
UIWindow.Instance.uiCellEditor.togEdit.isOn = false;
|
|
|
|
|
|
UIWindow.Instance.uiCellEditor.togPathTest.isOn = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
public void ShowCells()
|
|
|
|
|
|
{
|
2025-06-16 00:15:41 +08:00
|
|
|
|
MapManager.Instance.ShowMapGrid();
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void HideCells()
|
|
|
|
|
|
{
|
2025-06-16 00:15:41 +08:00
|
|
|
|
MapManager.Instance.HideMapGrid();
|
2025-06-14 13:46:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CalculationCells()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!bMapOpened)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtMapWidth.text)
|
|
|
|
|
|
|| string.IsNullOrEmpty(txtMapWidth.text)
|
|
|
|
|
|
|| string.IsNullOrEmpty(txtCellHeight.text)
|
|
|
|
|
|
|| string.IsNullOrEmpty(txtCellHeight.text))
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int mapWidth = Convert.ToInt32(txtMapWidth.text);
|
|
|
|
|
|
int mapHeight = Convert.ToInt32(txtMapHeight.text);
|
|
|
|
|
|
int cellWidth = Convert.ToInt32(txtCellWidth.text);
|
|
|
|
|
|
int cellHeight = Convert.ToInt32(txtCellHeight.text);
|
|
|
|
|
|
|
|
|
|
|
|
if (mapWidth <= 0 || mapHeight <= 0 || cellWidth <= 0 || cellHeight <= 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD><EFBFBD>ֵ");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CalculationCells(mapWidth, mapHeight, cellWidth, cellHeight);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void CalculationCells(int mapWidth, int mapHeight, int cellWidth, int cellHeight)
|
|
|
|
|
|
{
|
|
|
|
|
|
int row = mapHeight / cellHeight;
|
|
|
|
|
|
int col = mapWidth / cellWidth;
|
|
|
|
|
|
|
|
|
|
|
|
txtCellRows.text = row.ToString();
|
|
|
|
|
|
txtCellCols.text = col.ToString();
|
|
|
|
|
|
txtTotalCells.text = (row * col).ToString();
|
|
|
|
|
|
|
|
|
|
|
|
MapManager.Instance.CalculationCells(cellWidth, cellHeight, mapWidth, mapHeight);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|