wgl 7 月之前
父节点
当前提交
a85ddd754c

+ 44 - 20
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/Editor/GameMapEditor.cs

@@ -713,14 +713,14 @@ public class GameMapEditor : EditorWindow
 				if (GUI.Button(r, GC_rem, EditorStyles.miniButtonRight))
 				{
 					Undo.RecordObject(asset, "Remove Layer");
-					foreach (GameMapTile tile in asset.tileAsset.tiles)
-					{
-						if (currLayer<tile.spawnTime.Count && tile.spawnTime[currLayer].curLayer == asset.maps[mapIdx].layers[currLayer].name)
-						{
-							tile.spawnTime.RemoveAt(currLayer);
-						}
-
-					}
+					//foreach (GameMapTile tile in asset.tileAsset.tiles)
+					//{
+					//	if (currLayer<tile.spawnTime.Count && tile.spawnTime[currLayer].curLayer == asset.maps[mapIdx].layers[currLayer].name)
+					//	{
+					//		tile.spawnTime.RemoveAt(currLayer);
+					//	}
+
+					//}
 					ArrayUtility.RemoveAt(ref asset.maps[mapIdx].layers, currLayer);
 
 					EditorUtility.SetDirty(asset);
@@ -735,10 +735,10 @@ public class GameMapEditor : EditorWindow
 					Undo.RecordObject(asset, "Add Layer");
 					ArrayUtility.Add(ref asset.maps[mapIdx].layers, new GameMapLayer());
 					asset.maps[mapIdx].InitLayer(asset.maps[mapIdx].layers.Length);
-					foreach (GameMapTile tile in asset.tileAsset.tiles)
-					{
-						tile.spawnTime.Add(new SpawnTimeList());
-					}
+					//foreach (GameMapTile tile in asset.tileAsset.tiles)
+					//{
+					//	tile.spawnTime.Add(new SpawnTimeList());
+					//}
 					EditorUtility.SetDirty(asset);
 					doRepaint = true;
 				}
@@ -833,21 +833,45 @@ public class GameMapEditor : EditorWindow
 
 		// 显示并编辑图层名称
 		EditorGUI.BeginChangeCheck();
-		string addName = EditorGUILayout.TextField("Name", layer.name);
+		string addName = EditorGUILayout.TextField("Wave Name", layer.name);
 		
-		int duration = EditorGUILayout.IntField("Duration", layer.duration);
+		int duration = EditorGUILayout.IntField("Next Wave", layer.duration);
 		float addHp = EditorGUILayout.FloatField("Hp", layer.Hp);
 		float addMoveSpeed = EditorGUILayout.FloatField("MoveSpeed", layer.moveSpeed);
 		float addAttack = EditorGUILayout.FloatField("Attack", layer.attack);
-		if (EditorGUI.EndChangeCheck())
+
+		EditorGUILayout.BeginVertical("box");
 		{
-			Undo.RecordObject(asset, "Change Layer Information");
-			foreach (GameMapTile tile in asset.tileAsset.tiles)
+			EditorGUILayout.LabelField("Spawn Times", EditorStyles.boldLabel);
+			GUILayout.Space(5f);
+			for (int i = 0; i < layer.spawnTimes.Count; i++)
 			{
-				SpawnTimeList spawnTimeList = tile.spawnTime[currLayer];
-				spawnTimeList.curLayer = addName;
-				tile.spawnTime[currLayer] = spawnTimeList;
+				SpawnTime spawnTime = layer.spawnTimes[i];
+				spawnTime.name = EditorGUILayout.TextField("Tile Name", layer.spawnTimes[i].name);
+				spawnTime.startTime = EditorGUILayout.IntField("Start Time", layer.spawnTimes[i].startTime);
+				spawnTime.endTime = EditorGUILayout.IntField("End Time", layer.spawnTimes[i].endTime);
+				spawnTime.num = EditorGUILayout.IntField("Number", layer.spawnTimes[i].num);
+				layer.spawnTimes[i] = spawnTime;
+
+				if (GUILayout.Button("Remove"))
+				{
+					layer.spawnTimes.RemoveAt(i);
+					i--;
+				}
 			}
+		}
+		EditorGUILayout.EndVertical();
+
+
+		if (EditorGUI.EndChangeCheck())
+		{
+			Undo.RecordObject(asset, "Change Layer Information");
+			//foreach (GameMapTile tile in asset.tileAsset.tiles)
+			//{
+			//	SpawnTimeList spawnTimeList = tile.spawnTime[currLayer];
+			//	spawnTimeList.curLayer = addName;
+			//	tile.spawnTime[currLayer] = spawnTimeList;
+			//}
 			layer.name = addName;
 			layer.duration = duration;
 			layer.Hp = addHp;

+ 11 - 2
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/GameMapLayer.cs

@@ -1,6 +1,14 @@
-using System.Collections.Generic;
+using System;
+using System.Collections.Generic;
 using UnityEngine;
-
+[Serializable]
+public struct SpawnTime
+{
+	public string name;
+	public int startTime;
+	public int endTime;
+	public int num;
+}
 
 /// <summary>
 /// A layer consists of a series of values in a grid.
@@ -16,6 +24,7 @@ public class GameMapLayer
 	public float Hp = 1;
 	public float moveSpeed = 1;
 	public float attack = 1;
+	public List<SpawnTime> spawnTimes;
 
 
 	// ----------------------------------------------------------------------------------------------------------------

+ 0 - 19
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/GameMapTile.cs

@@ -3,23 +3,6 @@ using UnityEditor;
 using System;
 using System.Collections.Generic;
 
-[Serializable]
-public struct SpawnTime
-{
-	public int startTime;
-	public int endTime;
-	public int num;
-}
-
-[Serializable]
-public struct SpawnTimeList
-{
-	[HideInInspector]
-	public string curLayer;
-	public SpawnTime[] spawnTimes;
-}
-
-
 [Serializable]
 public struct Parameter
 {
@@ -65,7 +48,6 @@ public class GameMapTile
 	[GameMapTilePreview] public Color color = Color.white;
 	public Vector2 radius;
 	public string name;
-	public List<SpawnTimeList> spawnTime;
 	[HideInInspector]public int index = -1;
 	[HideInInspector]public bool hasOut = false;
 	public Parameter parameter;
@@ -85,7 +67,6 @@ public class GameMapTile
 		t.color = color;
 		t.radius = radius;
 		t.name = name;
-		t.spawnTime = spawnTime;
 		t.index = index;
 		t.hasOut = hasOut;
 	}

+ 11 - 11
ActionTowerDefense/Assets/GameLevelEditor/GameMap/Sample/Scripts/Main.cs

@@ -176,17 +176,17 @@ public class Main : MonoBehaviour
 						t.hasOut = true;
 						ts.Add(t);
 						buttonTest.AddSwimLane(t);
-						foreach(SpawnTimeList spawnTimes in t.spawnTime)
-                        {
-							if(spawnTimes.curLayer == map.layers[i - 1].name)
-                            {
-								for (int j = 0; j < spawnTimes.spawnTimes.Length; j++)
-								{
-									buttonTest.AddEventToTimeline(spawnTimes.spawnTimes[j], t.index, t.color, startTime);
-								}
-								break;
-                            }
-                        }
+						//foreach(SpawnTimeList spawnTimes in t.spawnTime)
+      //                  {
+						//	if(spawnTimes.curLayer == map.layers[i - 1].name)
+      //                      {
+						//		for (int j = 0; j < spawnTimes.spawnTimes.Length; j++)
+						//		{
+						//			buttonTest.AddEventToTimeline(spawnTimes.spawnTimes[j], t.index, t.color, startTime);
+						//		}
+						//		break;
+      //                      }
+      //                  }
 
 					}
 

文件差异内容过多而无法显示
+ 0 - 0
ActionTowerDefense/Assets/GameLevelEditor/maps.asset


+ 0 - 72
ActionTowerDefense/Assets/GameLevelEditor/tiles.asset

@@ -21,11 +21,6 @@ MonoBehaviour:
     color: {r: 0.17626214, g: 1, b: 0, a: 0.39215687}
     radius: {x: 0, y: 0}
     name: "\u9632\u5FA1\u5854"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes: []
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:
@@ -42,11 +37,6 @@ MonoBehaviour:
     color: {r: 1, g: 0, b: 0, a: 0.39215687}
     radius: {x: 0, y: 0}
     name: "\u654C\u65B9\u9632\u5FA1\u5854"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes: []
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 1
     parameter:
@@ -63,14 +53,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 2, y: 0}
     name: "\u5C0F\u732A"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes:
-      - startTime: 0
-        endTime: 0
-        num: 0
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:
@@ -87,11 +69,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 2, y: 0}
     name: "\u9053\u58EB"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes: []
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 1
     parameter:
@@ -108,11 +85,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 2, y: 0}
     name: "\u5927\u732A"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes: []
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:
@@ -129,11 +101,6 @@ MonoBehaviour:
     color: {r: 0.96931714, g: 0.9811321, b: 0.96724814, a: 1}
     radius: {x: 2, y: 3}
     name: "\u5E7D\u7075\u5934"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes: []
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:
@@ -150,11 +117,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 2, y: 0}
     name: "\u867E\u5175"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes: []
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:
@@ -171,17 +133,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 0, y: 0}
     name: "\u8001\u68D2\u5B50"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes:
-      - startTime: 2
-        endTime: 4
-        num: 3
-    - curLayer: 2
-      spawnTimes:
-      - startTime: 0
-        endTime: 0
-        num: 0
     index: -1
     hasOut: 0
     parameter:
@@ -198,21 +149,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 0, y: 0}
     name: "\u8001\u5F13\u5175"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes:
-      - startTime: 2
-        endTime: 4
-        num: 3
-    - curLayer: 2
-      spawnTimes:
-      - startTime: 0
-        endTime: 0
-        num: 0
-    - curLayer: 
-      spawnTimes: []
-    - curLayer: 
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:
@@ -229,14 +165,6 @@ MonoBehaviour:
     color: {r: 1, g: 1, b: 1, a: 1}
     radius: {x: 0, y: 0}
     name: "\u8001\u80D6\u5B50"
-    spawnTime:
-    - curLayer: 1
-      spawnTimes:
-      - startTime: 2
-        endTime: 4
-        num: 3
-    - curLayer: 2
-      spawnTimes: []
     index: -1
     hasOut: 0
     parameter:

+ 19 - 19
ActionTowerDefense/Assets/Scripts/EnemyCreater.cs

@@ -83,25 +83,25 @@ public class EnemyCreater : MonoBehaviour
                     
                     GameMapTile t = mapsAsset.tileAsset.GetTile(grid[idx++]);
                     if (t == null) continue;
-                    foreach (SpawnTimeList spawnTimes in t.spawnTime)
-                    {
-                        if (spawnTimes.curLayer == map.layers[i - 1].name)
-                        {
-                            for (int j = 0; j < spawnTimes.spawnTimes.Length; j++)
-                            {
-                                CreaterControl createrControl = new();
-                                createrControl.isCreated = false;
-                                createrControl.tile = t;
-                                createrControl.spawnTime = spawnTimes.spawnTimes[j];
-                                createrControl.pos = new Vector3(x + UnityEngine.Random.Range(-t.radius.x / 2, t.radius.x / 2), y + UnityEngine.Random.Range(-t.radius.y / 2, t.radius.y / 2), 0);
-                                createrControl.waveStartTime = startTime;
-                                createrControl.mapLayer = map.layers[i - 1];
-                                createCharacter.Add(createrControl);
-
-                            }
-                            break;
-                        }
-                    }
+                    //foreach (SpawnTimeList spawnTimes in t.spawnTime)
+                    //{
+                    //    if (spawnTimes.curLayer == map.layers[i - 1].name)
+                    //    {
+                    //        for (int j = 0; j < spawnTimes.spawnTimes.Length; j++)
+                    //        {
+                    //            CreaterControl createrControl = new();
+                    //            createrControl.isCreated = false;
+                    //            createrControl.tile = t;
+                    //            createrControl.spawnTime = spawnTimes.spawnTimes[j];
+                    //            createrControl.pos = new Vector3(x + UnityEngine.Random.Range(-t.radius.x / 2, t.radius.x / 2), y + UnityEngine.Random.Range(-t.radius.y / 2, t.radius.y / 2), 0);
+                    //            createrControl.waveStartTime = startTime;
+                    //            createrControl.mapLayer = map.layers[i - 1];
+                    //            createCharacter.Add(createrControl);
+
+                    //        }
+                    //        break;
+                    //    }
+                    //}
                 }
             }
             startTime += map.layers[i - 1].duration;

部分文件因为文件数量过多而无法显示