提交
This commit is contained in:
@@ -47,7 +47,7 @@ public partial class MapManager : MonoBehaviour
|
||||
private int _cellCols;
|
||||
//public CellNode[,] cellNodes;
|
||||
|
||||
private int _curOpenMapId;
|
||||
public int _curOpenMapId;
|
||||
|
||||
private Material _cellMoveMat;
|
||||
private Material _cellObsMat;
|
||||
@@ -73,24 +73,10 @@ public partial class MapManager : MonoBehaviour
|
||||
public int MaxWidth { get { return _maxWidth; } }
|
||||
public int MaxHeight { get { return _maxHeight; } }
|
||||
|
||||
private UnityEngine.Object _cellAsset = null;
|
||||
private GameObject _curPathObj = null;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_cellAsset = Resources.Load("Prefabs/Cell");
|
||||
if (_cellAsset == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>cell.prefabʧ<62><CAA7>");
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (CellLayer layer in Enum.GetValues(typeof(CellLayer)))
|
||||
{
|
||||
List<GameObject> gos = new List<GameObject>();
|
||||
_layCellsMap.Add(layer, gos);
|
||||
}
|
||||
|
||||
_cellMoveMat = Resources.Load<Material>("Materials/cellMoveMat");
|
||||
_cellObsMat = Resources.Load<Material>("Materials/cellObsMat");
|
||||
_cellHideMat = Resources.Load<Material>("Materials/cellHideMat");
|
||||
@@ -102,7 +88,6 @@ public partial class MapManager : MonoBehaviour
|
||||
_cellTeleportMat = Resources.Load<Material>("Materials/cellTeleportMat");
|
||||
_cellNpcMat = Resources.Load<Material>("Materials/cellNpcMat");
|
||||
_cellPathNodeMat = Resources.Load<Material>("Materials/cellPathNodeMat");
|
||||
UIWindow.Instance.uiCreateMap.onCreatedMapCallback += OnCreatedMap;
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
@@ -122,7 +107,6 @@ public partial class MapManager : MonoBehaviour
|
||||
}
|
||||
|
||||
_StartEditor = true;
|
||||
_curEditCellType = EditCellType.None;
|
||||
}
|
||||
|
||||
public void CloseEditor()
|
||||
@@ -136,80 +120,15 @@ public partial class MapManager : MonoBehaviour
|
||||
_brushCellType = type;
|
||||
}
|
||||
|
||||
public void SaveCellsXml()
|
||||
{
|
||||
|
||||
if(cellsNode.Length == 0)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݻ<EFBFBD>û<EFBFBD><C3BB><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
string path = PathUtil.GetXmlPath(_curOpenMapId, "Obs");
|
||||
|
||||
if (File.Exists(path))
|
||||
File.Delete(path);
|
||||
|
||||
XmlDocument xml = new XmlDocument();
|
||||
XmlDeclaration node = xml.CreateXmlDeclaration("1.0", "utf-8", "no");
|
||||
xml.AppendChild(node);
|
||||
XmlElement Root = xml.CreateElement("Item");
|
||||
xml.AppendChild(Root);
|
||||
|
||||
Root.SetAttribute("ID", _curOpenMapId.ToString());
|
||||
Root.SetAttribute("MapWidth", mapWidth.ToString());
|
||||
Root.SetAttribute("MapHeight", mapHeight.ToString());
|
||||
Root.SetAttribute("CellWidth", _cellWidth.ToString());
|
||||
Root.SetAttribute("CellHeight", _cellHeight.ToString());
|
||||
|
||||
|
||||
CellNode cell = null;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
//tempSafeAreasConfig.Clear();
|
||||
|
||||
for (int row = 0; row < _cellRows; row++)
|
||||
{
|
||||
for (int col = 0; col < _cellCols; col++)
|
||||
{
|
||||
cell = GetCell(col, row);
|
||||
if(cell == null)
|
||||
{
|
||||
UIWindow.Instance.ShowMessage("<22><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
|
||||
return;
|
||||
}
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD>ǰ<EFBFBD>ȫ<EFBFBD><C8AB><EFBFBD><EFBFBD><EFBFBD>ӣ<EFBFBD><D3A3><EFBFBD><EFBFBD>ϰ<EFBFBD>ȫ<EFBFBD><C8AB>ö<EFBFBD><C3B6>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
//if (CheckIsSafeCell(cell))
|
||||
//{
|
||||
// cell.cellType |= CellType.Safe;
|
||||
//}
|
||||
|
||||
sb.Append(string.Format($"{row},{col},{(int)cell.cellType};"));
|
||||
}
|
||||
}
|
||||
sb.Remove(sb.Length - 1, 1);
|
||||
|
||||
string Value = sb.ToString();
|
||||
Root.SetAttribute("Value", Value);
|
||||
|
||||
xml.Save(path);
|
||||
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>xml<6D>ɹ<EFBFBD>.");
|
||||
}
|
||||
|
||||
|
||||
List<MapConfig.AreaConfig> tempSafeAreasConfig = new List<MapConfig.AreaConfig>();
|
||||
|
||||
public void CloseMap()
|
||||
{
|
||||
if (_curOpenMapId <= 0)
|
||||
return;
|
||||
|
||||
RemoveAllCells();
|
||||
UIWindow.Instance.uiCellInfo.CloseMap();
|
||||
UIWindow.Instance.uiCreateMap.CloseMap();
|
||||
UIWindow.Instance.uiMonstersPanel.RemoveAll();
|
||||
|
||||
ClearMapRegions();
|
||||
Cleanup();
|
||||
}
|
||||
|
||||
@@ -228,7 +147,6 @@ public partial class MapManager : MonoBehaviour
|
||||
_StartEditor = false;
|
||||
_brushRadius = 0;
|
||||
_brushCellType = CellType.None;
|
||||
cellsNode = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -238,175 +156,8 @@ public partial class MapManager : MonoBehaviour
|
||||
if (bHoverUI)
|
||||
return;
|
||||
UpdateCamera();
|
||||
if (_curEditCellType != EditCellType.None)
|
||||
{
|
||||
EditSpecialMapPoint(_curEditCellType);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_StartEditor)
|
||||
return;
|
||||
|
||||
if (Input.GetMouseButton(0))
|
||||
{
|
||||
EditCell();
|
||||
}
|
||||
}
|
||||
|
||||
private void EditCell()
|
||||
{
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitInfo;
|
||||
if (Physics.Raycast(ray, out hitInfo))
|
||||
{
|
||||
GameObject gameObj = hitInfo.collider.gameObject;
|
||||
if (gameObj.layer != LayerMask.NameToLayer("MapCell"))
|
||||
return;
|
||||
|
||||
if (_brushRadius == 0)
|
||||
{
|
||||
CellType ct = SetCellType(gameObj.name, _brushCellType);
|
||||
ShowCellType(gameObj, ct);
|
||||
return;
|
||||
}
|
||||
|
||||
Collider[] hits = Physics.OverlapSphere(gameObj.transform.position, _brushRadius);// LayerMask.NameToLayer("MapCell")
|
||||
if (hits.Length > 0)
|
||||
{
|
||||
for (int i = 0; i < hits.Length; i++)
|
||||
{
|
||||
CellType ct = SetCellType(hits[i].name, _brushCellType);
|
||||
ShowCellType(hits[i].gameObject, ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EditSpecialMapPoint(EditCellType type)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(0))
|
||||
{
|
||||
if(type == EditCellType.NpcPath)
|
||||
{
|
||||
if (_curPathObj == null)
|
||||
return;
|
||||
|
||||
UIWindow.Instance.uiNpcsPanel.curActiveList.Add(_curPathObj.name);
|
||||
UIWindow.Instance.uiNpcsPanel.curActiveInput.text += $"[{_curPathObj.name.Replace('_', ',')}]";
|
||||
AddNpcPathSize();
|
||||
_curPathObj = null;
|
||||
}
|
||||
else if (type == EditCellType.MonsterPath)
|
||||
{
|
||||
if (_curPathObj == null)
|
||||
return;
|
||||
|
||||
//UIWindow.Instance.uiMonstersPanel_old.curActiveList.Add(_curPathObj.name);
|
||||
//UIWindow.Instance.uiMonstersPanel_old.curActiveInput.text += $"[{_curPathObj.name.Replace('_', ',')}]";
|
||||
AddMonsterPathSize();
|
||||
_curPathObj = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_curEditCellType = EditCellType.None;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(type == EditCellType.NpcPath)
|
||||
{
|
||||
if(Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
string last = $"NpcPath{_curNpcPointIdx}{GetCurNpcPathIdx()}";
|
||||
GameObject lastObj = GameObject.Find(last);
|
||||
DestroyImmediate(lastObj);
|
||||
_curEditCellType = EditCellType.None;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (type == EditCellType.MonsterPath)
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
string last = $"MonsterPath{_curMonsterPoint.areaIdx}{GetCurMonsterPathIdx()}";
|
||||
GameObject lastObj = GameObject.Find(last);
|
||||
DestroyImmediate(lastObj);
|
||||
_curEditCellType = EditCellType.None;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hitInfo;
|
||||
|
||||
if (Physics.Raycast(ray, out hitInfo))
|
||||
{
|
||||
GameObject gameObj = hitInfo.collider.gameObject;
|
||||
if (gameObj.layer != LayerMask.NameToLayer("MapCell"))
|
||||
return;
|
||||
|
||||
string[] point = gameObj.name.Split('_');
|
||||
if (point.Length != 2)
|
||||
{
|
||||
if (Input.GetMouseButtonUp(1))
|
||||
{
|
||||
int xx = (int)((gameObj.transform.localPosition.x - _cellWidth / 100.0f / 2) / (_cellWidth / 100.0f));
|
||||
int yy = (int)((gameObj.transform.localPosition.y - _cellHeight / 100.0f / 2) / (_cellHeight / 100.0f));
|
||||
|
||||
UIWindow.Instance.uiNpcsPanel.curActiveList.Remove($"{xx}_{yy}");
|
||||
DestroyImmediate(gameObj);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int x, y;
|
||||
x = Convert.ToInt32(point[0]); //<2F><>
|
||||
y = Convert.ToInt32(point[1]); //<2F><>
|
||||
CreateSpecialPoint(x, y, type);
|
||||
|
||||
_curPathObj = gameObj;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case EditCellType.ReturnCell:
|
||||
UIWindow.Instance.uiEditMapConfig.txtReturnMapCellPoint.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.TeleportCell:
|
||||
UIWindow.Instance.uiTeleportPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.NpcCell:
|
||||
UIWindow.Instance.uiNpcsPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.PathNodeCell:
|
||||
UIWindow.Instance.uiCellEditor.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.TriggerCell:
|
||||
UIWindow.Instance.uiTriggersPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.AudioTrigger:
|
||||
UIWindow.Instance.uiAudioTriggerPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.ReliveCell:
|
||||
UIWindow.Instance.uiRelivesPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.SellArea:
|
||||
UIWindow.Instance.uiSellAreasPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.MonsterArea:
|
||||
UIWindow.Instance.uiMonstersPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.FuBenArea:
|
||||
UIWindow.Instance.uiFuBensPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
case EditCellType.JuBaoArea:
|
||||
UIWindow.Instance.uiJuBaosPanel.curActiveInput.text = gameObj.name.Replace('_', ',');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadSprite(string spName, GameObject go, int regionWidth=0, int regionHeight=0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user