|
@@ -27,18 +27,18 @@ public class GameMapEditor : EditorWindow
|
|
|
private static Vector2[] scroll = { Vector2.zero, Vector2.zero };
|
|
private static Vector2[] scroll = { Vector2.zero, Vector2.zero };
|
|
|
|
|
|
|
|
private bool dragSplitter = false;
|
|
private bool dragSplitter = false;
|
|
|
- private bool doRepaint = false;
|
|
|
|
|
|
|
+ public static bool doRepaint = false;
|
|
|
|
|
|
|
|
- private GameMapsAsset asset = null;
|
|
|
|
|
|
|
+ public static GameMapsAsset asset = null;
|
|
|
private GameMapsAsset _setAsset = null;
|
|
private GameMapsAsset _setAsset = null;
|
|
|
- private int mapSize_w = 0;
|
|
|
|
|
- private int mapSize_h = 0;
|
|
|
|
|
- private int mapIdx = -1;
|
|
|
|
|
|
|
+ public static int mapSize_w = 0;
|
|
|
|
|
+ public static int mapSize_h = 0;
|
|
|
|
|
+ public static int mapIdx = -1;
|
|
|
private int tileIdx = -1;
|
|
private int tileIdx = -1;
|
|
|
private bool autoTileSelected = false;
|
|
private bool autoTileSelected = false;
|
|
|
private float tileDrawSz = 32f;
|
|
private float tileDrawSz = 32f;
|
|
|
private int dragDropTarget = -1;
|
|
private int dragDropTarget = -1;
|
|
|
- private int currLayer = -1;
|
|
|
|
|
|
|
+ public static int currLayer = -1;
|
|
|
private bool[] layerHidden = new bool[0];
|
|
private bool[] layerHidden = new bool[0];
|
|
|
|
|
|
|
|
[NonSerialized] private float tileListH = 1f;
|
|
[NonSerialized] private float tileListH = 1f;
|
|
@@ -114,7 +114,7 @@ public class GameMapEditor : EditorWindow
|
|
|
private StyleDefs _styles = null;
|
|
private StyleDefs _styles = null;
|
|
|
private StyleDefs Styles { get { return _styles ?? (_styles = new StyleDefs()); } }
|
|
private StyleDefs Styles { get { return _styles ?? (_styles = new StyleDefs()); } }
|
|
|
|
|
|
|
|
- private static readonly GUIContent GC_ExcelReload = new GUIContent("-reload-");
|
|
|
|
|
|
|
+ private static readonly GUIContent GC_ExcelSave = new GUIContent("-save-");
|
|
|
private static readonly GUIContent GC_MapSelect = new GUIContent("-select-");
|
|
private static readonly GUIContent GC_MapSelect = new GUIContent("-select-");
|
|
|
private static readonly GUIContent GC_EditorHead = new GUIContent("Editor");
|
|
private static readonly GUIContent GC_EditorHead = new GUIContent("Editor");
|
|
|
private static readonly GUIContent GC_AssetHead = new GUIContent("Asset");
|
|
private static readonly GUIContent GC_AssetHead = new GUIContent("Asset");
|
|
@@ -136,7 +136,7 @@ public class GameMapEditor : EditorWindow
|
|
|
private static readonly GUIContent GC_EditAuto = new GUIContent("Setup Auto-tile");
|
|
private static readonly GUIContent GC_EditAuto = new GUIContent("Setup Auto-tile");
|
|
|
private static readonly GUIContent GC_Viz = new GUIContent("*", "Toggle layer visblity in editor");
|
|
private static readonly GUIContent GC_Viz = new GUIContent("*", "Toggle layer visblity in editor");
|
|
|
|
|
|
|
|
- private static string enemyExcelPath = "Luban/Config/Datas/出怪表.xlsx";
|
|
|
|
|
|
|
+ public static string enemyExcelPath = "Luban/Config/Datas/出怪表.xlsx";
|
|
|
|
|
|
|
|
private GenericMenu addTileMenu = null;
|
|
private GenericMenu addTileMenu = null;
|
|
|
|
|
|
|
@@ -622,14 +622,20 @@ public class GameMapEditor : EditorWindow
|
|
|
// map selection button
|
|
// map selection button
|
|
|
r.height = EditorGUIUtility.singleLineHeight;
|
|
r.height = EditorGUIUtility.singleLineHeight;
|
|
|
r.x = r.xMax - 200f; r.width = 100f; r.height = 15f;
|
|
r.x = r.xMax - 200f; r.width = 100f; r.height = 15f;
|
|
|
- if (GUI.Button(r, GC_ExcelReload))
|
|
|
|
|
|
|
+ if (GUI.Button(r, GC_ExcelSave))
|
|
|
{
|
|
{
|
|
|
- ReloadExcel(enemyExcelPath);
|
|
|
|
|
|
|
+ ReloadSheetName(enemyExcelPath);
|
|
|
|
|
+ mapsPopup.Asset = asset;
|
|
|
|
|
+ mapsPopup.isSelect = false;
|
|
|
|
|
+ mapsPopup.OnMapSelected = OnMapSelected;
|
|
|
|
|
+ PopupWindow.Show(r, mapsPopup);
|
|
|
}
|
|
}
|
|
|
r.x = r.xMax; r.width = 100f; r.height = 15f;
|
|
r.x = r.xMax; r.width = 100f; r.height = 15f;
|
|
|
if (GUI.Button(r, GC_MapSelect))
|
|
if (GUI.Button(r, GC_MapSelect))
|
|
|
{
|
|
{
|
|
|
|
|
+ ReloadSheetName(enemyExcelPath);
|
|
|
mapsPopup.Asset = asset;
|
|
mapsPopup.Asset = asset;
|
|
|
|
|
+ mapsPopup.isSelect = true;
|
|
|
mapsPopup.OnMapSelected = OnMapSelected;
|
|
mapsPopup.OnMapSelected = OnMapSelected;
|
|
|
PopupWindow.Show(r, mapsPopup);
|
|
PopupWindow.Show(r, mapsPopup);
|
|
|
}
|
|
}
|
|
@@ -648,8 +654,8 @@ public class GameMapEditor : EditorWindow
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
{
|
|
{
|
|
|
EditorGUILayout.PrefixLabel("Ident");
|
|
EditorGUILayout.PrefixLabel("Ident");
|
|
|
- GUILayout.Label(mapIdx.ToString() + " => " + asset.maps[mapIdx].ident);
|
|
|
|
|
- if (GUILayout.Button(GC_rename, EditorStyles.miniButtonRight)) GameMapTextEd.ShowEd("Rename map", "Enter a unique name", asset.maps[mapIdx].ident, OnRenameMap);
|
|
|
|
|
|
|
+ GUILayout.Label(mapIdx.ToString() + " => " + asset.maps[mapIdx].showIdent);
|
|
|
|
|
+ if (GUILayout.Button(GC_rename, EditorStyles.miniButtonRight)) GameMapTextEd.ShowEd("Rename map", "Enter a unique name", asset.maps[mapIdx].showIdent, OnRenameMap);
|
|
|
GUILayout.FlexibleSpace();
|
|
GUILayout.FlexibleSpace();
|
|
|
}
|
|
}
|
|
|
EditorGUILayout.EndHorizontal();
|
|
EditorGUILayout.EndHorizontal();
|
|
@@ -665,8 +671,6 @@ public class GameMapEditor : EditorWindow
|
|
|
asset.maps[mapIdx].Resize(mapSize_w, mapSize_h);
|
|
asset.maps[mapIdx].Resize(mapSize_w, mapSize_h);
|
|
|
mapSize_w = asset.maps[mapIdx].width;
|
|
mapSize_w = asset.maps[mapIdx].width;
|
|
|
mapSize_h = asset.maps[mapIdx].height;
|
|
mapSize_h = asset.maps[mapIdx].height;
|
|
|
- ExcelEditor.ModifyExcel(enemyExcelPath, asset.maps[mapIdx].ident, "C6", mapSize_w);
|
|
|
|
|
- ExcelEditor.ModifyExcel(enemyExcelPath, asset.maps[mapIdx].ident, "D6", mapSize_h);
|
|
|
|
|
}
|
|
}
|
|
|
GUILayout.FlexibleSpace();
|
|
GUILayout.FlexibleSpace();
|
|
|
}
|
|
}
|
|
@@ -696,67 +700,34 @@ public class GameMapEditor : EditorWindow
|
|
|
EditorGUILayout.EndVertical();
|
|
EditorGUILayout.EndVertical();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private JSONNode Loader(string fileName)
|
|
|
|
|
- {
|
|
|
|
|
- return JSON.Parse(File.ReadAllText("GenerateDatas/json/" + fileName + ".json"));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- private void ReloadExcel(string path)
|
|
|
|
|
|
|
+ void ReloadSheetName(string path)
|
|
|
{
|
|
{
|
|
|
List<string> excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(path);
|
|
List<string> excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(path);
|
|
|
- Tables allCfgData = new Tables(Loader);
|
|
|
|
|
|
|
+ Tables allCfgData = new Tables(ExcelEditor.Loader);
|
|
|
List<SingleCreateEnemyConfig> cfgCreateEnemy = allCfgData.CfgCreateEnemy.DataList;
|
|
List<SingleCreateEnemyConfig> cfgCreateEnemy = allCfgData.CfgCreateEnemy.DataList;
|
|
|
-
|
|
|
|
|
//导入关卡数据
|
|
//导入关卡数据
|
|
|
- if (mapIdx >= excelWorksheets.Count)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (mapIdx >= excelWorksheets.Count)
|
|
|
|
|
+ {
|
|
|
mapIdx = 0;
|
|
mapIdx = 0;
|
|
|
}
|
|
}
|
|
|
if (asset.maps.Count > excelWorksheets.Count)
|
|
if (asset.maps.Count > excelWorksheets.Count)
|
|
|
- {
|
|
|
|
|
- for(int i = asset.maps.Count - 1; i>= excelWorksheets.Count; i--)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int i = asset.maps.Count - 1; i >= excelWorksheets.Count; i--)
|
|
|
|
|
+ {
|
|
|
asset.RemoveMapAtIndex(i);
|
|
asset.RemoveMapAtIndex(i);
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
for (int i = 0; i < excelWorksheets.Count; i++)
|
|
for (int i = 0; i < excelWorksheets.Count; i++)
|
|
|
{
|
|
{
|
|
|
- if (i >= asset.maps.Count)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if (i >= asset.maps.Count)
|
|
|
|
|
+ {
|
|
|
asset.AddMap();
|
|
asset.AddMap();
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
asset.maps[i].ident = excelWorksheets[i];
|
|
asset.maps[i].ident = excelWorksheets[i];
|
|
|
- int.TryParse(ExcelEditor.GetCellData(path, excelWorksheets[i], "C6"), out int width);
|
|
|
|
|
- int.TryParse(ExcelEditor.GetCellData(path, excelWorksheets[i], "D6"), out int height);
|
|
|
|
|
- asset.maps[i].Resize(width, height);
|
|
|
|
|
- }
|
|
|
|
|
- mapSize_w = asset.maps[mapIdx].width;
|
|
|
|
|
- mapSize_h = asset.maps[mapIdx].height;
|
|
|
|
|
-
|
|
|
|
|
- //导入波次数据
|
|
|
|
|
- currLayer = -1;
|
|
|
|
|
- int mapId = -1;
|
|
|
|
|
- String waveName = "";
|
|
|
|
|
- for(int i = 0; i < cfgCreateEnemy.Count; i++)
|
|
|
|
|
- {
|
|
|
|
|
- if(cfgCreateEnemy[i].WaveName == "这一行不要动")
|
|
|
|
|
- {
|
|
|
|
|
- mapId++;
|
|
|
|
|
- ArrayUtility.Clear(ref asset.maps[mapId].layers);
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- if(cfgCreateEnemy[i].WaveName != waveName)
|
|
|
|
|
- {
|
|
|
|
|
- waveName = cfgCreateEnemy[i].WaveName;
|
|
|
|
|
- ArrayUtility.Add(ref asset.maps[mapId].layers, new GameMapLayer());
|
|
|
|
|
- asset.maps[mapId].InitLayer(asset.maps[mapId].layers.Length);
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
- doRepaint = true;
|
|
|
|
|
- Debug.Log("出怪表导入成功!");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void OnMapSelected(int idx)
|
|
private void OnMapSelected(int idx)
|
|
@@ -785,12 +756,12 @@ public class GameMapEditor : EditorWindow
|
|
|
string s = wiz.text;
|
|
string s = wiz.text;
|
|
|
wiz.Close();
|
|
wiz.Close();
|
|
|
|
|
|
|
|
- if (!string.IsNullOrEmpty(s) && s != asset.maps[mapIdx].ident)
|
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(s) && s != asset.maps[mapIdx].showIdent)
|
|
|
{
|
|
{
|
|
|
if (StringIsUnique(asset.maps, s))
|
|
if (StringIsUnique(asset.maps, s))
|
|
|
{
|
|
{
|
|
|
Undo.RecordObject(asset, "Rename map");
|
|
Undo.RecordObject(asset, "Rename map");
|
|
|
- asset.maps[mapIdx].ident = s;
|
|
|
|
|
|
|
+ asset.maps[mapIdx].showIdent = s;
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
@@ -821,11 +792,6 @@ public class GameMapEditor : EditorWindow
|
|
|
GameMap gameMap = asset.maps[mapIdx];
|
|
GameMap gameMap = asset.maps[mapIdx];
|
|
|
if (GUI.Button(r, GC_rem, EditorStyles.miniButtonRight))
|
|
if (GUI.Button(r, GC_rem, EditorStyles.miniButtonRight))
|
|
|
{
|
|
{
|
|
|
-
|
|
|
|
|
- ExcelEditor.RemoveExcelRows(enemyExcelPath, gameMap.ident, (ws, row) =>
|
|
|
|
|
- {
|
|
|
|
|
- return ws.Cells[row, 2].Text == gameMap.layers[currLayer].name;
|
|
|
|
|
- });
|
|
|
|
|
Undo.RecordObject(asset, "Remove Layer");
|
|
Undo.RecordObject(asset, "Remove Layer");
|
|
|
ArrayUtility.RemoveAt(ref gameMap.layers, currLayer);
|
|
ArrayUtility.RemoveAt(ref gameMap.layers, currLayer);
|
|
|
|
|
|
|
@@ -838,7 +804,6 @@ public class GameMapEditor : EditorWindow
|
|
|
if (GUI.Button(r, GC_add, EditorStyles.miniButtonLeft))
|
|
if (GUI.Button(r, GC_add, EditorStyles.miniButtonLeft))
|
|
|
{
|
|
{
|
|
|
int length = gameMap.layers.Length + 1;
|
|
int length = gameMap.layers.Length + 1;
|
|
|
- ExcelEditor.ModifyExcel(enemyExcelPath, gameMap.ident, $"B{length + 8}", length);
|
|
|
|
|
Undo.RecordObject(asset, "Add Layer");
|
|
Undo.RecordObject(asset, "Add Layer");
|
|
|
ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
gameMap.InitLayer(length);
|
|
gameMap.InitLayer(length);
|