This commit is contained in:
2025-06-16 00:15:41 +08:00
parent bcfa5ce1ec
commit 6d79a5baa1
16 changed files with 246 additions and 3838 deletions

View File

@@ -209,7 +209,6 @@ public class UICellEditor : MonoBehaviour
//<2F><EFBFBD><E0BCAD>Ч
public void OnShowEffectsToggleChange()
{
UIWindow.Instance.uiCreateMap.MapBG.GetComponent<CanvasGroup>().blocksRaycasts = true;
MapManager.Instance.HideCells();
UIWindow.Instance.ShowMouseOver();
}

View File

@@ -22,7 +22,6 @@ public class UICellInfo : MonoBehaviour
private void Start()
{
MapManager.Instance.onLoadFinishedCallback = OnLoadFinished;
UIWindow.Instance.uiCreateMap.onCreatedMapCallback += OnCreatedMap;
Cleanup();
}
@@ -82,41 +81,12 @@ public class UICellInfo : MonoBehaviour
public void ShowCells()
{
if (!bMapOpened)
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD>ȴ򿪵<C8B4>ͼ");
return;
}
if (MapManager.Instance.CellRows <= 0)
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return;
}
UIWindow.Instance.uiCreateMap.MapBG.GetComponent<CanvasGroup>().blocksRaycasts = false;
MapManager.Instance.CreateCells();
txtMoveCells.text = MapManager.Instance.GetLayCellCount(CellLayer.Move).ToString();
MapManager.Instance.ShowMapGrid();
}
public void HideCells()
{
if (!bMapOpened)
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD>ȴ򿪵<C8B4>ͼ");
return;
}
if (MapManager.Instance.CellRows <= 0)
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD>ȼ<EFBFBD><C8BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>");
return;
}
UIWindow.Instance.uiCreateMap.MapBG.GetComponent<CanvasGroup>().blocksRaycasts = true;
MapManager.Instance.HideCells();
MapManager.Instance.HideMapGrid();
}
public void CalculationCells()

View File

@@ -105,31 +105,7 @@ public class UIEditMapConfig : MonoBehaviour
}
private void OnInputFieldClicked(BaseEventData data)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼID<49><44><EFBFBD>õ<EFBFBD>ͼһ<CDBC>£<EFBFBD><C2A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//TODO: <20><><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
if (data.selectedObject.name.Equals("InputReturnPoint"))
{
if (!txtReturnMapId.text.Equals(UIWindow.Instance.uiCreateMap.txtMapID.text))
{
MapManager.Instance.RemoveSpecialPoint(MapManager.EditCellType.ReturnCell);
return;
}
MapManager.Instance.SetEditCellType(MapManager.EditCellType.ReturnCell);
}
//else if (data.selectedObject.name.Equals("InputRelivePoint"))
//{
// if (!txtReliveMapId.text.Equals(UIWindow.Instance.uiCreateMap.txtMapID.text))
// {
// MapManager.Instance.RemoveSpecialPoint(MapManager.EditCellType.ReliveCell);
// return;
// }
// MapManager.Instance.SetEditCellType(MapManager.EditCellType.ReliveCell);
//}
{
}
@@ -257,12 +233,6 @@ public class UIEditMapConfig : MonoBehaviour
bool CheckValid()
{
if (string.IsNullOrEmpty(UIWindow.Instance.uiCreateMap.txtMapID.text))
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ͼID");
return false;
}
if (string.IsNullOrEmpty(txtMapName.text))
{
UIWindow.Instance.ShowMessage("<22><><EFBFBD><EFBFBD>д<EFBFBD><D0B4>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>");
@@ -467,9 +437,7 @@ public class UIEditMapConfig : MonoBehaviour
config.time = Convert.ToInt32(item.txtTime.text);
mc.conditionsConfig.Add(config);
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
mc.SaveXML(mapId);
mc.SaveXML(MapManager.Instance._curOpenMapId);
}
public void LoadMapConfig(int mapId)
@@ -483,9 +451,6 @@ public class UIEditMapConfig : MonoBehaviour
txtReturnMapId.text = mc.returnMapId.ToString();
txtReturnMapCellPoint.text = $"{mc.returnMapCellPoint.x},{mc.returnMapCellPoint.y}";
if (txtReturnMapId.text.Equals(UIWindow.Instance.uiCreateMap.txtMapID.text))
MapManager.Instance.CreateSpecialPoint(mc.returnMapCellPoint.x, mc.returnMapCellPoint.y, MapManager.EditCellType.ReturnCell);
if ((mc.roleMode & RoleMode.PK) != 0)
togModePK.isOn = true;
if ((mc.roleMode & RoleMode.ShiZu) != 0)

View File

@@ -94,7 +94,7 @@ public class UIFuBensPanel : MonoBehaviour
mc.fubenConfigs.Add(monster);
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
int mapId = MapManager.Instance._curOpenMapId;
mc.SaveXML(mapId);
}

View File

@@ -97,7 +97,7 @@ public class UIJuBaoPanel : MonoBehaviour
mc.jubaoConfigs.Add(jubao);
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
int mapId = MapManager.Instance._curOpenMapId;
mc.SaveXML(mapId);
}

View File

@@ -2,6 +2,7 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using UnityEngine;
using UnityEngine.UI;
@@ -9,11 +10,9 @@ using UnityEngine.UI;
///<2F><><EFBFBD>ܣ<EFBFBD>ɨ<EFBFBD><C9A8><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>򿪵<EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>رյ<D8B1>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public class UIMapPanel : MonoBehaviour
{
public List<string> allMaps = new List<string>();
public Dropdown dropMap;
private int _curOpenMapId;
private bool _saving;
public int CurOpenMapId => _curOpenMapId;
// Start is called before the first frame update
@@ -21,50 +20,85 @@ public class UIMapPanel : MonoBehaviour
{
_saving = false;
_curOpenMapId = -1;
UIWindow.Instance.uiCreateMap.onCreatedMapCallback += OnCreatedMap;
}
void OnDataLoaded()
{
string[] AllFilePath = Directory.GetDirectories(Application.dataPath + "/GameAssets/Maps");
for (int i = 0; i < AllFilePath.Length; i++)
// <20><>ȡ<EFBFBD><C8A1><EFBFBD>е<EFBFBD>ͼ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>
string mapsDirectory = Path.Combine(Application.dataPath, "GameAssets", "Maps");
if (!Directory.Exists(mapsDirectory))
{
string[] pathSplit = AllFilePath[i].Split('/');
string[] pathSplit2 = pathSplit[pathSplit.Length - 1].Split('\\');
allMaps.Add(pathSplit2[pathSplit2.Length - 1]);
Debug.LogError($"Maps directory not found: {mapsDirectory}");
return;
}
string[] mapFolders = Directory.GetDirectories(mapsDirectory);
foreach (string folderPath in mapFolders)
{
string[] pathSplit = folderPath.Split(Path.DirectorySeparatorChar);
string mapId = pathSplit[pathSplit.Length - 1]; // <20><><EFBFBD><EFBFBD> "v1000"
string textureDirectory = Path.Combine(folderPath, "Texture");
if (Directory.Exists(textureDirectory))
{
string[] imageFiles = Directory.GetFiles(textureDirectory, "*.jpg");
int maxRow = 0;
int maxCol = 0;
string pattern = $@"{mapId}_r(\d+)_c(\d+)"; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ƥ<EFBFBD><C6A5> v1000_rXX_cYY
Regex regex = new Regex(pattern);
foreach (string filePath in imageFiles)
{
string fileName = Path.GetFileNameWithoutExtension(filePath); // <20><><EFBFBD><EFBFBD> "v1000_r11_c14"
Match match = regex.Match(fileName);
if (match.Success)
{
if (int.TryParse(match.Groups[1].Value, out int row) && int.TryParse(match.Groups[2].Value, out int col))
{
maxRow = Mathf.Max(maxRow, row);
maxCol = Mathf.Max(maxCol, col);
}
}
else
{
Debug.LogWarning($"Filename {fileName} does not match expected pattern: {pattern}");
}
}
if (maxRow > 0 && maxCol > 0)
{
MapManager.Instance.allMaps[mapId] = (maxRow, maxCol);
Debug.Log($"Map {mapId} loaded with max dimensions: {maxRow}x{maxCol}");
}
else
{
Debug.LogWarning($"No valid dimensions found for map {mapId}");
}
}
else
{
Debug.LogWarning($"Texture directory not found for map {mapId}: {textureDirectory}");
}
}
}
public void ScanMap()
{
allMaps.Clear();
{
MapManager.Instance.allMaps.Clear();
OnDataLoaded();
dropMap.options.Clear();
for (int i=0; i<allMaps.Count; i++)
{
foreach (var map in MapManager.Instance.allMaps)
{
Dropdown.OptionData od = new Dropdown.OptionData();
od.text = allMaps[i];
od.text = map.Key;
dropMap.options.Add(od);
}
dropMap.value = 1;
dropMap.value = 0; //Ϊ<><CEAA>Ĭ<EFBFBD><C4AC>ѡ<EFBFBD>е<EFBFBD>һ<EFBFBD><D2BB>
}
private void OnCreatedMap(int mapId, int mapWidth, int mapHeight)
{
ScanMap();
allMaps.Add(mapId.ToString());
Dropdown.OptionData od = new Dropdown.OptionData();
od.text = mapId.ToString();
dropMap.options.Add(od);
dropMap.value = dropMap.options.Count - 1;
}
public void OpenMap()
{
if(dropMap.options.Count == 0)
@@ -82,18 +116,18 @@ public class UIMapPanel : MonoBehaviour
int mapId = 0;
mapId = Convert.ToInt32(dropMap.options[dropMap.value].text);
UIWindow.Instance.uiCreateMap.LoadMapRegions(mapId);
UIWindow.Instance.uiCellInfo.LoadCells();
UIWindow.Instance.uiCellInfo.ShowCells();
UIWindow.Instance.uiEditMapConfig.LoadMapConfig(mapId);
UIWindow.Instance.uiMonstersPanel.LoadMonsterConfig(mapId);
UIWindow.Instance.uiNpcsPanel.LoadNpcsConfig(mapId);
UIWindow.Instance.uiTriggersPanel.LoadTriggersConfig(mapId);
UIWindow.Instance.uiFuBensPanel.LoadFuBenConfig(mapId);
UIWindow.Instance.uiJuBaosPanel.LoadJuBaoConfig(mapId);
//UIWindow.Instance.uiCreateMap.LoadMapRegions(mapId);
//UIWindow.Instance.uiCellInfo.LoadCells();
//UIWindow.Instance.uiCellInfo.ShowCells();
//UIWindow.Instance.uiEditMapConfig.LoadMapConfig(mapId);
//UIWindow.Instance.uiMonstersPanel.LoadMonsterConfig(mapId);
//UIWindow.Instance.uiNpcsPanel.LoadNpcsConfig(mapId);
//UIWindow.Instance.uiTriggersPanel.LoadTriggersConfig(mapId);
//UIWindow.Instance.uiFuBensPanel.LoadFuBenConfig(mapId);
//UIWindow.Instance.uiJuBaosPanel.LoadJuBaoConfig(mapId);
_curOpenMapId = mapId;
//MapManager.Instance.LoadMapSprite();
MapManager.Instance.LoadMapRegions(_curOpenMapId);
}
public void CloseMap()
@@ -105,7 +139,7 @@ public class UIMapPanel : MonoBehaviour
public bool HasMap(string mapId)
{
return allMaps.Find(s => s == mapId) != null;
return MapManager.Instance.allMaps.ContainsKey(mapId);
}
public void ResetMap()
@@ -145,7 +179,7 @@ public class UIMapPanel : MonoBehaviour
{
_saving = true;
Debug.Log("<22><><EFBFBD>ڱ<EFBFBD><DAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>...");
UIWindow.Instance.uiCreateMap.SaveRegions();
//UIWindow.Instance.uiCreateMap.SaveRegions();
UIWindow.Instance.uiCellEditor.SaveCells();
UIWindow.Instance.uiEditMapConfig.SaveMapConfig();
UIWindow.Instance.uiMonstersPanel.SaveMonsterConfig();

View File

@@ -372,7 +372,7 @@ public class UIMonsterPanel : MonoBehaviour
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
int mapId = MapManager.Instance._curOpenMapId;
mc.SaveXML(mapId);
}

View File

@@ -113,7 +113,7 @@ public class UIMonstersPanel_old : MonoBehaviour
mc.monsterConfigs.Add(monster);
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
int mapId = MapManager.Instance._curOpenMapId;
mc.SaveXML(mapId);
}

View File

@@ -101,7 +101,7 @@ public class UINpcsPanel : MonoBehaviour
nc.npcConfigs.Add(npc);
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
int mapId = MapManager.Instance._curOpenMapId;
nc.SaveXML(mapId);
}

View File

@@ -82,9 +82,9 @@ public class UITriggerPanel : MonoBehaviour
t.eventId = Convert.ToInt32(item.txtEvent.text);
ts.triggersConfig.Add(t);
}
int mapId = Convert.ToInt32(UIWindow.Instance.uiCreateMap.txtMapID.text);
}
int mapId = MapManager.Instance._curOpenMapId;
ts.SaveXML(mapId);
}

View File

@@ -31,7 +31,6 @@ public class UIWindow : MonoBehaviour
public UIMapPanel uiMapPanel;
public UICellInfo uiCellInfo;
public UICellEditor uiCellEditor;
public UICreateMap uiCreateMap;
public UIEditMapConfig uiEditMapConfig;
public UITeleportPanel uiTeleportPanel;
public UIRelivesPanel uiRelivesPanel;
@@ -55,7 +54,6 @@ public class UIWindow : MonoBehaviour
private void Start()
{
uiCreateMap.onCreatedMapCallback += OnCreatedMap;
uiMonstersPanel.gameObject.SetActive(false);
}