|
|
@@ -6,7 +6,7 @@ using UnityEditor;
|
|
|
using cfg;
|
|
|
using System.IO;
|
|
|
using OfficeOpenXml;
|
|
|
-using SimpleJSON;
|
|
|
+using System.Linq;
|
|
|
|
|
|
public class GameMapEditor : EditorWindow
|
|
|
{
|
|
|
@@ -983,77 +983,72 @@ public class GameMapEditor : EditorWindow
|
|
|
buildingHp = EditorGUILayout.FloatField("剩余血量", layer.buildingHp);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- Dictionary<int, SpawnTime> newSpawnTimes = new();
|
|
|
+ List<SpawnTime> newSpawnTimes = new List<SpawnTime>();
|
|
|
+ for(int i = 0; i < asset.tileAsset.tiles.Count; i++)
|
|
|
+ {
|
|
|
+ SpawnTime spawnTime = new SpawnTime();
|
|
|
+ spawnTime.pos = new List<int>();
|
|
|
+ newSpawnTimes.Add(spawnTime);
|
|
|
+ }
|
|
|
EditorGUILayout.BeginVertical("box");
|
|
|
{
|
|
|
EditorGUILayout.LabelField("Spawn Times", EditorStyles.boldLabel);
|
|
|
GUILayout.Space(5f);
|
|
|
- try
|
|
|
+ int[] grids = layer.grid;
|
|
|
+ for (int i = 0; i < grids.Length; i++)
|
|
|
{
|
|
|
- int[] grids = layer.grid;
|
|
|
- for (int i = 0; i < grids.Length; i++)
|
|
|
+ if (grids[i] == -1)
|
|
|
{
|
|
|
- if (grids[i] == -1)
|
|
|
- {
|
|
|
- continue;
|
|
|
- }
|
|
|
- SpawnTime spawnTime = new SpawnTime();
|
|
|
- if (newSpawnTimes.ContainsKey(grids[i]))
|
|
|
- {
|
|
|
- spawnTime = newSpawnTimes[grids[i]];
|
|
|
- spawnTime.pos.Add(i);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- spawnTime.id = grids[i];
|
|
|
- spawnTime.pos = new List<int> { i };
|
|
|
- newSpawnTimes.Add(grids[i], spawnTime);
|
|
|
- }
|
|
|
+ continue;
|
|
|
}
|
|
|
+ SpawnTime spawnTime = newSpawnTimes[grids[i]];
|
|
|
+ spawnTime.id = grids[i];
|
|
|
+ spawnTime.pos.Add(i);
|
|
|
+ newSpawnTimes[grids[i]] = spawnTime;
|
|
|
+ }
|
|
|
|
|
|
- if (newSpawnTimes.Count >= 1)
|
|
|
- {
|
|
|
- Dictionary<int, SpawnTime> copyNewSpawnTime = new Dictionary<int, SpawnTime>(newSpawnTimes);
|
|
|
- foreach (var item in copyNewSpawnTime)
|
|
|
- {
|
|
|
- SpawnTime newSpawnTime = item.Value;
|
|
|
- EditorGUILayout.LabelField($"{asset.tileAsset.GetTile(newSpawnTime.id).name} - {newSpawnTime.pos.Count}", EditorStyles.boldLabel);
|
|
|
- if (layer.spawnTimes.ContainsKey(item.Key))
|
|
|
- {
|
|
|
- newSpawnTime.startTime = EditorGUILayout.IntField("Start Time", layer.spawnTimes[item.Key].startTime);
|
|
|
- newSpawnTime.endTime = EditorGUILayout.IntField("End Time", layer.spawnTimes[item.Key].endTime);
|
|
|
- newSpawnTime.num = EditorGUILayout.IntField("Number", layer.spawnTimes[item.Key].num);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ int spawnTimeIndex = 0;
|
|
|
+ for (int i = 0; i < newSpawnTimes.Count; i++)
|
|
|
+ {
|
|
|
+ SpawnTime newSpawnTime = newSpawnTimes[i];
|
|
|
+ if(newSpawnTime.pos.Count > 0)
|
|
|
+ {
|
|
|
+ EditorGUILayout.LabelField($"{asset.tileAsset.GetTile(newSpawnTime.id).name} - {newSpawnTime.pos.Count}", EditorStyles.boldLabel);
|
|
|
+ while(spawnTimeIndex < layer.spawnTimes.Count)
|
|
|
+ {
|
|
|
+ if(layer.spawnTimes[spawnTimeIndex].id == newSpawnTime.id)
|
|
|
+ {
|
|
|
+ newSpawnTime.startTime = EditorGUILayout.IntField("Start Time", layer.spawnTimes[spawnTimeIndex].startTime);
|
|
|
+ newSpawnTime.endTime = EditorGUILayout.IntField("End Time", layer.spawnTimes[spawnTimeIndex].endTime);
|
|
|
+ newSpawnTime.num = EditorGUILayout.IntField("Number", layer.spawnTimes[spawnTimeIndex].num);
|
|
|
+ spawnTimeIndex++;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ else if(layer.spawnTimes[spawnTimeIndex].id < newSpawnTime.id)
|
|
|
+ {
|
|
|
+ spawnTimeIndex++;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
newSpawnTime.startTime = EditorGUILayout.IntField("Start Time", 0);
|
|
|
newSpawnTime.endTime = EditorGUILayout.IntField("End Time", 0);
|
|
|
- newSpawnTime.num = EditorGUILayout.IntField("Number", 0);
|
|
|
+ newSpawnTime.num = EditorGUILayout.IntField("Number", 1);
|
|
|
+ spawnTimeIndex++;
|
|
|
+ break;
|
|
|
}
|
|
|
-
|
|
|
- if (GUILayout.Button("Remove"))
|
|
|
+ }
|
|
|
+ if (GUILayout.Button("Remove"))
|
|
|
+ {
|
|
|
+ for (int j = 0; j < newSpawnTime.pos.Count; j++)
|
|
|
{
|
|
|
- for (int j = 0; j < newSpawnTime.pos.Count; j++)
|
|
|
- {
|
|
|
- layer.grid[newSpawnTime.pos[j]] = -1;
|
|
|
- }
|
|
|
+ layer.grid[newSpawnTime.pos[j]] = -1;
|
|
|
}
|
|
|
- newSpawnTimes[item.Key] = newSpawnTime;
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- Debug.LogError(e);
|
|
|
- newSpawnTimes = layer.spawnTimes;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- EditorGUILayout.EndVertical();
|
|
|
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
if (EditorGUI.EndChangeCheck() || haveChangeGrid)
|
|
|
{
|
|
|
Undo.RecordObject(asset, "Change Layer Information");
|
|
|
@@ -1066,11 +1061,7 @@ public class GameMapEditor : EditorWindow
|
|
|
layer.waveType = waveType;
|
|
|
AssetDatabase.SaveAssets();
|
|
|
}
|
|
|
- // 标记资源为脏数据,以便保存更改
|
|
|
- // 显示其他图层信息(根据需求扩展)
|
|
|
- //EditorGUILayout.LabelField("Other Properties:");
|
|
|
- //EditorGUILayout.LabelField($"Grid Size: {layer.gridSize}");
|
|
|
- //EditorGUILayout.LabelField($"Is Visible: {layer.isVisible}");
|
|
|
+ EditorGUILayout.EndVertical();
|
|
|
}
|
|
|
private void DrawTileProperties(Event ev)
|
|
|
{
|