wgl 7 місяців тому
батько
коміт
3b2fc088c7

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

@@ -769,7 +769,7 @@ public class GameMapEditor : EditorWindow
 			layerHidden[idx + 1] = !GUILayout.Toggle(!layerHidden[idx + 1], GC_Viz, EditorStyles.miniButton, GUILayout.Width(25));
 
 			// 选择图层
-			if (GUILayout.Toggle((idx == currLayer), asset.maps[mapIdx].layers[idx].name, EditorStyles.miniButton))
+			if (GUILayout.Toggle((idx == currLayer), asset.maps[mapIdx].layers[idx].id.ToString(), EditorStyles.miniButton))
 			{
 				currLayer = idx;
 				doRepaint = true; // 触发重绘以显示图层信息
@@ -819,7 +819,7 @@ public class GameMapEditor : EditorWindow
 
 		// 显示并编辑图层名称
 		EditorGUI.BeginChangeCheck();
-		string addName = EditorGUILayout.TextField("Name", layer.name);
+		int addId = EditorGUILayout.IntField("Id", layer.id);
 		int duration = EditorGUILayout.IntField("Duration", layer.duration);
 		float addHp = EditorGUILayout.FloatField("Hp", layer.Hp);
 		float addMoveSpeed = EditorGUILayout.FloatField("MoveSpeed", layer.moveSpeed);
@@ -827,7 +827,7 @@ public class GameMapEditor : EditorWindow
 		if (EditorGUI.EndChangeCheck())
 		{
 			Undo.RecordObject(asset, "Change Layer Information");
-			layer.name = addName;
+			layer.id = addId;
 			layer.duration = duration;
 			layer.Hp = addHp;
 			layer.moveSpeed = addMoveSpeed;

+ 1 - 1
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/GameMapLayer.cs

@@ -12,7 +12,7 @@ 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 int duration;
-	public string name;
+	public int id;
 	public float Hp = 1;
 	public float moveSpeed = 1;
 	public float attack = 1;

+ 12 - 2
ActionTowerDefense/Assets/GameLevelEditor/GameMap/CoreScripts/GameMapTile.cs

@@ -1,16 +1,24 @@
 using UnityEngine;
 using UnityEditor;
 using System;
+using System.Collections.Generic;
 
 [Serializable]
 public struct SpawnTime
 {
-	public int curLayer;
 	public int startTime;
 	public int endTime;
 	public int num;
 }
 
+[Serializable]
+public struct SpawnTimeList
+{
+	public int curLayer;
+	public SpawnTime[] spawnTimes;
+}
+
+
 [Serializable]
 public struct Parameter
 {
@@ -56,10 +64,12 @@ public class GameMapTile
 	[GameMapTilePreview] public Color color = Color.white;
 	public Vector2 radius;
 	public string name;
-	public SpawnTime[] spawnTime;
+	public List<SpawnTimeList> spawnTime;
 	[HideInInspector]public int index = -1;
 	[HideInInspector]public bool hasOut = false;
 	public Parameter parameter;
+
+	
 	
 
 	// ----------------------------------------------------------------------------------------------------------------

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

@@ -176,10 +176,18 @@ public class Main : MonoBehaviour
 						t.hasOut = true;
 						ts.Add(t);
 						buttonTest.AddSwimLane(t);
-						for (int j = 0; j < t.spawnTime.Length; j++)
-						{
-							buttonTest.AddEventToTimeline(t.spawnTime[j], t.index, t.color, startTime);
-						}
+						foreach(SpawnTimeList spawnTimes in t.spawnTime)
+                        {
+							if(spawnTimes.curLayer == map.layers[i - 1].id)
+                            {
+								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


+ 12 - 6
ActionTowerDefense/Assets/GameLevelEditor/tiles.asset

@@ -56,9 +56,16 @@ MonoBehaviour:
     radius: {x: 1, y: 1}
     name: "\u5C0F\u732A"
     spawnTime:
-    - startTime: 3
-      endTime: 20
-      num: 20
+    - curLayer: 2
+      spawnTimes:
+      - startTime: 3
+        endTime: 5
+        num: 2
+    - curLayer: 1
+      spawnTimes:
+      - startTime: 3
+        endTime: 5
+        num: 2
     index: -1
     hasOut: 1
     parameter:
@@ -76,9 +83,8 @@ MonoBehaviour:
     radius: {x: 1, y: 2}
     name: "\u9053\u58EB"
     spawnTime:
-    - startTime: 3
-      endTime: 20
-      num: 20
+    - curLayer: 0
+      spawnTimes: []
     index: -1
     hasOut: 1
     parameter:

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

@@ -13,7 +13,7 @@ public struct CreaterControl
     public bool isCreated;
     public GameMapTile tile;
     public GameMapLayer mapLayer;
-    public int spawnTimeId;
+    public SpawnTime spawnTime;
     public int waveStartTime;
     public Vector3 pos;
 }
@@ -83,20 +83,24 @@ public class EnemyCreater : MonoBehaviour
                     
                     GameMapTile t = mapsAsset.tileAsset.GetTile(grid[idx++]);
                     if (t == null) continue;
-                    for (int j = 0; j < t.spawnTime.Length; j++)
+                    foreach (SpawnTimeList spawnTimes in t.spawnTime)
                     {
-                        if(t.spawnTime[j].curLayer == i - 1)
+                        if (spawnTimes.curLayer == map.layers[i - 1].id)
                         {
-                            CreaterControl createrControl = new();
-                            createrControl.isCreated = false;
-                            createrControl.tile = t;
-                            createrControl.spawnTimeId = 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);
+                            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;
                         }
-
                     }
                 }
             }
@@ -108,8 +112,7 @@ public class EnemyCreater : MonoBehaviour
     {
         for (int i = 0; i < createCharacter.Count; i++)
         {
-            GameMapTile gameMapTile = createCharacter[i].tile;
-            if (!createCharacter[i].isCreated && gameMapTile.spawnTime[createCharacter[i].spawnTimeId].startTime + createCharacter[i].waveStartTime <= gameTime)
+            if (!createCharacter[i].isCreated && createCharacter[i].spawnTime.startTime + createCharacter[i].waveStartTime <= gameTime)
             {
                 CreaterControl createrControl = createCharacter[i];
                 createrControl.isCreated = true;
@@ -121,7 +124,7 @@ public class EnemyCreater : MonoBehaviour
 
     public async void StartCreateEnemy(CreaterControl createrControl)
     {
-        SpawnTime spawnTime = createrControl.tile.spawnTime[createrControl.spawnTimeId];
+        SpawnTime spawnTime = createrControl.spawnTime;
         for (int i = 0; i < spawnTime.num; i++)
         {
             if (!instance)

Деякі файли не було показано, через те що забагато файлів було змінено