Prechádzať zdrojové kódy

根据塔血量出怪

wgl 5 mesiacov pred
rodič
commit
1eb8cc4b01

+ 124 - 45
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapEdPopup.cs

@@ -129,6 +129,8 @@ public class GameMapEdPopup : PopupWindowContent
 			SaveExcelData(GameMapEditor.createEnemyExcelPath, list.index + 1);
         }
 		editorWindow.Close();
+		// 标记资源为脏数据,以便保存更改
+		EditorUtility.SetDirty(GameMapEditor.asset);
 	}
 
 	void SaveAsNewExcelData(string path)
@@ -171,33 +173,82 @@ public class GameMapEdPopup : PopupWindowContent
 					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;
+			float idFloat = 0f;
+			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);
-				ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", layer.duration.ToString());
+                if (layer.isFromTower)
+                {
+					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", layer.buildingId);
+					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"F{cell_row}", layer.buildingHp.ToString());
+				}
+                else
+                {
+                    if ((!layer.isTowerWave && !layer.isFromTower) || i == 0)
+                    {
+						ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"D{cell_row}", layer.duration.ToString());
+					}
+					
+				}
 
-				for(int j = 0;j< layer.spawnTimes.Count; j++)
+				if (!layer.isTowerWave)
+				{
+					if (layer.isFromTower)
+					{
+						idFloat += 0.01f;
+					}
+					else
+					{
+						idInt++;
+					}
+				}
+
+				for (int j = 0;j< layer.spawnTimes.Count; j++)
                 {
 					SpawnTime spawnTime = layer.spawnTimes[j];
-					if(spawnTime.pos.Count == 0)
-                    {
-						continue;
-                    }
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", (i + 1).ToString());
-					if(j != 0)
-                    {
-						for (int k = 0; k < 5; k++)
+					try
+					{
+						if (spawnTime.pos.Count == 0)
 						{
-							ExcelEditor.ModifyExcel(package, gameMap.showIdent, cell_row, 3 + k, "");
+							continue;
 						}
+					} 
+					catch (Exception e)
+                    {
+						Debug.Log(gameMap.layers.Length);
+						Debug.Log(i);
+						Debug.Log(layer.spawnTimes.Count);
+						Debug.LogError(j);
+						Debug.LogError(spawnTime);
+						Debug.LogError(spawnTime.pos);
+						Debug.LogException(e);
+                    }
+
+					if (layer.isTowerWave)
+					{
+						ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", "0");
+						ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"C{cell_row}", layer.name);
+					}
+					else if (layer.isFromTower)
+					{
+						ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", idFloat.ToString());
+					}
+					else
+					{
+						ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"B{cell_row}", idInt.ToString());
 					}
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"E{cell_row}", Asset.tileAsset.GetTile(spawnTime.id).name);
+
+					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++)
                     {
@@ -211,20 +262,27 @@ public class GameMapEdPopup : PopupWindowContent
                         }
 						posString += ",";
                     }
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"F{cell_row}",	posString);
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"G{cell_row}",	spawnTime.startTime.ToString());
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"H{cell_row}",	spawnTime.endTime.ToString());
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"I{cell_row}",	spawnTime.num.ToString());
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"J{cell_row}", (spawnTime.attack == 0?1:spawnTime.attack).ToString());
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"K{cell_row}", (spawnTime.moveSpeed == 0?1:spawnTime.moveSpeed).ToString());
-					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"L{cell_row}", (spawnTime.Hp == 0?1:spawnTime.Hp).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());
+					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"L{cell_row}", (spawnTime.attack == 0?1:spawnTime.attack).ToString());
+					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"M{cell_row}", (spawnTime.moveSpeed == 0?1:spawnTime.moveSpeed).ToString());
+					ExcelEditor.ModifyExcel(package, gameMap.showIdent, $"N{cell_row}", (spawnTime.Hp == 0?1:spawnTime.Hp).ToString());
 					cell_row++;
 				}
             }
-			ExcelEditor.RemoveExcelRows(package, gameMap.showIdent, cell_row, cell_row + 100);
-
+			try
+			{
+				package.Save();
+			}
+			catch (System.InvalidOperationException e)
+			{
+				EditorUtility.DisplayDialog("Error", $"出怪表未关闭或Sheet名重复,请重试", "OK");
+				Debug.LogException(e);
+				return;
+			}
 
-			package.Save();
 		}
 		Debug.Log($"\"{gameMap.showIdent}\"表保存完毕!");
 		Debug.Log("记得运行\"gen_code_json.bat\"更新数据!");
@@ -252,6 +310,7 @@ public class GameMapEdPopup : PopupWindowContent
 		//导入波次数据
 		GameMapEditor.currLayer = -1;
 		int mapId = -1;
+		float id = 0;
 		for (int i = 0; i < cfgCreateEnemy.Count; i++)
 		{
 			if (cfgCreateEnemy[i].WaveID == -1)
@@ -266,40 +325,60 @@ public class GameMapEdPopup : PopupWindowContent
 			}
 			if(mapId == mapIdx - 1)
             {
-				if(cfgCreateEnemy[i-1].WaveID == -1)
-                {
-					if(cfgCreateEnemy[i].WaveID != 1)
-                    {
-						EditorUtility.DisplayDialog("Error", $"\"{excelWorksheets[mapIdx - 1]}\"关卡第\"{cfgCreateEnemy[i].WaveID}\"波顺序有误", "OK");
-					}
-                }
-                else
-                {
-					if(cfgCreateEnemy[i].WaveID - cfgCreateEnemy[i-1].WaveID > 1 
-						|| cfgCreateEnemy[i].WaveID < cfgCreateEnemy[i - 1].WaveID)
-                    {
-						EditorUtility.DisplayDialog("Error", $"\"{excelWorksheets[mapIdx - 1]}\"关卡第\"{cfgCreateEnemy[i].WaveID}\"波顺序有误", "OK");
-					}
-                }
-				if(cfgCreateEnemy[i].WaveID > gameMap.layers.Length)
+				if (cfgCreateEnemy[i].WaveID == 0)
                 {
-					//波次第一行的波次数据
 					SingleCreateEnemyConfig singleCreateEnemyConfig = cfgCreateEnemy[i];
-					int id = singleCreateEnemyConfig.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; 
+					gameMapLayer.name = singleCreateEnemyConfig.WaveName;
 					gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
+					gameMapLayer.isTowerWave = true;
 
-					//波次第一行怪物数据
-					ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i],excelWorksheets[mapIdx - 1]);
+					ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
 				}
                 else
                 {
-					GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
-					ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
+					
+					if (cfgCreateEnemy[i].WaveID - cfgCreateEnemy[i - 1].WaveID > 1
+					|| cfgCreateEnemy[i].WaveID < cfgCreateEnemy[i - 1].WaveID)
+					{
+						Debug.Log(cfgCreateEnemy[i].WaveID);
+						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.isFromTower = true;
+							gameMapLayer.buildingId = singleCreateEnemyConfig.BuildingID;
+							gameMapLayer.buildingHp = singleCreateEnemyConfig.BuildingHP;
+						}
+                        else
+                        {
+							gameMapLayer.isFromTower = false;
+							gameMapLayer.duration = singleCreateEnemyConfig.WaveTime;
+						}
+						
+
+						//波次第一行怪物数据
+						ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
+					}
+					else
+					{
+						GameMapLayer gameMapLayer = gameMap.layers[gameMap.layers.Length - 1];
+						ReloadEnemyInWave(gameMapLayer, cfgCreateEnemy[i], excelWorksheets[mapIdx - 1]);
+					}
 				}
+
 			}
             else
             {

+ 23 - 3
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapEditor.cs

@@ -701,6 +701,7 @@ public class GameMapEditor : EditorWindow
 				}
 			}
 		}
+		EditorUtility.SetDirty(asset);
 		EditorGUILayout.EndVertical();
 	}
 
@@ -950,7 +951,22 @@ public class GameMapEditor : EditorWindow
 		// 显示并编辑图层名称
 		EditorGUI.BeginChangeCheck();
 		string addName = EditorGUILayout.TextField("波次名称", layer.name);
-		int duration = EditorGUILayout.IntField("下一波时间", layer.duration);
+		int duration = 0;
+		string buildingId = "";
+		float buildingHp = 0;
+		bool isTowerWave = EditorGUILayout.ToggleLeft("塔波", layer.isTowerWave);
+		bool isFromTower = EditorGUILayout.ToggleLeft("根据塔血量出", layer.isFromTower);
+		if (layer.isFromTower)
+		{
+			buildingId = EditorGUILayout.TextField("出怪建筑", layer.buildingId);
+			buildingHp = EditorGUILayout.FloatField("剩余血量", layer.buildingHp);
+		}
+		else
+		{
+			duration = EditorGUILayout.IntField("下一波时间", layer.duration);
+		}
+		
+		
 
 		EditorGUILayout.BeginVertical("box");
 		{
@@ -1055,10 +1071,14 @@ public class GameMapEditor : EditorWindow
 			//	tile.spawnTime[currLayer] = spawnTimeList;
 			//}
 			layer.name = addName;
+			layer.isFromTower = isFromTower;
 			layer.duration = duration;
-			EditorUtility.SetDirty(asset);
+			layer.buildingId = buildingId;
+			layer.buildingHp = buildingHp;
+			layer.isTowerWave = isTowerWave;
 		}
-
+		// 标记资源为脏数据,以便保存更改
+		EditorUtility.SetDirty(asset);
 		// 显示其他图层信息(根据需求扩展)
 		//EditorGUILayout.LabelField("Other Properties:");
 		//EditorGUILayout.LabelField($"Grid Size: {layer.gridSize}");

+ 4 - 0
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/GameMapLayer.cs

@@ -23,7 +23,11 @@ public class GameMapLayer
 {
 	/// <summary> The layer's grid of tile values. -1 is an empty tile, else a value related to GameMapTile.id will be present </summary>
 	public int[] grid = new int[0];
+	public bool isTowerWave;
+	public bool isFromTower;
 	public int duration;
+	public string buildingId;
+	public float buildingHp;
 	public string name;
 	public List<SpawnTime> spawnTimes = new List<SpawnTime>();
 

+ 10 - 14
ActionTowerDefense/Assets/Gen/SingleCreateEnemyConfig.cs

@@ -21,6 +21,8 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
         { if(!_json["WaveID"].IsNumber) { throw new SerializationException(); }  WaveID = _json["WaveID"]; }
         { if(!_json["WaveName"].IsString) { throw new SerializationException(); }  WaveName = _json["WaveName"]; }
         { if(!_json["WaveTime"].IsNumber) { throw new SerializationException(); }  WaveTime = _json["WaveTime"]; }
+        { if(!_json["BuildingID"].IsString) { throw new SerializationException(); }  BuildingID = _json["BuildingID"]; }
+        { if(!_json["BuildingHP"].IsNumber) { throw new SerializationException(); }  BuildingHP = _json["BuildingHP"]; }
         { if(!_json["EnemyName"].IsString) { throw new SerializationException(); }  EnemyName = _json["EnemyName"]; }
         { var __json0 = _json["Position"]; if(!__json0.IsArray) { throw new SerializationException(); } Position = new System.Collections.Generic.List<int>(__json0.Count); foreach(JSONNode __e0 in __json0.Children) { int __v0;  { if(!__e0.IsNumber) { throw new SerializationException(); }  __v0 = __e0; }  Position.Add(__v0); }   }
         { if(!_json["StartTime"].IsNumber) { throw new SerializationException(); }  StartTime = _json["StartTime"]; }
@@ -29,17 +31,16 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
         { if(!_json["AttackRatio"].IsNumber) { throw new SerializationException(); }  AttackRatio = _json["AttackRatio"]; }
         { if(!_json["SpeedRatio"].IsNumber) { throw new SerializationException(); }  SpeedRatio = _json["SpeedRatio"]; }
         { if(!_json["HPRatio"].IsNumber) { throw new SerializationException(); }  HPRatio = _json["HPRatio"]; }
-        { if(!_json["Type"].IsNumber) { throw new SerializationException(); }  Type = _json["Type"]; }
-        { if(!_json["BuildingHP"].IsNumber) { throw new SerializationException(); }  BuildingHP = _json["BuildingHP"]; }
-        { if(!_json["BuildingID"].IsNumber) { throw new SerializationException(); }  BuildingID = _json["BuildingID"]; }
         PostInit();
     }
 
-    public SingleCreateEnemyConfig(int WaveID, string WaveName, int WaveTime, string EnemyName, System.Collections.Generic.List<int> Position, int StartTime, int EndTime, int Count, float AttackRatio, float SpeedRatio, float HPRatio, int Type, float BuildingHP, int BuildingID ) 
+    public SingleCreateEnemyConfig(float WaveID, string WaveName, int WaveTime, string BuildingID, float BuildingHP, string EnemyName, System.Collections.Generic.List<int> Position, int StartTime, int EndTime, int Count, float AttackRatio, float SpeedRatio, float HPRatio ) 
     {
         this.WaveID = WaveID;
         this.WaveName = WaveName;
         this.WaveTime = WaveTime;
+        this.BuildingID = BuildingID;
+        this.BuildingHP = BuildingHP;
         this.EnemyName = EnemyName;
         this.Position = Position;
         this.StartTime = StartTime;
@@ -48,9 +49,6 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
         this.AttackRatio = AttackRatio;
         this.SpeedRatio = SpeedRatio;
         this.HPRatio = HPRatio;
-        this.Type = Type;
-        this.BuildingHP = BuildingHP;
-        this.BuildingID = BuildingID;
         PostInit();
     }
 
@@ -62,7 +60,7 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
     /// <summary>
     /// 表格参数:
     /// </summary>
-    public int WaveID { get; private set; }
+    public float WaveID { get; private set; }
     /// <summary>
     /// 宽:
     /// </summary>
@@ -71,6 +69,8 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
     /// 140
     /// </summary>
     public int WaveTime { get; private set; }
+    public string BuildingID { get; private set; }
+    public float BuildingHP { get; private set; }
     public string EnemyName { get; private set; }
     public System.Collections.Generic.List<int> Position { get; private set; }
     public int StartTime { get; private set; }
@@ -79,9 +79,6 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
     public float AttackRatio { get; private set; }
     public float SpeedRatio { get; private set; }
     public float HPRatio { get; private set; }
-    public int Type { get; private set; }
-    public float BuildingHP { get; private set; }
-    public int BuildingID { get; private set; }
 
     public const int __ID__ = 691467974;
     public override int GetTypeId() => __ID__;
@@ -101,6 +98,8 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
         + "WaveID:" + WaveID + ","
         + "WaveName:" + WaveName + ","
         + "WaveTime:" + WaveTime + ","
+        + "BuildingID:" + BuildingID + ","
+        + "BuildingHP:" + BuildingHP + ","
         + "EnemyName:" + EnemyName + ","
         + "Position:" + Bright.Common.StringUtil.CollectionToString(Position) + ","
         + "StartTime:" + StartTime + ","
@@ -109,9 +108,6 @@ public sealed partial class SingleCreateEnemyConfig :  Bright.Config.BeanBase
         + "AttackRatio:" + AttackRatio + ","
         + "SpeedRatio:" + SpeedRatio + ","
         + "HPRatio:" + HPRatio + ","
-        + "Type:" + Type + ","
-        + "BuildingHP:" + BuildingHP + ","
-        + "BuildingID:" + BuildingID + ","
         + "}";
     }
     

+ 64 - 18
ActionTowerDefense/Assets/Scripts/EnemyCreater.cs

@@ -18,6 +18,9 @@ public class EnemyCreater : MonoBehaviour
     public Dictionary<string, List<GameObject>> buildingDic;
     private int curLevel;
     public Vector2Int idRange;  //当前关卡为出怪表[x,y]行
+    public Dictionary<string, EnemyTower> enemyCreateTowerDic;
+    public List<string> createdEnemyTower = new();
+    public List<float> createdEnemyTowerHp = new();
 
     private void Awake()
     {
@@ -32,6 +35,7 @@ public class EnemyCreater : MonoBehaviour
         }
         enemyDic = new Dictionary<string, List<Enemy>>();
         buildingDic = new Dictionary<string, List<GameObject>>();
+        enemyCreateTowerDic = new Dictionary<string, EnemyTower>();
     }
 
     private void Start()
@@ -41,7 +45,7 @@ public class EnemyCreater : MonoBehaviour
         cfgCreateEnemy = GameManager.instance.allCfgData.CfgCreateEnemy.DataList;
         createdEnemy = new List<bool>();
         float waveTime = 0;
-        int id = 0;
+        float id = 0;
         int mapId = 1;
         int start = -1;
         int end = -1;
@@ -65,12 +69,42 @@ public class EnemyCreater : MonoBehaviour
             }
             if (haveStart)
             {
-                createdEnemy.Add(false);
-                createEnemyTime.Add(new List<float> { waveTime + cfgCreateEnemy[i].StartTime, waveTime + cfgCreateEnemy[i].EndTime });
-                if (id != cfgCreateEnemy[i].WaveID)
+                if(cfgCreateEnemy[i].WaveID == 0)
                 {
-                    waveTime += cfgCreateEnemy[i].WaveTime;
-                    id = cfgCreateEnemy[i].WaveID;
+                    createdEnemy.Add(false);
+                    createEnemyTime.Add(new List<float> { cfgCreateEnemy[i].StartTime, cfgCreateEnemy[i].EndTime });
+                    createdEnemyTower.Add("");
+                    createdEnemyTowerHp.Add(0);
+                    waveTime = cfgCreateEnemy[i].WaveTime;
+                }
+                else if(cfgCreateEnemy[i].WaveID < 1)
+                {
+                    createdEnemy.Add(false);
+                    createEnemyTime.Add(new List<float> { 0,0});
+                    if(id != cfgCreateEnemy[i].WaveID)
+                    {
+                        createdEnemyTower.Add(cfgCreateEnemy[i].BuildingID);
+                        createdEnemyTowerHp.Add(cfgCreateEnemy[i].BuildingHP);
+                        id = cfgCreateEnemy[i].WaveID;
+                    }
+                    else
+                    {
+                        int l = createdEnemyTower.Count;
+                        createdEnemyTower.Add(createdEnemyTower[l - 1]);
+                        createdEnemyTowerHp.Add(createdEnemyTowerHp[l - 1]);
+                    }
+                }
+                else
+                {
+                    createdEnemy.Add(false);
+                    createEnemyTime.Add(new List<float> { waveTime + cfgCreateEnemy[i].StartTime, waveTime + cfgCreateEnemy[i].EndTime });
+                    createdEnemyTower.Add("");
+                    createdEnemyTowerHp.Add(0);
+                    if (id != cfgCreateEnemy[i].WaveID)
+                    {
+                        waveTime += cfgCreateEnemy[i].WaveTime;
+                        id = cfgCreateEnemy[i].WaveID;
+                    }
                 }
             }
         }
@@ -79,7 +113,6 @@ public class EnemyCreater : MonoBehaviour
             end = cfgCreateEnemy.Count - 1;
         }
         idRange = new Vector2Int(start, end);
-
         //把所有怪物prefab生成一遍防止后面初次生成卡顿
         //foreach (var item in createCharacter)
         //{
@@ -97,23 +130,35 @@ public class EnemyCreater : MonoBehaviour
     }
     public void OnGameTimeChange(float gameTime)
     {
-        int waveId = -1;
-        int waveIndex = -1;
         for (int i = idRange[0] + 1; i <= idRange[1]; i++)
         {
             int id = i - idRange[0] - 1;
-            if(waveId != cfgCreateEnemy[i].WaveID)
+            if (!createdEnemy[id])
             {
-                waveId = cfgCreateEnemy[i].WaveID;
-                waveIndex = i;
-            }
-            if (!createdEnemy[id] && createEnemyTime[id][0] <= gameTime)
-            {
-                createdEnemy[id] = true;
-                StartCreateEnemy(cfgCreateEnemy[i]);
+                if (cfgCreateEnemy[i].WaveID == 0)
+                {
+                    createdEnemy[id] = true;
+                    StartCreateEnemy(cfgCreateEnemy[i]);
+                }
+                else if(cfgCreateEnemy[i].WaveID < 1)
+                {
+                    EnemyTower enemyTower = enemyCreateTowerDic[createdEnemyTower[id]];
+                    if (enemyTower != null && enemyTower.hp <= enemyTower.totalHp * createdEnemyTowerHp[id]/100f)
+                    {
+                        createdEnemy[id] = true;
+                        StartCreateEnemy(cfgCreateEnemy[i]);
+                    }
+                }
+                else
+                {
+                    if (createEnemyTime[id][0] <= gameTime)
+                    {
+                        createdEnemy[id] = true;
+                        StartCreateEnemy(cfgCreateEnemy[i]);
+                    }
+                }
             }
         }
-        
     }
 
     //每一行怪
@@ -206,6 +251,7 @@ public class EnemyCreater : MonoBehaviour
                 buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
             }
             buildingDic[cfgEnemy.Name].Add(enemyObj);
+            enemyCreateTowerDic[cfgCreateEnemy.WaveName] = enemyTower;
         }
         else if(cfgEnemy.Type == "Enemy")
         {

+ 188 - 121
ActionTowerDefense/GenerateDatas/json/cfgcreateenemy.json

@@ -3,6 +3,8 @@
     "WaveID": -1,
     "WaveName": "占位行",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "",
     "Position": [],
     "StartTime": 0,
@@ -10,15 +12,14 @@
     "Count": 0,
     "AttackRatio": 0,
     "SpeedRatio": 0,
-    "HPRatio": 0,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 0
   },
   {
     "WaveID": 1,
     "WaveName": "塔波",
     "WaveTime": 1,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "敌方防御塔",
     "Position": [
       1,
@@ -39,15 +40,14 @@
     "Count": 6,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 1,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "防御塔",
     "Position": [
       108,
@@ -64,15 +64,14 @@
     "Count": 4,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 2,
     "WaveName": "1",
     "WaveTime": 10,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "大猪",
     "Position": [
       55,
@@ -83,15 +82,14 @@
     "Count": 3,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 2,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "小猪",
     "Position": [
       54,
@@ -102,15 +100,14 @@
     "Count": 15,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 3,
     "WaveName": "1.1",
     "WaveTime": 5,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "幽灵头",
     "Position": [
       5,
@@ -121,15 +118,14 @@
     "Count": 40,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 4,
     "WaveName": "2",
     "WaveTime": 15,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "小猪",
     "Position": [
       50,
@@ -140,15 +136,14 @@
     "Count": 20,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 4,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "道士",
     "Position": [
       48,
@@ -159,15 +154,14 @@
     "Count": 5,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 4,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "大猪",
     "Position": [
       54,
@@ -178,15 +172,14 @@
     "Count": 3,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 5,
     "WaveName": "3",
     "WaveTime": 10,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "飞胖",
     "Position": [
       50,
@@ -197,15 +190,14 @@
     "Count": 3,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 5,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "老鬼头",
     "Position": [
       47,
@@ -216,15 +208,14 @@
     "Count": 10,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 5,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "幽灵头",
     "Position": [
       45,
@@ -235,15 +226,14 @@
     "Count": 15,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 6,
     "WaveName": "3.1",
     "WaveTime": 5,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "幽灵头",
     "Position": [
       4,
@@ -254,15 +244,14 @@
     "Count": 30,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 6,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "老鬼头",
     "Position": [
       6,
@@ -273,15 +262,14 @@
     "Count": 20,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 7,
     "WaveName": "4",
     "WaveTime": 15,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "小猪",
     "Position": [
       49,
@@ -292,15 +280,14 @@
     "Count": 15,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 7,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "道士",
     "Position": [
       44,
@@ -311,15 +298,14 @@
     "Count": 5,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 7,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "虾兵",
     "Position": [
       47,
@@ -330,15 +316,14 @@
     "Count": 15,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 8,
     "WaveName": "5",
     "WaveTime": 1,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "虾兵",
     "Position": [
       46,
@@ -349,15 +334,14 @@
     "Count": 15,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 8,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "老鬼头",
     "Position": [
       44,
@@ -368,15 +352,14 @@
     "Count": 10,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 8,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "大猪",
     "Position": [
       49,
@@ -387,15 +370,14 @@
     "Count": 3,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 8,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "道士",
     "Position": [
       45,
@@ -406,15 +388,14 @@
     "Count": 5,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 8,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "幽灵头",
     "Position": [
       45,
@@ -425,15 +406,14 @@
     "Count": 15,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 8,
     "WaveName": "",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "飞胖",
     "Position": [
       48,
@@ -444,15 +424,14 @@
     "Count": 3,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": 9,
     "WaveName": "5.1",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "飞胖",
     "Position": [
       5,
@@ -463,15 +442,14 @@
     "Count": 3,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
   },
   {
     "WaveID": -1,
     "WaveName": "占位行",
     "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
     "EnemyName": "",
     "Position": [],
     "StartTime": 0,
@@ -479,47 +457,136 @@
     "Count": 0,
     "AttackRatio": 0,
     "SpeedRatio": 0,
-    "HPRatio": 0,
-    "Type": 0,
+    "HPRatio": 0
+  },
+  {
+    "WaveID": 0,
+    "WaveName": "塔1",
+    "WaveTime": 5,
+    "BuildingID": "",
     "BuildingHP": 0,
-    "BuildingID": 0
+    "EnemyName": "敌方防御塔",
+    "Position": [
+      1,
+      1
+    ],
+    "StartTime": 0,
+    "EndTime": 0,
+    "Count": 1,
+    "AttackRatio": 0,
+    "SpeedRatio": 1,
+    "HPRatio": 1
   },
   {
-    "WaveID": 1,
-    "WaveName": "第一波",
-    "WaveTime": 1,
-    "EnemyName": "飞胖",
+    "WaveID": 0,
+    "WaveName": "塔2",
+    "WaveTime": 0,
+    "BuildingID": "",
+    "BuildingHP": 0,
+    "EnemyName": "敌方防御塔",
     "Position": [
-      8,
-      9
+      10,
+      1
     ],
-    "StartTime": 1,
-    "EndTime": 1,
+    "StartTime": 0,
+    "EndTime": 0,
     "Count": 1,
-    "AttackRatio": 1,
+    "AttackRatio": 0,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
+    "HPRatio": 1
+  },
+  {
+    "WaveID": 0,
+    "WaveName": "塔3",
+    "WaveTime": 0,
+    "BuildingID": "",
     "BuildingHP": 0,
-    "BuildingID": 0
+    "EnemyName": "敌方防御塔",
+    "Position": [
+      15,
+      1
+    ],
+    "StartTime": 0,
+    "EndTime": 0,
+    "Count": 1,
+    "AttackRatio": 0,
+    "SpeedRatio": 1,
+    "HPRatio": 1
   },
   {
-    "WaveID": 1,
+    "WaveID": 0.01,
+    "WaveName": "塔1波80",
+    "WaveTime": 0,
+    "BuildingID": "塔1",
+    "BuildingHP": 80,
+    "EnemyName": "飞胖",
+    "Position": [
+      1,
+      1,
+      2,
+      2
+    ],
+    "StartTime": 0,
+    "EndTime": 10,
+    "Count": 10,
+    "AttackRatio": 2,
+    "SpeedRatio": 1,
+    "HPRatio": 1
+  },
+  {
+    "WaveID": 0.01,
     "WaveName": "",
     "WaveTime": 0,
-    "EnemyName": "大猪",
+    "BuildingID": "",
+    "BuildingHP": 0,
+    "EnemyName": "小猪",
     "Position": [
-      6,
+      2,
+      1,
+      3,
+      2
+    ],
+    "StartTime": 0,
+    "EndTime": 10,
+    "Count": 10,
+    "AttackRatio": 2,
+    "SpeedRatio": 1,
+    "HPRatio": 1
+  },
+  {
+    "WaveID": 0.02,
+    "WaveName": "塔1波50",
+    "WaveTime": 0,
+    "BuildingID": "塔1",
+    "BuildingHP": 50,
+    "EnemyName": "小猪",
+    "Position": [
+      2,
       1
     ],
-    "StartTime": 1,
-    "EndTime": 1,
-    "Count": 1,
+    "StartTime": 0,
+    "EndTime": 10,
+    "Count": 10,
     "AttackRatio": 1,
     "SpeedRatio": 1,
-    "HPRatio": 1,
-    "Type": 0,
-    "BuildingHP": 0,
-    "BuildingID": 0
+    "HPRatio": 1
+  },
+  {
+    "WaveID": 0.03,
+    "WaveName": "塔2波",
+    "WaveTime": 0,
+    "BuildingID": "塔2",
+    "BuildingHP": 70,
+    "EnemyName": "小猪",
+    "Position": [
+      2,
+      1
+    ],
+    "StartTime": 0,
+    "EndTime": 10,
+    "Count": 10,
+    "AttackRatio": 1,
+    "SpeedRatio": 1,
+    "HPRatio": 1
   }
 ]

BIN
ActionTowerDefense/Luban/Config/Datas/出怪表.xlsx


BIN
ActionTowerDefense/Luban/Config/Datas/怪物表.xlsx