|
|
@@ -6,6 +6,7 @@ using cfg;
|
|
|
using System;
|
|
|
using System.IO;
|
|
|
using OfficeOpenXml;
|
|
|
+using SimpleJSON;
|
|
|
|
|
|
public class GameMapEdPopup : PopupWindowContent
|
|
|
{
|
|
|
@@ -80,20 +81,13 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
GameMapEditor.mapSize_w = Asset.maps[0].width;
|
|
|
GameMapEditor.mapSize_h = Asset.maps[0].height;
|
|
|
Asset.maps[0].expRatio = 1;
|
|
|
+ Asset.maps[0].levelId = Asset.levelID;
|
|
|
OnMapSelected(0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (GameMapEditor.asset.maps[0].isDynamic)
|
|
|
- {
|
|
|
- SaveAsNewCreateEnemyData(true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SaveAsNewCreateEnemyData(false);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ SaveAsNewCreateEnemyData();
|
|
|
+ }
|
|
|
editorWindow.Close();
|
|
|
}
|
|
|
}
|
|
|
@@ -107,47 +101,25 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
{
|
|
|
if (isSelect)
|
|
|
{
|
|
|
- if(list.index + 1 >= GameMapEditor.asset.dynamicSheetStart)
|
|
|
- {
|
|
|
- ReloadDynamicEnemyData(list.index + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- ReloadCreateEnemyData(list.index + 1);
|
|
|
- }
|
|
|
-
|
|
|
+ ReloadCreateEnemyData(list.index + 1);
|
|
|
+
|
|
|
OnMapSelected(0);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (GameMapEditor.asset.maps[0].isDynamic)
|
|
|
- {
|
|
|
- SaveDynamicEnemyData(list.index + 1);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SaveCreateEnemyData(list.index + 1);
|
|
|
- }
|
|
|
- }
|
|
|
+ SaveCreateEnemyData(list.index + 1);
|
|
|
+ }
|
|
|
editorWindow.Close();
|
|
|
}
|
|
|
|
|
|
- void SaveAsNewCreateEnemyData(bool isDynamic)
|
|
|
+ void SaveAsNewCreateEnemyData()
|
|
|
{
|
|
|
- string path = "";
|
|
|
- if (isDynamic)
|
|
|
- {
|
|
|
- path = GameMapEditor.dynamicEnemyExcelPath;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- path = GameMapEditor.createEnemyExcelPath;
|
|
|
- }
|
|
|
-
|
|
|
+ GameMap gameMap = GameMapEditor.asset.maps[GameMapEditor.mapIdx];
|
|
|
+ string path = GameMapEditor.createEnemyExcelPath + $"/出怪表{gameMap.levelId}.xlsx";
|
|
|
+
|
|
|
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];
|
|
|
// 保存目标文件
|
|
|
@@ -163,27 +135,19 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- if (isDynamic)
|
|
|
- {
|
|
|
- SaveDynamicEnemyData(0, true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- SaveCreateEnemyData(0, true);
|
|
|
- }
|
|
|
+ SaveCreateEnemyData(0, true);
|
|
|
|
|
|
}
|
|
|
|
|
|
void SaveCreateEnemyData(int mapIdx, bool isNew = false)
|
|
|
{
|
|
|
- string path = GameMapEditor.createEnemyExcelPath;
|
|
|
- List<string> excelWorksheets = new();
|
|
|
GameMap gameMap = GameMapEditor.asset.maps[GameMapEditor.mapIdx];
|
|
|
+ string path = GameMapEditor.createEnemyExcelPath + $"/出怪表{gameMap.levelId}.xlsx";
|
|
|
FileInfo fileInfo = new FileInfo(path);
|
|
|
using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
{
|
|
|
|
|
|
- excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
+ List<string> excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
if (!isNew)
|
|
|
{
|
|
|
if (!ExcelEditor.RenameSheet(package, excelWorksheets[mapIdx - 1], gameMap.showIdent))
|
|
|
@@ -207,152 +171,22 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
switch (layer.waveType)
|
|
|
{
|
|
|
case WaveType.Common:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", layer.duration.ToString());
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", layer.duration.ToString());
|
|
|
idInt++;
|
|
|
break;
|
|
|
case WaveType.FromTower:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"F{cell_row}", layer.buildingId);
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"G{cell_row}", layer.buildingHp.ToString());
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", layer.buildingId);
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"F{cell_row}", layer.buildingHp.ToString());
|
|
|
idFloat += 0.01f;
|
|
|
break;
|
|
|
case WaveType.Tower:
|
|
|
if(i == 0)
|
|
|
{
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", layer.duration.ToString());
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", layer.duration.ToString());
|
|
|
}
|
|
|
break;
|
|
|
}
|
|
|
|
|
|
- if (layer.isDynamic)
|
|
|
- {
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", layer.dynamicSheet.ToString());
|
|
|
- switch (layer.waveType)
|
|
|
- {
|
|
|
- case WaveType.Common:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", idInt.ToString());
|
|
|
- break;
|
|
|
- case WaveType.Tower:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", "0");
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"C{cell_row}", layer.name);
|
|
|
- break;
|
|
|
- case WaveType.FromTower:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", $"{idFloat:F2}");
|
|
|
- break;
|
|
|
- }
|
|
|
- cell_row++;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- foreach (var item in layer.spawnTimes)
|
|
|
- {
|
|
|
- SpawnTime spawnTime = item.Value;
|
|
|
- try
|
|
|
- {
|
|
|
- if (spawnTime.pos.Count == 0)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- UnityEngine.Debug.LogException(e);
|
|
|
- }
|
|
|
-
|
|
|
- switch (layer.waveType)
|
|
|
- {
|
|
|
- case WaveType.Common:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", idInt.ToString());
|
|
|
- break;
|
|
|
- case WaveType.Tower:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", "0");
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"C{cell_row}", layer.name);
|
|
|
- break;
|
|
|
- case WaveType.FromTower:
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", $"{idFloat:F2}");
|
|
|
- break;
|
|
|
- }
|
|
|
-
|
|
|
- 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;
|
|
|
- int w = pos % GameMapEditor.mapSize_w;
|
|
|
- int h = pos / GameMapEditor.mapSize_w;
|
|
|
- if (w == 0)
|
|
|
- {
|
|
|
- posString += GameMapEditor.mapSize_w.ToString();
|
|
|
- posString += ",";
|
|
|
- posString += h.ToString();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- posString += w.ToString();
|
|
|
- posString += ",";
|
|
|
- posString += (h + 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++;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- try
|
|
|
- {
|
|
|
- package.Save();
|
|
|
- }
|
|
|
- catch (System.InvalidOperationException e)
|
|
|
- {
|
|
|
- EditorUtility.DisplayDialog("Error", $"出怪表未关闭或Sheet名重复,请重试", "OK");
|
|
|
- UnityEngine.Debug.LogException(e);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- UnityEngine.Debug.Log($"\"{gameMap.showIdent}\"表保存完毕!");
|
|
|
- UnityEngine.Debug.Log("记得运行\"gen_code_json.bat\"更新数据!");
|
|
|
- ExcelEditor.RunBat();
|
|
|
- }
|
|
|
-
|
|
|
- void SaveDynamicEnemyData(int mapIdx, bool isNew = false)
|
|
|
- {
|
|
|
- string path = GameMapEditor.dynamicEnemyExcelPath;
|
|
|
- List<string> excelWorksheets = new();
|
|
|
- GameMap gameMap = GameMapEditor.asset.maps[GameMapEditor.mapIdx];
|
|
|
- FileInfo fileInfo = new FileInfo(path);
|
|
|
- using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
- {
|
|
|
- excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
- if (!isNew)
|
|
|
- {
|
|
|
- if (!ExcelEditor.RenameSheet(package, excelWorksheets[mapIdx - 1], gameMap.showIdent))
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- }
|
|
|
- ExcelEditor.RemoveExcelRows(package, gameMap.showIdent, 10, 500);
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, "D5", GameMapEditor.mapSize_w.ToString());
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, "D6", GameMapEditor.mapSize_h.ToString());
|
|
|
-
|
|
|
- int cell_row = 10;
|
|
|
- int idInt = 0;
|
|
|
- for (int i = 0; i < gameMap.layers.Length; i++)
|
|
|
- {
|
|
|
- GameMapLayer layer = gameMap.layers[i];
|
|
|
-
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"C{cell_row}", layer.name);
|
|
|
- idInt++;
|
|
|
-
|
|
|
foreach (var item in layer.spawnTimes)
|
|
|
{
|
|
|
SpawnTime spawnTime = item.Value;
|
|
|
@@ -368,8 +202,21 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
UnityEngine.Debug.LogException(e);
|
|
|
}
|
|
|
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", idInt.ToString());
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", Asset.tileAsset.GetTile(spawnTime.id).name);
|
|
|
+ switch (layer.waveType)
|
|
|
+ {
|
|
|
+ case WaveType.Common:
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", idInt.ToString());
|
|
|
+ break;
|
|
|
+ case WaveType.Tower:
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", "0");
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"C{cell_row}", layer.name);
|
|
|
+ break;
|
|
|
+ case WaveType.FromTower:
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", $"{idFloat:F2}");
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"G{cell_row}", Asset.tileAsset.GetTile(spawnTime.id).name);
|
|
|
string posString = "";
|
|
|
for (int k = 0; k < spawnTime.pos.Count; k++)
|
|
|
{
|
|
|
@@ -394,12 +241,14 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
}
|
|
|
posString += ",";
|
|
|
}
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", posString);
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"F{cell_row}", spawnTime.startTime.ToString());
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"G{cell_row}", spawnTime.endTime.ToString());
|
|
|
- ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"H{cell_row}", spawnTime.num.ToString());
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"H{cell_row}", posString);
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"I{cell_row}", spawnTime.startTime.ToString());
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"J{cell_row}", spawnTime.endTime.ToString());
|
|
|
+ ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"K{cell_row}", spawnTime.num.ToString());
|
|
|
cell_row++;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
try
|
|
|
{
|
|
|
@@ -420,267 +269,153 @@ public class GameMapEdPopup : PopupWindowContent
|
|
|
|
|
|
public void ReloadCreateEnemyData(int mapIdx)
|
|
|
{
|
|
|
- string path = GameMapEditor.createEnemyExcelPath;
|
|
|
- ExcelEditor.RunBat();
|
|
|
- List<string> excelWorksheets = new();
|
|
|
- Tables allCfgData = new Tables(ExcelEditor.Loader);
|
|
|
- List<SingleCreateEnemyConfig> cfgCreateEnemy = allCfgData.CfgCreateEnemy.DataList;
|
|
|
GameMap gameMap = GameMapEditor.asset.maps[0];
|
|
|
- FileInfo fileInfo = new FileInfo(path);
|
|
|
- using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
- {
|
|
|
- excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
-
|
|
|
- //导入关卡数据
|
|
|
- gameMap.ident = GameMapEditor.asset.maps[mapIdx].ident;
|
|
|
- gameMap.showIdent = gameMap.ident;
|
|
|
- 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);
|
|
|
- float.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[mapIdx - 1], "F5"), out gameMap.expRatio);
|
|
|
- gameMap.Resize(GameMapEditor.mapSize_w, GameMapEditor.mapSize_h);
|
|
|
- }
|
|
|
+ string path = GameMapEditor.createEnemyExcelPath + $"/出怪表{Asset.levelID}.xlsx";
|
|
|
+ gameMap.levelId = Asset.levelID;
|
|
|
+ ExcelEditor.RunBat();
|
|
|
+ List<string> excelWorksheets = new();
|
|
|
+ JSONNode keyValuePairs = JSON.Parse(File.ReadAllText($"GenerateDatas/json/CfgCreateEnemy{gameMap.levelId}.json"));
|
|
|
+ CreateEnemyConfig createEnemyConfig = new CreateEnemyConfig(keyValuePairs);
|
|
|
+ List<SingleCreateEnemyConfig> cfgCreateEnemy = createEnemyConfig.DataList;
|
|
|
+
|
|
|
+ FileInfo fileInfo = new FileInfo(path);
|
|
|
+ using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
+ {
|
|
|
+ excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
|
|
|
- //导入波次数据
|
|
|
- GameMapEditor.currLayer = -1;
|
|
|
- int mapId = -1;
|
|
|
- float id = 0;
|
|
|
- ArrayUtility.Clear(ref gameMap.layers);
|
|
|
- for (int i = 0; i < cfgCreateEnemy.Count; i++)
|
|
|
- {
|
|
|
- if (cfgCreateEnemy[i].WaveID == -1)
|
|
|
- {
|
|
|
- if(mapId == mapIdx - 1)
|
|
|
+ //导入关卡数据
|
|
|
+ gameMap.ident = GameMapEditor.asset.maps[mapIdx].ident;
|
|
|
+ gameMap.showIdent = gameMap.ident;
|
|
|
+ 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);
|
|
|
+ float.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[mapIdx - 1], "F5"), out gameMap.expRatio);
|
|
|
+ gameMap.Resize(GameMapEditor.mapSize_w, GameMapEditor.mapSize_h);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //导入波次数据
|
|
|
+ GameMapEditor.currLayer = -1;
|
|
|
+ int mapId = -1;
|
|
|
+ float id = 0;
|
|
|
+ ArrayUtility.Clear(ref gameMap.layers);
|
|
|
+ for (int i = 0; i < cfgCreateEnemy.Count; i++)
|
|
|
+ {
|
|
|
+ if (cfgCreateEnemy[i].WaveID == -1)
|
|
|
+ {
|
|
|
+ if (mapId == mapIdx - 1)
|
|
|
{
|
|
|
- break;
|
|
|
+ break;
|
|
|
}
|
|
|
- mapId++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(mapId == mapIdx - 1)
|
|
|
+ mapId++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (mapId == mapIdx - 1)
|
|
|
{
|
|
|
- if (cfgCreateEnemy[i].WaveID == 0)
|
|
|
+ if (cfgCreateEnemy[i].WaveID == 0)
|
|
|
{
|
|
|
- SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
|
|
|
- ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
- gameMap.InitLayer(gameMap.layers.Length);
|
|
|
- GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
- gameMapLayer.name = singleCreateEnemyConfig.WaveName;
|
|
|
- gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
|
|
|
- gameMapLayer.waveType = WaveType.Tower;
|
|
|
-
|
|
|
- ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
|
|
|
- }
|
|
|
+ SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
|
|
|
+ ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
+ gameMap.InitLayer(gameMap.layers.Length);
|
|
|
+ GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
+ gameMapLayer.name = singleCreateEnemyConfig.WaveName;
|
|
|
+ gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
|
|
|
+ gameMapLayer.waveType = WaveType.Tower;
|
|
|
+
|
|
|
+ ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
-
|
|
|
- if (cfgCreateEnemy[i].WaveID - cfgCreateEnemy[i - 1].WaveID > 1
|
|
|
- || cfgCreateEnemy[i].WaveID < cfgCreateEnemy[i - 1].WaveID)
|
|
|
- {
|
|
|
- UnityEngine.Debug.Log(cfgCreateEnemy[i].WaveID);
|
|
|
- UnityEngine.Debug.Log(cfgCreateEnemy[i - 1].WaveID);
|
|
|
- EditorUtility.DisplayDialog("Error", $"\"{excelWorksheets[mapIdx - 1]}\"关卡第\"{cfgCreateEnemy[i].WaveID}\"波顺序有误", "OK");
|
|
|
- }
|
|
|
- if (cfgCreateEnemy[i].WaveID != id)
|
|
|
- {
|
|
|
- //波次第一行的波次数据
|
|
|
- SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
|
|
|
- id = cfgCreateEnemy[i].WaveID;
|
|
|
- ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
- gameMap.InitLayer(gameMap.layers.Length);
|
|
|
- GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
- gameMapLayer.name = singleCreateEnemyConfig.WaveName;
|
|
|
- if(cfgCreateEnemy[i].WaveID < 1)
|
|
|
+
|
|
|
+ if (cfgCreateEnemy[i].WaveID - cfgCreateEnemy[i - 1].WaveID > 1
|
|
|
+ || cfgCreateEnemy[i].WaveID < cfgCreateEnemy[i - 1].WaveID)
|
|
|
+ {
|
|
|
+ UnityEngine.Debug.Log(cfgCreateEnemy[i].WaveID);
|
|
|
+ UnityEngine.Debug.Log(cfgCreateEnemy[i - 1].WaveID);
|
|
|
+ EditorUtility.DisplayDialog("Error", $"\"{excelWorksheets[mapIdx - 1]}\"关卡第\"{cfgCreateEnemy[i].WaveID}\"波顺序有误", "OK");
|
|
|
+ }
|
|
|
+ if (cfgCreateEnemy[i].WaveID != id)
|
|
|
+ {
|
|
|
+ //波次第一行的波次数据
|
|
|
+ SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
|
|
|
+ id = cfgCreateEnemy[i].WaveID;
|
|
|
+ ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
+ gameMap.InitLayer(gameMap.layers.Length);
|
|
|
+ GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
+ gameMapLayer.name = singleCreateEnemyConfig.WaveName;
|
|
|
+ if (cfgCreateEnemy[i].WaveID < 1)
|
|
|
{
|
|
|
- gameMapLayer.waveType = WaveType.FromTower;
|
|
|
- gameMapLayer.buildingId = singleCreateEnemyConfig.BuildingID;
|
|
|
- gameMapLayer.buildingHp = singleCreateEnemyConfig.BuildingHP;
|
|
|
- }
|
|
|
+ gameMapLayer.waveType = WaveType.FromTower;
|
|
|
+ gameMapLayer.buildingId = singleCreateEnemyConfig.BuildingID;
|
|
|
+ gameMapLayer.buildingHp = singleCreateEnemyConfig.BuildingHP;
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- gameMapLayer.waveType = WaveType.Common;
|
|
|
- gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
|
|
|
- }
|
|
|
- if(cfgCreateEnemy[i].Dynamic == 0)
|
|
|
- {
|
|
|
- //波次第一行怪物数据
|
|
|
- ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- gameMapLayer.isDynamic = true;
|
|
|
- gameMapLayer.dynamicSheet = cfgCreateEnemy[i].Dynamic;
|
|
|
+ gameMapLayer.waveType = WaveType.Common;
|
|
|
+ gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
|
|
|
}
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
|
|
|
}
|
|
|
- }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
+ ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- if(i == cfgCreateEnemy.Count - 1)
|
|
|
+ if (i == cfgCreateEnemy.Count - 1)
|
|
|
{
|
|
|
- UnityEngine.Debug.LogError("请运行\"gen_code_json.bat\"更新表格数据");
|
|
|
+ UnityEngine.Debug.LogError("请运行\"gen_code_json.bat\"更新表格数据");
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- // 标记资源为脏数据,以便保存更改
|
|
|
- EditorUtility.SetDirty(GameMapEditor.asset);
|
|
|
- AssetDatabase.SaveAssets();
|
|
|
- UnityEngine.Debug.Log($"\"{excelWorksheets[mapIdx - 1]}\"表导入完毕!");
|
|
|
- }
|
|
|
-
|
|
|
- public void ReloadDynamicEnemyData(int mapIdx)
|
|
|
- {
|
|
|
- int sheetId = mapIdx - GameMapEditor.asset.dynamicSheetStart;
|
|
|
- string path = GameMapEditor.dynamicEnemyExcelPath;
|
|
|
- ExcelEditor.RunBat();
|
|
|
- List<string> excelWorksheets = new();
|
|
|
- Tables allCfgData = new Tables(ExcelEditor.Loader);
|
|
|
- List<SingleDynamicEnemyConfig> cfgDynamicEnemy = allCfgData.CfgDynamicEnemy.DataList;
|
|
|
- GameMap gameMap = GameMapEditor.asset.maps[0];
|
|
|
- FileInfo fileInfo = new FileInfo(path);
|
|
|
- using (ExcelPackage package = new ExcelPackage(fileInfo))
|
|
|
- {
|
|
|
- excelWorksheets = ExcelEditor.ReadExcelSheetsInfo(package);
|
|
|
-
|
|
|
- //导入关卡数据
|
|
|
- gameMap.ident = GameMapEditor.asset.maps[mapIdx].ident;
|
|
|
- gameMap.showIdent = gameMap.ident;
|
|
|
- int.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[sheetId], "D5"), out GameMapEditor.mapSize_w);
|
|
|
- int.TryParse(ExcelEditor.GetCellData(package, excelWorksheets[sheetId], "D6"), out GameMapEditor.mapSize_h);
|
|
|
- gameMap.Resize(GameMapEditor.mapSize_w, GameMapEditor.mapSize_h);
|
|
|
- gameMap.isDynamic = true;
|
|
|
- }
|
|
|
-
|
|
|
- //导入波次数据
|
|
|
- GameMapEditor.currLayer = -1;
|
|
|
- int mapId = -1;
|
|
|
- float id = 0;
|
|
|
- ArrayUtility.Clear(ref gameMap.layers);
|
|
|
- UnityEngine.Debug.Log(sheetId);
|
|
|
- for (int i = 0; i < cfgDynamicEnemy.Count; i++)
|
|
|
- {
|
|
|
- if (cfgDynamicEnemy[i].WaveID == -1)
|
|
|
- {
|
|
|
- if (mapId == sheetId)
|
|
|
- {
|
|
|
- break;
|
|
|
- }
|
|
|
- mapId++;
|
|
|
- continue;
|
|
|
- }
|
|
|
- if (mapId == sheetId)
|
|
|
- {
|
|
|
-
|
|
|
- if (cfgDynamicEnemy[i].WaveID != id)
|
|
|
- {
|
|
|
- //波次第一行的波次数据
|
|
|
- SingleDynamicEnemyConfig singleDynamicEnemyConfig = cfgDynamicEnemy[i];
|
|
|
- id = cfgDynamicEnemy[i].WaveID;
|
|
|
- ArrayUtility.Add(ref gameMap.layers, new GameMapLayer());
|
|
|
- gameMap.InitLayer(gameMap.layers.Length);
|
|
|
- GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
- gameMapLayer.name = singleDynamicEnemyConfig.WaveName;
|
|
|
- gameMapLayer.waveType = WaveType.Common;
|
|
|
- ReloadDynamicEnemy(gameMapLayer, cfgDynamicEnemy[i], excelWorksheets[sheetId]);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
|
|
|
- ReloadDynamicEnemy(gameMapLayer, cfgDynamicEnemy[i], excelWorksheets[sheetId]);
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
- // 标记资源为脏数据,以便保存更改
|
|
|
- EditorUtility.SetDirty(GameMapEditor.asset);
|
|
|
- AssetDatabase.SaveAssets();
|
|
|
- UnityEngine.Debug.Log($"\"{excelWorksheets[sheetId]}\"表导入完毕!");
|
|
|
- }
|
|
|
+ }
|
|
|
+ // 标记资源为脏数据,以便保存更改
|
|
|
+ EditorUtility.SetDirty(GameMapEditor.asset);
|
|
|
+ AssetDatabase.SaveAssets();
|
|
|
+ UnityEngine.Debug.Log($"\"{excelWorksheets[mapIdx - 1]}\"表导入完毕!");
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- public void ReloadEnemyInWave(GameMapLayer layer, SingleCreateEnemyConfig cfgData, string SheetName)
|
|
|
+ public void ReloadEnemyInWave(GameMapLayer layer, SingleCreateEnemyConfig cfgData, string SheetName)
|
|
|
{
|
|
|
- if (cfgData.EnemyName == "")
|
|
|
- {
|
|
|
- EditorUtility.DisplayDialog("Error", $"\"{SheetName}\"关卡\"{layer.name}\"波次中有怪物名称为空", "OK");
|
|
|
- return;
|
|
|
- }
|
|
|
- GameMapTile tile = GameMapEditor.asset.tileAsset.tiles.Find(x => x.name == cfgData.EnemyName);
|
|
|
- if (!layer.spawnTimes.ContainsKey(tile.id))
|
|
|
+ if (cfgData.EnemyName == "")
|
|
|
+ {
|
|
|
+ EditorUtility.DisplayDialog("Error", $"\"{SheetName}\"关卡\"{layer.name}\"波次中有怪物名称为空", "OK");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ GameMapTile tile = GameMapEditor.asset.tileAsset.tiles.Find(x => x.name == cfgData.EnemyName);
|
|
|
+ if (!layer.spawnTimes.ContainsKey(tile.id))
|
|
|
{
|
|
|
- SpawnTime spawnTime = new();
|
|
|
+ SpawnTime spawnTime = new();
|
|
|
|
|
|
- spawnTime.id = tile.id;
|
|
|
+ spawnTime.id = tile.id;
|
|
|
if (cfgData.Position.Count % 2 != 0)
|
|
|
{
|
|
|
- UnityEngine.Debug.LogError($"出怪表\"{cfgData.WaveName}\"中\"{cfgData.EnemyName}\"的Position格式错误");
|
|
|
+ UnityEngine.Debug.LogError($"出怪表\"{cfgData.WaveName}\"中\"{cfgData.EnemyName}\"的Position格式错误");
|
|
|
}
|
|
|
- spawnTime.pos = new();
|
|
|
- for(int i = 0; i < cfgData.Position.Count; i+=2)
|
|
|
+ spawnTime.pos = new();
|
|
|
+ for (int i = 0; i < cfgData.Position.Count; i += 2)
|
|
|
{
|
|
|
- int x = cfgData.Position[i];
|
|
|
- int y = cfgData.Position[i + 1];
|
|
|
- layer.grid[(y - 1) * GameMapEditor.mapSize_w + x -1] = spawnTime.id;
|
|
|
- spawnTime.pos.Add((y - 1) * GameMapEditor.mapSize_w + x - 1);
|
|
|
+ int x = cfgData.Position[i];
|
|
|
+ int y = cfgData.Position[i + 1];
|
|
|
+ layer.grid[(y - 1) * GameMapEditor.mapSize_w + x - 1] = spawnTime.id;
|
|
|
+ spawnTime.pos.Add((y - 1) * GameMapEditor.mapSize_w + x - 1);
|
|
|
}
|
|
|
- spawnTime.startTime = cfgData.StartTime;
|
|
|
- spawnTime.endTime = cfgData.EndTime;
|
|
|
- spawnTime.num = cfgData.Count;
|
|
|
- spawnTime.Hp = cfgData.HPRatio;
|
|
|
- spawnTime.moveSpeed = cfgData.SpeedRatio;
|
|
|
- spawnTime.attack = cfgData.AttackRatio;
|
|
|
-
|
|
|
- layer.spawnTimes.Add(tile.id,spawnTime);
|
|
|
+ spawnTime.startTime = cfgData.StartTime;
|
|
|
+ spawnTime.endTime = cfgData.EndTime;
|
|
|
+ spawnTime.num = cfgData.Count;
|
|
|
+ spawnTime.Hp = cfgData.HPRatio;
|
|
|
+ spawnTime.moveSpeed = cfgData.SpeedRatio;
|
|
|
+ spawnTime.attack = cfgData.AttackRatio;
|
|
|
+
|
|
|
+ layer.spawnTimes.Add(tile.id, spawnTime);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- UnityEngine.Debug.LogError($"\"{layer.name}\"波次中\"{cfgData.EnemyName}\"重复");
|
|
|
+ UnityEngine.Debug.LogError($"\"{layer.name}\"波次中\"{cfgData.EnemyName}\"重复");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- public void ReloadDynamicEnemy(GameMapLayer layer, SingleDynamicEnemyConfig cfgData, string SheetName)
|
|
|
- {
|
|
|
- if (cfgData.EnemyName == "")
|
|
|
- {
|
|
|
- EditorUtility.DisplayDialog("Error", $"\"{SheetName}\"关卡\"{layer.name}\"波次中有怪物名称为空", "OK");
|
|
|
- return;
|
|
|
- }
|
|
|
- GameMapTile tile = GameMapEditor.asset.tileAsset.tiles.Find(x => x.name == cfgData.EnemyName);
|
|
|
- if (!layer.spawnTimes.ContainsKey(tile.id))
|
|
|
- {
|
|
|
- SpawnTime spawnTime = new();
|
|
|
-
|
|
|
- spawnTime.id = tile.id;
|
|
|
- if (cfgData.Position.Count % 2 != 0)
|
|
|
- {
|
|
|
- UnityEngine.Debug.LogError($"出怪表\"{cfgData.WaveName}\"中\"{cfgData.EnemyName}\"的Position格式错误");
|
|
|
- }
|
|
|
- spawnTime.pos = new();
|
|
|
- for (int i = 0; i < cfgData.Position.Count; i += 2)
|
|
|
- {
|
|
|
- int x = cfgData.Position[i];
|
|
|
- int y = cfgData.Position[i + 1];
|
|
|
- layer.grid[(y - 1) * GameMapEditor.mapSize_w + x - 1] = spawnTime.id;
|
|
|
- spawnTime.pos.Add((y - 1) * GameMapEditor.mapSize_w + x - 1);
|
|
|
- }
|
|
|
- spawnTime.startTime = cfgData.StartTime;
|
|
|
- spawnTime.endTime = cfgData.EndTime;
|
|
|
- spawnTime.num = cfgData.Count;
|
|
|
- spawnTime.Hp = cfgData.HPRatio;
|
|
|
- spawnTime.moveSpeed = cfgData.SpeedRatio;
|
|
|
- spawnTime.attack = cfgData.AttackRatio;
|
|
|
-
|
|
|
- layer.spawnTimes.Add(tile.id, spawnTime);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- UnityEngine.Debug.LogError($"\"{layer.name}\"波次中\"{cfgData.EnemyName}\"重复");
|
|
|
- }
|
|
|
- }
|
|
|
- // ----------------------------------------------------------------------------------------------------------------
|
|
|
+ // ----------------------------------------------------------------------------------------------------------------
|
|
|
}
|