|
@@ -26,7 +26,8 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
{
|
|
{
|
|
|
GC_Head = isSelect ? new GUIContent("Select") : new GUIContent("Save");
|
|
GC_Head = isSelect ? new GUIContent("Select") : new GUIContent("Save");
|
|
|
GC_Add = isSelect ? new GUIContent("新建") : new GUIContent("另存");
|
|
GC_Add = isSelect ? new GUIContent("新建") : new GUIContent("另存");
|
|
|
- list = new ReorderableList(Asset.maps, typeof(GameMap), true, false, false, false)
|
|
|
|
|
|
|
+ List<GameMap> gameMaps = Asset.maps.GetRange(1, Asset.maps.Count - 1);
|
|
|
|
|
+ list = new ReorderableList(gameMaps, typeof(GameMap), false, false, false, false)
|
|
|
{
|
|
{
|
|
|
elementHeight = EditorGUIUtility.singleLineHeight,
|
|
elementHeight = EditorGUIUtility.singleLineHeight,
|
|
|
headerHeight = 0,
|
|
headerHeight = 0,
|
|
@@ -51,10 +52,14 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
|
|
|
|
|
public override void OnGUI(Rect r)
|
|
public override void OnGUI(Rect r)
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
DrawHeader(new Rect(0, 0, r.width, 25));
|
|
DrawHeader(new Rect(0, 0, r.width, 25));
|
|
|
r.y += 25; r.height -= 25;
|
|
r.y += 25; r.height -= 25;
|
|
|
scroll = GUI.BeginScrollView(r, scroll, contentRect, false, true);
|
|
scroll = GUI.BeginScrollView(r, scroll, contentRect, false, true);
|
|
|
- list.DoList(r);
|
|
|
|
|
|
|
+ if (list != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ list.DoList(r);
|
|
|
|
|
+ }
|
|
|
GUI.EndScrollView();
|
|
GUI.EndScrollView();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -92,46 +97,128 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
//r.x -= 25;
|
|
//r.x -= 25;
|
|
|
if (GUI.Button(r, GC_Add, EditorStyles.miniButtonLeft))
|
|
if (GUI.Button(r, GC_Add, EditorStyles.miniButtonLeft))
|
|
|
{
|
|
{
|
|
|
- //Undo.RecordObject(Asset, "Add Game Map");
|
|
|
|
|
- //Asset.AddMap();
|
|
|
|
|
- //ChangeContentRect();
|
|
|
|
|
- //OnMapSelected(Asset.maps.Count - 1);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ if (isSelect)
|
|
|
|
|
+ {
|
|
|
|
|
+ Asset.ClearMap(0);
|
|
|
|
|
+ GameMapEditor.mapSize_w = Asset.maps[0].width;
|
|
|
|
|
+ GameMapEditor.mapSize_h = Asset.maps[0].height;
|
|
|
|
|
+ OnMapSelected(0);
|
|
|
|
|
+ }
|
|
|
|
|
+ else
|
|
|
|
|
+ {
|
|
|
|
|
+ SaveAsNewExcelData(GameMapEditor.createEnemyExcelPath);
|
|
|
|
|
+ }
|
|
|
|
|
+ editorWindow.Close();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void DrawElement(Rect r, int index, bool isActive, bool isFocused)
|
|
private void DrawElement(Rect r, int index, bool isActive, bool isFocused)
|
|
|
{
|
|
{
|
|
|
- GUI.Label(r, Asset.maps[index].ToString());
|
|
|
|
|
|
|
+ GUI.Label(r, Asset.maps[index + 1].ToString());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void SelectMap(ReorderableList list)
|
|
private void SelectMap(ReorderableList list)
|
|
|
{
|
|
{
|
|
|
if (isSelect)
|
|
if (isSelect)
|
|
|
{
|
|
{
|
|
|
- ReloadExcelData(GameMapEditor.createEnemyExcelPath, list.index);
|
|
|
|
|
- OnMapSelected(list.index);
|
|
|
|
|
|
|
+ ReloadExcelData(GameMapEditor.createEnemyExcelPath, list.index + 1);
|
|
|
|
|
+ OnMapSelected(0);
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- //SaveExcelData(GameMapEditor.createEnemyExcelPath, list.index);
|
|
|
|
|
|
|
+ SaveExcelData(GameMapEditor.createEnemyExcelPath, list.index + 1);
|
|
|
}
|
|
}
|
|
|
editorWindow.Close();
|
|
editorWindow.Close();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- void SaveExcelData(string path, int mapIdx)
|
|
|
|
|
|
|
+ void SaveAsNewExcelData(string path)
|
|
|
|
|
+ {
|
|
|
|
|
+ FileInfo fileInfo = new FileInfo(path);
|
|
|
|
|
+ using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
|
|
+ {
|
|
|
|
|
+ GameMap gameMap = GameMapEditor.asset.maps[GameMapEditor.mapIdx];
|
|
|
|
|
+ // 拷贝 Sheet
|
|
|
|
|
+ ExcelWorksheet sourceSheet = package.Workbook.Worksheets[1];
|
|
|
|
|
+ // 保存目标文件
|
|
|
|
|
+ try
|
|
|
|
|
+ {
|
|
|
|
|
+ ExcelWorksheet newSheet = package.Workbook.Worksheets.Add(gameMap.showIdent, sourceSheet);
|
|
|
|
|
+ package.Save();
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (System.InvalidOperationException e)
|
|
|
|
|
+ {
|
|
|
|
|
+ Debug.LogError($"出怪表未关闭或Sheet名重复,请重试");
|
|
|
|
|
+ Debug.LogException(e);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ SaveExcelData(path, 0,true);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void SaveExcelData(string path, int mapIdx, bool isNew = false)
|
|
|
{
|
|
{
|
|
|
List<string> excelWorksheets = new();
|
|
List<string> excelWorksheets = new();
|
|
|
GameMap gameMap = GameMapEditor.asset.maps[GameMapEditor.mapIdx];
|
|
GameMap gameMap = GameMapEditor.asset.maps[GameMapEditor.mapIdx];
|
|
|
FileInfo fileInfo = new FileInfo(path);
|
|
FileInfo fileInfo = new FileInfo(path);
|
|
|
using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
{
|
|
{
|
|
|
|
|
+
|
|
|
excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
- if (!ExcelEditor.RenameSheet(package, excelWorksheets[mapIdx], gameMap.showIdent))
|
|
|
|
|
|
|
+ if (!isNew)
|
|
|
{
|
|
{
|
|
|
- return;
|
|
|
|
|
|
|
+ if (!ExcelEditor.RenameSheet(package, excelWorksheets[mapIdx - 1], gameMap.showIdent))
|
|
|
|
|
+ {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, "C6", GameMapEditor.mapSize_w.ToString());
|
|
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, "D5", GameMapEditor.mapSize_w.ToString());
|
|
|
ExcelEditor.ModifyExcel(package, gameMap.showIdent, "D6", GameMapEditor.mapSize_h.ToString());
|
|
ExcelEditor.ModifyExcel(package, gameMap.showIdent, "D6", GameMapEditor.mapSize_h.ToString());
|
|
|
|
|
+
|
|
|
|
|
+ int cell_row = 10;
|
|
|
|
|
+ for(int i = 0; i < gameMap.layers.Length; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ GameMapLayer layer = gameMap.layers[i];
|
|
|
|
|
+
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"C{cell_row}", layer.name);
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", layer.duration.ToString());
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", layer.attack.ToString());
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"F{cell_row}", layer.moveSpeed.ToString());
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"G{cell_row}", layer.Hp.ToString());
|
|
|
|
|
+ for(int j = 0;j< layer.spawnTimes.Count; j++)
|
|
|
|
|
+ {
|
|
|
|
|
+ SpawnTime spawnTime = layer.spawnTimes[j];
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", (i + 1).ToString());
|
|
|
|
|
+ if(j != 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int k = 0; k < 5; k++)
|
|
|
|
|
+ {
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, cell_row, 3 + k, "");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"H{cell_row}", Asset.tileAsset.GetTile(spawnTime.id).name);
|
|
|
|
|
+ string posString = "";
|
|
|
|
|
+ for(int k = 0; k < spawnTime.pos.Count; k++)
|
|
|
|
|
+ {
|
|
|
|
|
+ int pos = spawnTime.pos[k] + 1;
|
|
|
|
|
+ posString += (pos % GameMapEditor.mapSize_w).ToString();
|
|
|
|
|
+ posString += ",";
|
|
|
|
|
+ posString += (pos / GameMapEditor.mapSize_w + 1).ToString();
|
|
|
|
|
+ if(k == spawnTime.pos.Count - 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ posString += ",";
|
|
|
|
|
+ }
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"I{cell_row}", posString);
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"J{cell_row}", spawnTime.startTime.ToString());
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"K{cell_row}", spawnTime.endTime.ToString());
|
|
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"L{cell_row}", spawnTime.num.ToString());
|
|
|
|
|
+ cell_row++;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ExcelEditor.RemoveExcelRows(package, gameMap.showIdent, cell_row, cell_row + 100);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
package.Save();
|
|
package.Save();
|
|
|
}
|
|
}
|
|
|
Debug.Log($"\"{gameMap.showIdent}\"表保存完毕!");
|
|
Debug.Log($"\"{gameMap.showIdent}\"表保存完毕!");
|
|
@@ -143,28 +230,28 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
List<string> excelWorksheets = new();
|
|
List<string> excelWorksheets = new();
|
|
|
Tables allCfgData = new Tables(ExcelEditor.Loader);
|
|
Tables allCfgData = new Tables(ExcelEditor.Loader);
|
|
|
List<SingleCreateEnemyConfig> cfgCreateEnemy = allCfgData.CfgCreateEnemy.DataList;
|
|
List<SingleCreateEnemyConfig> cfgCreateEnemy = allCfgData.CfgCreateEnemy.DataList;
|
|
|
- GameMap gameMap = GameMapEditor.asset.maps[mapIdx];
|
|
|
|
|
|
|
+ GameMap gameMap = GameMapEditor.asset.maps[0];
|
|
|
FileInfo fileInfo = new FileInfo(path);
|
|
FileInfo fileInfo = new FileInfo(path);
|
|
|
using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
{
|
|
{
|
|
|
excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
|
|
|
|
|
//导入关卡数据
|
|
//导入关卡数据
|
|
|
|
|
+ gameMap.ident = GameMapEditor.asset.maps[mapIdx].ident;
|
|
|
gameMap.showIdent = gameMap.ident;
|
|
gameMap.showIdent = gameMap.ident;
|
|
|
- int.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[mapIdx], "C6"), out GameMapEditor.mapSize_w);
|
|
|
|
|
- int.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[mapIdx], "D6"), out GameMapEditor.mapSize_h);
|
|
|
|
|
|
|
+ int.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[mapIdx - 1], "D5"), out GameMapEditor.mapSize_w);
|
|
|
|
|
+ int.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[mapIdx - 1], "D6"), out GameMapEditor.mapSize_h);
|
|
|
gameMap.Resize(GameMapEditor.mapSize_w, GameMapEditor.mapSize_h);
|
|
gameMap.Resize(GameMapEditor.mapSize_w, GameMapEditor.mapSize_h);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//导入波次数据
|
|
//导入波次数据
|
|
|
GameMapEditor.currLayer = -1;
|
|
GameMapEditor.currLayer = -1;
|
|
|
int mapId = -1;
|
|
int mapId = -1;
|
|
|
- String waveName = "";
|
|
|
|
|
for (int i = 0; i < cfgCreateEnemy.Count; i++)
|
|
for (int i = 0; i < cfgCreateEnemy.Count; i++)
|
|
|
{
|
|
{
|
|
|
- if (cfgCreateEnemy[i].WaveName == "占位行")
|
|
|
|
|
|
|
+ if (cfgCreateEnemy[i].WaveID == -1)
|
|
|
{
|
|
{
|
|
|
- if(mapId == mapIdx)
|
|
|
|
|
|
|
+ if(mapId == mapIdx - 1)
|
|
|
{
|
|
{
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
@@ -172,17 +259,17 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
ArrayUtility.Clear(ref gameMap.layers);
|
|
ArrayUtility.Clear(ref gameMap.layers);
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- if(mapId == mapIdx)
|
|
|
|
|
|
|
+ if(mapId == mapIdx - 1)
|
|
|
{
|
|
{
|
|
|
- if (cfgCreateEnemy[i].WaveName != waveName)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ if(cfgCreateEnemy[i].WaveID > gameMap.layers.Length)
|
|
|
|
|
+ {
|
|
|
//波次第一行的波次数据
|
|
//波次第一行的波次数据
|
|
|
SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
|
|
SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
|
|
|
- waveName = singleCreateEnemyConfig.WaveName;
|
|
|
|
|
|
|
+ int id = singleCreateEnemyConfig.WaveID;
|
|
|
ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
gameMap.InitLayer(gameMap.layers.Length);
|
|
gameMap.InitLayer(gameMap.layers.Length);
|
|
|
GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
- gameMapLayer.name = waveName;
|
|
|
|
|
|
|
+ gameMapLayer.name = singleCreateEnemyConfig.WaveName;
|
|
|
gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
|
|
gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
|
|
|
gameMapLayer.Hp = singleCreateEnemyConfig.HPRatio;
|
|
gameMapLayer.Hp = singleCreateEnemyConfig.HPRatio;
|
|
|
gameMapLayer.moveSpeed = singleCreateEnemyConfig.SpeedRatio;
|
|
gameMapLayer.moveSpeed = singleCreateEnemyConfig.SpeedRatio;
|
|
@@ -208,7 +295,7 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
|
|
|
|
|
|
|
|
|
|
doRepaint = true;
|
|
doRepaint = true;
|
|
|
- Debug.Log($"\"{excelWorksheets[mapIdx]}\"表导入完毕!");
|
|
|
|
|
|
|
+ Debug.Log($"\"{excelWorksheets[mapIdx - 1]}\"表导入完毕!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|