关卡编辑器 战旗相关
parent
423b93b0d1
commit
92213fddae
|
|
@ -140,6 +140,16 @@ namespace Gameplay.Level
|
|||
public int damageBuffId = -1; // 触发后给敌方添加的伤害加成buffID,默认-1不添加
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class HoldFlagData
|
||||
{
|
||||
[HideInInspector] [LabelText("区域ID")] public int id;
|
||||
[HideInInspector] [LabelText("区域点位")] public List<int> cellIndex = new List<int>();
|
||||
[LabelText("所属战旗ID")] public int flagID;
|
||||
[LabelText("区域争夺触发区ID")] public int triggerAreaID;
|
||||
[LabelText("占领时间")] public float captureTime;
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public class RadarInfo
|
||||
{
|
||||
|
|
@ -617,6 +627,11 @@ namespace Gameplay.Level
|
|||
/// </summary>
|
||||
[HideInInspector] public List<Region> defenseRegions = new();
|
||||
|
||||
/// <summary>
|
||||
/// 战旗
|
||||
/// </summary>
|
||||
[HideInInspector] public List<HoldFlagData> holdGFlagInfos = new List<HoldFlagData>();
|
||||
|
||||
/// <summary>
|
||||
/// 雷达信息
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1169,6 +1169,14 @@ public partial class LevelEditorWindow
|
|||
_curMap.SetBlocksColor(region.positions, false, MinesColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseMinesRegion()
|
||||
{
|
||||
ClearMinesRegionColor();
|
||||
canEditorMinesArea = false;
|
||||
_currEditMinesRegionArea = null;
|
||||
_isEditorSingleMinesRegion = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -1332,6 +1340,14 @@ public partial class LevelEditorWindow
|
|||
_curMap.SetBlocksColor(blockRegion.positions, false, BlockRegionColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseBlockRegion()
|
||||
{
|
||||
ClearBlockRegionColor();
|
||||
canEditorBlockArea = false;
|
||||
_currEditBlockRegion = null;
|
||||
_isEditorSingleBlockRegion = false;
|
||||
}
|
||||
|
||||
private GameObject CreateBlockObj(string path, Vector3 pos)
|
||||
{
|
||||
|
|
@ -1376,12 +1392,12 @@ public partial class LevelEditorWindow
|
|||
|
||||
private static readonly Color DefenseRegionColor = Color.magenta;
|
||||
|
||||
private DefenseRegionArea _currEditDefenseRegion;
|
||||
private MonsterTriggerEditorInfo _currEditDefenseRegion;
|
||||
|
||||
private static bool _isEditorSingleDefenseRegion = false;
|
||||
|
||||
[Serializable]
|
||||
public class DefenseRegionArea
|
||||
public class MonsterTriggerEditorInfo
|
||||
{
|
||||
[HorizontalGroup("1")] [ReadOnly] public int id;
|
||||
|
||||
|
|
@ -1400,7 +1416,7 @@ public partial class LevelEditorWindow
|
|||
|
||||
private LevelData.Region _region;
|
||||
|
||||
public DefenseRegionArea(LevelData.Region region)
|
||||
public MonsterTriggerEditorInfo(LevelData.Region region)
|
||||
{
|
||||
_region = region;
|
||||
note = _region.note;
|
||||
|
|
@ -1443,13 +1459,13 @@ public partial class LevelEditorWindow
|
|||
}
|
||||
}
|
||||
|
||||
private void UpdateDefenseRegion()
|
||||
private void UpdateMonsterTrigger()
|
||||
{
|
||||
defenseRegionList.Clear();
|
||||
var index = 0;
|
||||
foreach (var region in currentLevelData.defenseRegions)
|
||||
{
|
||||
var defenseRegion = new DefenseRegionArea(region)
|
||||
var defenseRegion = new MonsterTriggerEditorInfo(region)
|
||||
{
|
||||
id = index,
|
||||
regionCount = region.positions.Count,
|
||||
|
|
@ -1460,7 +1476,7 @@ public partial class LevelEditorWindow
|
|||
}
|
||||
}
|
||||
|
||||
private void ClearDefenseRegionColor()
|
||||
private void ClearMonsterTriggerColor()
|
||||
{
|
||||
if (currentLevelData == null || _curMap == null)
|
||||
return;
|
||||
|
|
@ -1469,7 +1485,107 @@ public partial class LevelEditorWindow
|
|||
_curMap.SetBlocksColor(defenseRegion.positions, false, DefenseRegionColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseMonsterTrigger()
|
||||
{
|
||||
ClearMonsterTriggerColor();
|
||||
canEditorMonsterTrigger = false;
|
||||
_currEditDefenseRegion = null;
|
||||
_isEditorSingleDefenseRegion = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 战棋
|
||||
|
||||
private static readonly Color HoldFlagRegionColor = Color.magenta;
|
||||
|
||||
private HoldFlagEditorInfo _currEditHoldFlagInfo;
|
||||
|
||||
private static bool _isEditorSingleHoldFlag;
|
||||
|
||||
[Serializable]
|
||||
public class HoldFlagEditorInfo
|
||||
{
|
||||
[HorizontalGroup("1")] [ReadOnly] public int id;
|
||||
|
||||
[HorizontalGroup("2")] [LabelText("区域点位")] public List<int> Positions;
|
||||
|
||||
[LabelText("信息")] public HoldFlagData info;
|
||||
|
||||
[Button("编辑"), HorizontalGroup("2")]
|
||||
private void EditorRegion()
|
||||
{
|
||||
var map = currWindow._curMap;
|
||||
currWindow._currEditHoldFlagInfo = this;
|
||||
var holdFlagList = currWindow.currentLevelData.holdGFlagInfos;
|
||||
foreach (var holdFlagData in holdFlagList)
|
||||
{
|
||||
map.SetBlocksColor(holdFlagData.cellIndex, false, HoldFlagRegionColor);
|
||||
}
|
||||
|
||||
map.SetBlocksColor(info.cellIndex, true, HoldFlagRegionColor);
|
||||
_isEditorSingleHoldFlag = true;
|
||||
}
|
||||
|
||||
public HoldFlagEditorInfo(HoldFlagData info)
|
||||
{
|
||||
this.info = info;
|
||||
id = info.id;
|
||||
Positions = info.cellIndex;
|
||||
}
|
||||
|
||||
public void AddPosition(int cellIndex)
|
||||
{
|
||||
if (Positions.Contains(cellIndex))
|
||||
return;
|
||||
Positions.Add(cellIndex);
|
||||
DebugUtil.Log($"战旗区 {id} 添加地格{cellIndex}");
|
||||
currWindow._curMap.TerrainGridSystem.CellToggleRegionSurface(cellIndex, true, HoldFlagRegionColor);
|
||||
}
|
||||
|
||||
public void RemovePosition(int cellIndex)
|
||||
{
|
||||
if (!Positions.Contains(cellIndex))
|
||||
return;
|
||||
Positions.Remove(cellIndex);
|
||||
|
||||
DebugUtil.Log($"战旗区 {id} 移除地格{cellIndex}");
|
||||
currWindow._curMap.TerrainGridSystem.CellHideRegionSurface(cellIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateHoldFlag()
|
||||
{
|
||||
holdFlagEditorList.Clear();
|
||||
var index = 1;
|
||||
foreach (var holdFlagData in currentLevelData.holdGFlagInfos)
|
||||
{
|
||||
holdFlagData.id = index;
|
||||
var holdFlagEditorInfo = new HoldFlagEditorInfo(holdFlagData);
|
||||
holdFlagEditorList.Add(holdFlagEditorInfo);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearHoldFlagColor()
|
||||
{
|
||||
if (currentLevelData == null || _curMap == null)
|
||||
return;
|
||||
foreach (var holdFlagData in currentLevelData.holdGFlagInfos)
|
||||
{
|
||||
_curMap.SetBlocksColor(holdFlagData.cellIndex, false, HoldFlagRegionColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseHoldFlag()
|
||||
{
|
||||
ClearHoldFlagColor();
|
||||
canEditorHoldFlagArea = false;
|
||||
_currEditHoldFlagInfo = null;
|
||||
_isEditorSingleHoldFlag = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 雷达信息
|
||||
|
|
@ -1491,7 +1607,7 @@ public partial class LevelEditorWindow
|
|||
|
||||
private static readonly Color SearchLightColor = MapUtils.GetRGBAColor("2D004CFF");
|
||||
|
||||
private static bool _isEditorSearchLight;
|
||||
private static bool _isEditorSingleSearchLight;
|
||||
|
||||
private SearchLightEditorInfo _currEditSearchLight;
|
||||
|
||||
|
|
@ -1522,7 +1638,7 @@ public partial class LevelEditorWindow
|
|||
}
|
||||
|
||||
map.SetBlocksColor(points, true, SearchLightColor);
|
||||
_isEditorSearchLight = true;
|
||||
_isEditorSingleSearchLight = true;
|
||||
}
|
||||
|
||||
public void AddPosition(int cellIndex)
|
||||
|
|
@ -1530,6 +1646,7 @@ public partial class LevelEditorWindow
|
|||
if (points.Contains(cellIndex))
|
||||
return;
|
||||
points.Add(cellIndex);
|
||||
DebugUtil.Log($"探照灯{info.localID} 添加地格{cellIndex}");
|
||||
currWindow._curMap.TerrainGridSystem.CellToggleRegionSurface(cellIndex, true, SearchLightColor);
|
||||
}
|
||||
|
||||
|
|
@ -1538,6 +1655,7 @@ public partial class LevelEditorWindow
|
|||
if (!points.Contains(cellIndex))
|
||||
return;
|
||||
points.Remove(cellIndex);
|
||||
DebugUtil.Log($"探照灯{info.localID} 移除地格{cellIndex}");
|
||||
currWindow._curMap.TerrainGridSystem.CellHideRegionSurface(cellIndex);
|
||||
}
|
||||
}
|
||||
|
|
@ -1562,6 +1680,14 @@ public partial class LevelEditorWindow
|
|||
_curMap.SetBlocksColor(searchLight.interactivePoints, false, SearchLightColor);
|
||||
}
|
||||
}
|
||||
|
||||
private void CloseSearchLight()
|
||||
{
|
||||
ClearSearchLightColor();
|
||||
canEditorSearchLight = false;
|
||||
_currEditSearchLight = null;
|
||||
_isEditorSingleSearchLight = false;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public partial class LevelEditorWindow
|
|||
DestroyAllBlockObj();
|
||||
ClearMinesRegionColor();
|
||||
ClearBlockRegionColor();
|
||||
ClearDefenseRegionColor();
|
||||
ClearMonsterTriggerColor();
|
||||
|
||||
base.OnDestroy();
|
||||
if (_curMap != null)
|
||||
|
|
@ -91,9 +91,9 @@ public partial class LevelEditorWindow
|
|||
#region 点击添加事件
|
||||
|
||||
private bool ResponseClickOnCell =>
|
||||
isEditingEnemyNpc || isEditingSelfNpc || isEditingMidNpc || isEditingNpcPos || isEditingCaptureInfo || isEditingFallbackReusable ||
|
||||
isEditingRetreat || isEditingRoadInfo ||
|
||||
isEditingAreaInfo || canEditorBlockArea || canEditorDefenseArea || canEditorMinesArea || canEditorSearchLight;
|
||||
isEditingEnemyNpc || isEditingSelfNpc || isEditingMidNpc || isEditingNpcPos || isEditingCaptureInfo ||
|
||||
isEditingFallbackReusable || isEditingRetreat || isEditingRoadInfo || isEditingAreaInfo || canEditorBlockArea ||
|
||||
canEditorMonsterTrigger || canEditorMinesArea || canEditorSearchLight || canEditorHoldFlagArea;
|
||||
|
||||
private void OnCellClick(TerrainGridSystem tgs, int cellIndex, int buttonIndex)
|
||||
{
|
||||
|
|
@ -158,10 +158,14 @@ public partial class LevelEditorWindow
|
|||
{
|
||||
EditingDefenseRegion(cellIndex, opTrue);
|
||||
}
|
||||
else if (_isEditorSearchLight && _currEditSearchLight != null)
|
||||
else if (_isEditorSingleSearchLight && _currEditSearchLight != null)
|
||||
{
|
||||
EditingSearchLight(cellIndex, opTrue);
|
||||
}
|
||||
else if (_isEditorSingleHoldFlag && _currEditHoldFlagInfo != null)
|
||||
{
|
||||
EditingHoldFlag(cellIndex, opTrue);
|
||||
}
|
||||
}
|
||||
|
||||
private void EditingMinesRegion(int clickPosition, bool isAdd)
|
||||
|
|
@ -195,6 +199,14 @@ public partial class LevelEditorWindow
|
|||
else
|
||||
_currEditSearchLight.RemovePosition(clickPosition);
|
||||
}
|
||||
|
||||
private void EditingHoldFlag(int clickPosition, bool isAdd)
|
||||
{
|
||||
if (isAdd)
|
||||
_currEditHoldFlagInfo.AddPosition(clickPosition);
|
||||
else
|
||||
_currEditHoldFlagInfo.RemovePosition(clickPosition);
|
||||
}
|
||||
|
||||
private void EditingFallBack(Vector2Int clickPosition, bool isAdd)
|
||||
{
|
||||
|
|
@ -728,7 +740,7 @@ public partial class LevelEditorWindow
|
|||
DestroyAllBlockObj();
|
||||
UpdateMinesRegion();
|
||||
UpdateBlockRegion();
|
||||
UpdateDefenseRegion();
|
||||
UpdateMonsterTrigger();
|
||||
|
||||
// 加载撤离数据
|
||||
retreatEditorInfo.Clear();
|
||||
|
|
@ -786,6 +798,10 @@ public partial class LevelEditorWindow
|
|||
|
||||
// 轰炸区
|
||||
bombAreaInfoList = currentLevelData.bombAreaInfos.Select(b => new BombAreaInfoEditor(b)).ToList();
|
||||
|
||||
// 战旗
|
||||
holdFlagEditorList = currentLevelData.holdGFlagInfos.Select(h => new HoldFlagEditorInfo(h))
|
||||
.ToList();
|
||||
|
||||
// 加载当前关卡的Monster配置
|
||||
LoadAllNpcConfig();
|
||||
|
|
|
|||
|
|
@ -573,7 +573,7 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
|
||||
#endregion
|
||||
|
||||
#region 雷区
|
||||
#region 雷区 点击
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[BoxGroup("地区相关/雷区信息")]
|
||||
|
|
@ -588,22 +588,16 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
{
|
||||
if (canEditorMinesArea)
|
||||
{
|
||||
canEditorBlockArea = false;
|
||||
canEditorDefenseArea = false;
|
||||
_isEditorSingleBlockRegion = false;
|
||||
_isEditorSingleDefenseRegion = false;
|
||||
_isEditorSearchLight = false;
|
||||
ClearDefenseRegionColor();
|
||||
ClearBlockRegionColor();
|
||||
ClearSearchLightColor();
|
||||
CloseBlockRegion();
|
||||
CloseMonsterTrigger();
|
||||
CloseHoldFlag();
|
||||
CloseSearchLight();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearMinesRegionColor();
|
||||
SceneView.RepaintAll();
|
||||
_isEditorSingleMinesRegion = false;
|
||||
_currEditMinesRegionArea = null;
|
||||
CloseMinesRegion();
|
||||
}
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
|
|
@ -631,7 +625,7 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
|
||||
#endregion
|
||||
|
||||
#region 阻挡区信息
|
||||
#region 阻挡区信息 点击
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[BoxGroup("地区相关/阻挡区信息")]
|
||||
|
|
@ -646,22 +640,16 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
{
|
||||
if (canEditorBlockArea)
|
||||
{
|
||||
canEditorMinesArea = false;
|
||||
canEditorDefenseArea = false;
|
||||
_isEditorSingleDefenseRegion = false;
|
||||
_isEditorSingleMinesRegion = false;
|
||||
_isEditorSearchLight = false;
|
||||
ClearDefenseRegionColor();
|
||||
ClearMinesRegionColor();
|
||||
ClearSearchLightColor();
|
||||
CloseMinesRegion();
|
||||
CloseMinesRegion();
|
||||
CloseMonsterTrigger();
|
||||
CloseHoldFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearBlockRegionColor();
|
||||
SceneView.RepaintAll();
|
||||
_currEditBlockRegion = null;
|
||||
_isEditorSingleBlockRegion = false;
|
||||
CloseBlockRegion();
|
||||
}
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
|
|
@ -698,65 +686,112 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
|
||||
#endregion
|
||||
|
||||
#region 刷怪触发区
|
||||
#region 刷怪触发区 点击
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[BoxGroup("地区相关/刷怪触发区")]
|
||||
[HorizontalGroup("地区相关/刷怪触发区/Region")]
|
||||
[LabelText("编辑触发区"), Indent]
|
||||
[OnValueChanged("OnCanEditorDefenseAreaChanged")]
|
||||
[OnValueChanged("OnCanEditorMonsterTriggerChanged")]
|
||||
[LabelWidth(100)]
|
||||
[SerializeField]
|
||||
private bool canEditorDefenseArea;
|
||||
private bool canEditorMonsterTrigger;
|
||||
|
||||
private void OnCanEditorDefenseAreaChanged()
|
||||
private void OnCanEditorMonsterTriggerChanged()
|
||||
{
|
||||
if (canEditorDefenseArea)
|
||||
if (canEditorMonsterTrigger)
|
||||
{
|
||||
canEditorBlockArea = false;
|
||||
canEditorMinesArea = false;
|
||||
_isEditorSingleMinesRegion = false;
|
||||
_isEditorSingleBlockRegion = false;
|
||||
_isEditorSearchLight = false;
|
||||
ClearBlockRegionColor();
|
||||
ClearMinesRegionColor();
|
||||
ClearSearchLightColor();
|
||||
CloseBlockRegion();
|
||||
CloseMinesRegion();
|
||||
CloseSearchLight();
|
||||
CloseHoldFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDefenseRegionColor();
|
||||
SceneView.RepaintAll();
|
||||
_currEditDefenseRegion = null;
|
||||
_isEditorSingleDefenseRegion = false;
|
||||
CloseMonsterTrigger();
|
||||
}
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[LabelText("刷怪触发区列表")]
|
||||
[ShowIf("canEditorDefenseArea")]
|
||||
[ShowIf("canEditorMonsterTrigger")]
|
||||
[VerticalGroup("地区相关/刷怪触发区/RegionInfo"), Indent]
|
||||
[ListDrawerSettings(CustomAddFunction = "CustomAddDefenseRegion",
|
||||
CustomRemoveIndexFunction = "CustomRemoveDefenseRegion",
|
||||
DraggableItems = false)]
|
||||
public List<DefenseRegionArea> defenseRegionList = new();
|
||||
public List<MonsterTriggerEditorInfo> defenseRegionList = new();
|
||||
|
||||
private void CustomAddDefenseRegion()
|
||||
{
|
||||
var region = new LevelData.Region();
|
||||
currentLevelData.defenseRegions.Add(region);
|
||||
UpdateDefenseRegion();
|
||||
UpdateMonsterTrigger();
|
||||
}
|
||||
|
||||
private void CustomRemoveDefenseRegion(int index)
|
||||
{
|
||||
ClearDefenseRegionColor();
|
||||
ClearMonsterTriggerColor();
|
||||
currentLevelData.defenseRegions.RemoveAt(index);
|
||||
UpdateDefenseRegion();
|
||||
UpdateMonsterTrigger();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 探照灯
|
||||
#region 战旗 点击
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[BoxGroup("地区相关/战旗")]
|
||||
[HorizontalGroup("地区相关/战旗/Region")]
|
||||
[LabelText("编辑战旗信息"), Indent]
|
||||
[OnValueChanged("OnCanEditorHoldFlagAreaChanged")]
|
||||
[LabelWidth(100)]
|
||||
[SerializeField]
|
||||
private bool canEditorHoldFlagArea;
|
||||
|
||||
private void OnCanEditorHoldFlagAreaChanged()
|
||||
{
|
||||
if (canEditorHoldFlagArea)
|
||||
{
|
||||
CloseBlockRegion();
|
||||
CloseMonsterTrigger();
|
||||
CloseMinesRegion();
|
||||
CloseSearchLight();
|
||||
}
|
||||
else
|
||||
{
|
||||
CloseHoldFlag();
|
||||
}
|
||||
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[LabelText("战旗争夺区列表")]
|
||||
[ShowIf("canEditorHoldFlagArea")]
|
||||
[VerticalGroup("地区相关/战旗/RegionInfo"), Indent]
|
||||
[ListDrawerSettings(CustomAddFunction = "CustomAddHoldFlag",
|
||||
CustomRemoveIndexFunction = "CustomRemoveHoldFlag",
|
||||
DraggableItems = false)]
|
||||
public List<HoldFlagEditorInfo> holdFlagEditorList = new();
|
||||
|
||||
private void CustomAddHoldFlag()
|
||||
{
|
||||
var holdFlag = new HoldFlagData();
|
||||
currentLevelData.holdGFlagInfos.Add(holdFlag);
|
||||
UpdateHoldFlag();
|
||||
}
|
||||
|
||||
private void CustomRemoveHoldFlag(int index)
|
||||
{
|
||||
ClearHoldFlagColor();
|
||||
currentLevelData.holdGFlagInfos.RemoveAt(index);
|
||||
UpdateHoldFlag();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 探照灯 点击
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
[BoxGroup("地区相关/探照灯")]
|
||||
|
|
@ -771,22 +806,16 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
{
|
||||
if (canEditorSearchLight)
|
||||
{
|
||||
canEditorBlockArea = false;
|
||||
canEditorDefenseArea = false;
|
||||
_isEditorSingleBlockRegion = false;
|
||||
_isEditorSingleDefenseRegion = false;
|
||||
_isEditorSingleMinesRegion = false;
|
||||
ClearDefenseRegionColor();
|
||||
ClearBlockRegionColor();
|
||||
ClearMinesRegionColor();
|
||||
CloseBlockRegion();
|
||||
CloseMonsterTrigger();
|
||||
CloseMinesRegion();
|
||||
CloseHoldFlag();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearSearchLightColor();
|
||||
SceneView.RepaintAll();
|
||||
_isEditorSearchLight = false;
|
||||
_currEditSearchLight = null;
|
||||
CloseSearchLight();
|
||||
}
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
|
||||
[FoldoutGroup("地区相关")]
|
||||
|
|
@ -1604,6 +1633,9 @@ public partial class LevelEditorWindow : OdinEditorWindow
|
|||
|
||||
// 轰炸区
|
||||
currentLevelData.bombAreaInfos = bombAreaInfoList.Select(b => b.info).ToList();
|
||||
|
||||
// 战旗
|
||||
currentLevelData.holdGFlagInfos = holdFlagEditorList.Select(h => h.info).ToList();
|
||||
|
||||
// 阻挡球
|
||||
SaveBlockSphereInfo();
|
||||
|
|
|
|||
|
|
@ -413,568 +413,6 @@ namespace MapEditor
|
|||
|
||||
#endregion
|
||||
|
||||
/*#region 雷区
|
||||
|
||||
private static readonly Color MinesColor = MapUtils.GetRGBAColor("2D004CFF");
|
||||
|
||||
private static bool canEditorSingleMinesRegion;
|
||||
|
||||
private MinesRegionArea _currEditMinesRegionArea;
|
||||
|
||||
[Serializable]
|
||||
public class MinesRegionArea
|
||||
{
|
||||
[HorizontalGroup("1")] [ReadOnly] public int id;
|
||||
|
||||
[HorizontalGroup("1")] [ReadOnly] [LabelText("数量")]
|
||||
public int regionCount;
|
||||
|
||||
[LabelText("备注"), HorizontalGroup("1")] [OnValueChanged("OnNoteValueChanged")]
|
||||
public string note;
|
||||
|
||||
private void OnNoteValueChanged()
|
||||
{
|
||||
_region.note = note;
|
||||
}
|
||||
|
||||
public List<int> positions => _region.positions;
|
||||
|
||||
private MapData.Region _region;
|
||||
|
||||
public MinesRegionArea(MapData.Region region)
|
||||
{
|
||||
_region = region;
|
||||
note = _region.note;
|
||||
}
|
||||
|
||||
[Button("编辑"), HorizontalGroup("1")]
|
||||
private void EditorRegion()
|
||||
{
|
||||
var map = _thisWindow._map;
|
||||
_thisWindow._currEditMinesRegionArea = this;
|
||||
var regionList = map.MapData.minesRegions;
|
||||
foreach (var region in regionList)
|
||||
{
|
||||
map.SetBlocksColor(region.positions, false, MinesColor);
|
||||
}
|
||||
|
||||
map.SetBlocksColor(_region.positions, true, MinesColor);
|
||||
canEditorSingleMinesRegion = true;
|
||||
}
|
||||
|
||||
public void AddPosition(int cellIndex)
|
||||
{
|
||||
if (positions.Contains(cellIndex))
|
||||
return;
|
||||
positions.Add(cellIndex);
|
||||
regionCount++;
|
||||
_thisWindow._map.TerrainGridSystem.CellToggleRegionSurface(cellIndex, true, MinesColor);
|
||||
}
|
||||
|
||||
public void RemovePosition(int cellIndex)
|
||||
{
|
||||
if (!positions.Contains(cellIndex))
|
||||
return;
|
||||
positions.Remove(cellIndex);
|
||||
regionCount--;
|
||||
_thisWindow._map.TerrainGridSystem.CellHideRegionSurface(cellIndex);
|
||||
}
|
||||
}
|
||||
|
||||
[BoxGroup("雷区信息")]
|
||||
[HorizontalGroup("雷区信息/Region")]
|
||||
[LabelText("编辑雷区"), Indent]
|
||||
[ShowIf("@!_isLegionMap")]
|
||||
[OnValueChanged("OnCanEditorMinesAreaTypeChanged")]
|
||||
[LabelWidth(100)]
|
||||
[SerializeField]
|
||||
private bool canEditorMinesArea;
|
||||
|
||||
private void OnCanEditorMinesAreaTypeChanged()
|
||||
{
|
||||
if (canEditorMinesArea)
|
||||
{
|
||||
canEditorArea = false;
|
||||
canBrushTerrainType = false;
|
||||
canEditorBlockArea = false;
|
||||
canEditorDefenseArea = false;
|
||||
canEditorSingleBlockRegion = false;
|
||||
canEditorSingleDefenseRegion = false;
|
||||
ClearDefenseRegionColor();
|
||||
ClearBlockRegionColor();
|
||||
ClearRegionColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearMinesRegionColor();
|
||||
SceneView.RepaintAll();
|
||||
canEditorSingleMinesRegion = false;
|
||||
_currEditMinesRegionArea = null;
|
||||
}
|
||||
}
|
||||
|
||||
[LabelText("雷区列表")]
|
||||
[ShowIf("@!_isLegionMap&&canEditorMinesArea")]
|
||||
[VerticalGroup("雷区信息/RegionInfo"), Indent]
|
||||
[ListDrawerSettings(CustomAddFunction = "CustomAddMinesRegion",
|
||||
CustomRemoveIndexFunction = "CustomRemoveMinesRegion",
|
||||
DraggableItems = false)]
|
||||
public List<MinesRegionArea> minesRegionList = new();
|
||||
|
||||
private void CustomAddMinesRegion()
|
||||
{
|
||||
var region = new MapData.Region();
|
||||
_currentMapData.minesRegions.Add(region);
|
||||
UpdateMinesRegion();
|
||||
}
|
||||
|
||||
private void CustomRemoveMinesRegion(int index)
|
||||
{
|
||||
ClearMinesRegionColor();
|
||||
_currentMapData.minesRegions.RemoveAt(index);
|
||||
UpdateMinesRegion();
|
||||
}
|
||||
|
||||
private void UpdateMinesRegion()
|
||||
{
|
||||
minesRegionList.Clear();
|
||||
if (_currentMapData != null)
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var region in _currentMapData.minesRegions)
|
||||
{
|
||||
MinesRegionArea ra = new MinesRegionArea(region)
|
||||
{
|
||||
id = index
|
||||
};
|
||||
ra.regionCount = ra.positions.Count;
|
||||
minesRegionList.Add(ra);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearMinesRegionColor()
|
||||
{
|
||||
if (_map == null)
|
||||
return;
|
||||
|
||||
foreach (var region in _map.MapData.minesRegions)
|
||||
{
|
||||
_map.SetBlocksColor(region.positions, false, MinesColor);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 阻挡区信息
|
||||
|
||||
private static readonly Color BlockRegionColor = Color.blue;
|
||||
|
||||
private BlockRegionArea _currEditBlockRegion;
|
||||
|
||||
private static bool canEditorSingleBlockRegion = false;
|
||||
|
||||
private Dictionary<int, GameObject> _blockPrefabDic;
|
||||
|
||||
private GameObject blockRoot;
|
||||
|
||||
[Serializable]
|
||||
public class BlockRegionArea
|
||||
{
|
||||
private const string BuffPrefabPath = "Art_Out/Other/BuffPoint";
|
||||
|
||||
[HorizontalGroup("1")] [ReadOnly] public int id;
|
||||
|
||||
[HorizontalGroup("1")] [ReadOnly] [LabelText("数量")]
|
||||
public int regionCount;
|
||||
|
||||
[LabelText("备注"), HorizontalGroup("1")] [OnValueChanged("OnNoteValueChanged")]
|
||||
public string note;
|
||||
|
||||
private void OnNoteValueChanged()
|
||||
{
|
||||
_region.note = note;
|
||||
}
|
||||
|
||||
[Button("编辑"), HorizontalGroup("1")]
|
||||
private void EditorRegion()
|
||||
{
|
||||
var map = _thisWindow._map;
|
||||
_thisWindow._currEditBlockRegion = this;
|
||||
var regionsList = map.MapData.blockRegions;
|
||||
foreach (var blockRegion in regionsList)
|
||||
{
|
||||
map.SetBlocksColor(blockRegion.positions, false, BlockRegionColor);
|
||||
}
|
||||
|
||||
map.SetBlocksColor(_region.positions, true, BlockRegionColor);
|
||||
canEditorSingleBlockRegion = true;
|
||||
}
|
||||
|
||||
|
||||
[HorizontalGroup("3")]
|
||||
[PreviewField(50, ObjectFieldAlignment.Center)]
|
||||
[LabelText("指示预览图"), OnValueChanged("OnObjectValueChanged")]
|
||||
[AssetList(Path = BuffPrefabPath)]
|
||||
public GameObject buffObject;
|
||||
|
||||
private void OnObjectValueChanged()
|
||||
{
|
||||
if (buffObject != null)
|
||||
{
|
||||
_region.path = "Assets/" + BuffPrefabPath + "/" + buffObject.name + ".prefab";
|
||||
}
|
||||
}
|
||||
|
||||
[HorizontalGroup("2")] [LabelText("指示位置"), OnValueChanged("OnPosValueChanged")]
|
||||
public Vector3 pos = Vector3.zero;
|
||||
|
||||
private void OnPosValueChanged()
|
||||
{
|
||||
_region.centerPos = pos;
|
||||
if (obj != null)
|
||||
{
|
||||
obj.transform.position = pos;
|
||||
}
|
||||
}
|
||||
|
||||
[Button("添加至场景"), HorizontalGroup("3")]
|
||||
[ShowIf("NeedAdd")]
|
||||
private void AddToScene()
|
||||
{
|
||||
obj = _thisWindow.CreateBlockObj(_region.path, pos);
|
||||
}
|
||||
|
||||
[Button("更换指示"), HorizontalGroup("3")]
|
||||
[HideIf("NeedAdd")]
|
||||
private void ChangeObj()
|
||||
{
|
||||
if (obj) DestroyImmediate(obj);
|
||||
obj = _thisWindow.CreateBlockObj(_region.path, pos);
|
||||
}
|
||||
|
||||
private bool NeedAdd => obj == null;
|
||||
[HideInInspector] public GameObject obj;
|
||||
|
||||
public List<int> Positions => _region.positions;
|
||||
|
||||
[HideInInspector] public MapData.BlockRegion _region;
|
||||
|
||||
public BlockRegionArea(MapData.BlockRegion region)
|
||||
{
|
||||
_region = region;
|
||||
pos = _region.centerPos;
|
||||
note = _region.note;
|
||||
if (!string.IsNullOrEmpty(region.path))
|
||||
{
|
||||
obj = _thisWindow.CreateBlockObj(_region.path, _region.centerPos);
|
||||
buffObject = AssetDatabase.LoadAssetAtPath<GameObject>(_region.path);
|
||||
}
|
||||
}
|
||||
|
||||
public void AddPosition(int cellIndex)
|
||||
{
|
||||
if (Positions.Contains(cellIndex))
|
||||
return;
|
||||
Positions.Add(cellIndex);
|
||||
DebugUtil.Log($"{id}阻挡区添加地格{cellIndex}");
|
||||
regionCount++;
|
||||
_thisWindow._map.TerrainGridSystem.CellToggleRegionSurface(cellIndex, true, BlockRegionColor);
|
||||
}
|
||||
|
||||
public void RemovePosition(int cellIndex)
|
||||
{
|
||||
if (!Positions.Contains(cellIndex))
|
||||
return;
|
||||
Positions.Remove(cellIndex);
|
||||
|
||||
DebugUtil.Log($"{id}阻挡区移除地格{cellIndex}");
|
||||
regionCount--;
|
||||
_thisWindow._map.TerrainGridSystem.CellHideRegionSurface(cellIndex);
|
||||
}
|
||||
}
|
||||
|
||||
[BoxGroup("阻挡区信息")]
|
||||
[HorizontalGroup("阻挡区信息/Region")]
|
||||
[ShowIf("@!_isLegionMap")]
|
||||
[LabelText("编辑阻挡区"), Indent]
|
||||
[OnValueChanged("OnCanEditorBlockAreaChanged")]
|
||||
[LabelWidth(100)]
|
||||
[SerializeField]
|
||||
private bool canEditorBlockArea;
|
||||
|
||||
private void OnCanEditorBlockAreaChanged()
|
||||
{
|
||||
if (canEditorBlockArea)
|
||||
{
|
||||
canEditorArea = false;
|
||||
canEditorMinesArea = false;
|
||||
canBrushTerrainType = false;
|
||||
canEditorDefenseArea = false;
|
||||
canEditorSingleRegion = false;
|
||||
canEditorSingleDefenseRegion = false;
|
||||
ClearDefenseRegionColor();
|
||||
ClearRegionColor();
|
||||
ClearMinesRegionColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearBlockRegionColor();
|
||||
SceneView.RepaintAll();
|
||||
_currEditBlockRegion = null;
|
||||
canEditorSingleBlockRegion = false;
|
||||
}
|
||||
}
|
||||
|
||||
[LabelText("阻挡区列表")]
|
||||
[ShowIf("@!_isLegionMap&&canEditorBlockArea")]
|
||||
[VerticalGroup("阻挡区信息/RegionInfo"), Indent]
|
||||
[ListDrawerSettings(CustomAddFunction = "CustomAddBlockRegion",
|
||||
CustomRemoveIndexFunction = "CustomRemoveBlockRegionIndex",
|
||||
DraggableItems = false)]
|
||||
public List<BlockRegionArea> blockRegionList = new();
|
||||
|
||||
private void CustomAddBlockRegion()
|
||||
{
|
||||
var region = new MapData.BlockRegion();
|
||||
_currentMapData.blockRegions.Add(region);
|
||||
UpdateBlockRegion();
|
||||
}
|
||||
|
||||
private void CustomRemoveBlockRegionIndex(int index)
|
||||
{
|
||||
if (index < blockRegionList.Count)
|
||||
{
|
||||
if (blockRegionList[index].obj != null)
|
||||
{
|
||||
DebugUtil.LogError($"删除{blockRegionList[index].id}的指示");
|
||||
DestroyImmediate(blockRegionList[index].obj);
|
||||
}
|
||||
}
|
||||
|
||||
ClearBlockRegionColor();
|
||||
_currentMapData.blockRegions.RemoveAt(index);
|
||||
UpdateBlockRegion();
|
||||
}
|
||||
|
||||
private void UpdateBlockRegion()
|
||||
{
|
||||
blockRegionList.Clear();
|
||||
if (_currentMapData != null)
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var region in _currentMapData.blockRegions)
|
||||
{
|
||||
var blockRegion = new BlockRegionArea(region)
|
||||
{
|
||||
id = index,
|
||||
regionCount = region.positions.Count,
|
||||
};
|
||||
|
||||
blockRegionList.Add(blockRegion);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearBlockRegionColor()
|
||||
{
|
||||
if (_map == null)
|
||||
return;
|
||||
foreach (var blockRegion in _map.MapData.blockRegions)
|
||||
{
|
||||
_map.SetBlocksColor(blockRegion.positions, false, BlockRegionColor);
|
||||
}
|
||||
}
|
||||
|
||||
private GameObject CreateBlockObj(string path, Vector3 pos)
|
||||
{
|
||||
var blockObj = AssetDatabase.LoadAssetAtPath<GameObject>(path);
|
||||
if (blockObj == null)
|
||||
{
|
||||
DebugUtil.LogError($"{path} 路径下无Block指示预制体 ");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (blockRoot == null)
|
||||
blockRoot = new GameObject("BlockRoot");
|
||||
var obj = Instantiate(blockObj, pos, blockObj.transform.rotation, blockRoot.transform);
|
||||
obj.SetActive(true);
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
private void DestroyAllBlockObj()
|
||||
{
|
||||
if (blockRoot)
|
||||
DestroyImmediate(blockRoot);
|
||||
foreach (var blockRegion in blockRegionList)
|
||||
{
|
||||
if (blockRegion.obj)
|
||||
DestroyImmediate(blockRegion.obj);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 刷怪触发区
|
||||
|
||||
private static readonly Color DefenseRegionColor = Color.magenta;
|
||||
|
||||
private DefenseRegionArea _currEditDefenseRegion;
|
||||
|
||||
private static bool canEditorSingleDefenseRegion = false;
|
||||
|
||||
[Serializable]
|
||||
public class DefenseRegionArea
|
||||
{
|
||||
[HorizontalGroup("1")] [ReadOnly] public int id;
|
||||
|
||||
[HorizontalGroup("1")] [ReadOnly] [LabelText("数量")]
|
||||
public int regionCount;
|
||||
|
||||
[LabelText("备注"), HorizontalGroup("1")] [OnValueChanged("OnNoteValueChanged")]
|
||||
public string note;
|
||||
|
||||
private void OnNoteValueChanged()
|
||||
{
|
||||
_region.note = note;
|
||||
}
|
||||
|
||||
public List<int> Positions => _region.positions;
|
||||
|
||||
private MapData.Region _region;
|
||||
|
||||
public DefenseRegionArea(MapData.Region region)
|
||||
{
|
||||
_region = region;
|
||||
note = _region.note;
|
||||
}
|
||||
|
||||
[Button("编辑"), HorizontalGroup("1")]
|
||||
private void EditorRegion()
|
||||
{
|
||||
var map = _thisWindow._map;
|
||||
_thisWindow._currEditDefenseRegion = this;
|
||||
var regionsList = map.MapData.defenseRegions;
|
||||
foreach (var defenseRegion in regionsList)
|
||||
{
|
||||
map.SetBlocksColor(defenseRegion.positions, false, DefenseRegionColor);
|
||||
}
|
||||
|
||||
map.SetBlocksColor(_region.positions, true, DefenseRegionColor);
|
||||
canEditorSingleDefenseRegion = true;
|
||||
}
|
||||
|
||||
public void AddPosition(int cellIndex)
|
||||
{
|
||||
if (Positions.Contains(cellIndex))
|
||||
return;
|
||||
Positions.Add(cellIndex);
|
||||
DebugUtil.Log($"{id}防守区添加地格{cellIndex}");
|
||||
regionCount++;
|
||||
_thisWindow._map.TerrainGridSystem.CellToggleRegionSurface(cellIndex, true, DefenseRegionColor);
|
||||
}
|
||||
|
||||
public void RemovePosition(int cellIndex)
|
||||
{
|
||||
if (!Positions.Contains(cellIndex))
|
||||
return;
|
||||
Positions.Remove(cellIndex);
|
||||
|
||||
DebugUtil.Log($"{id}防守区移除地格{cellIndex}");
|
||||
regionCount--;
|
||||
_thisWindow._map.TerrainGridSystem.CellHideRegionSurface(cellIndex);
|
||||
}
|
||||
}
|
||||
|
||||
[BoxGroup("刷怪触发区")]
|
||||
[HorizontalGroup("刷怪触发区/Region")]
|
||||
[ShowIf("@!_isLegionMap")]
|
||||
[LabelText("编辑触发区"), Indent]
|
||||
[OnValueChanged("OnCanEditorDefenseAreaChanged")]
|
||||
[LabelWidth(100)]
|
||||
[SerializeField]
|
||||
private bool canEditorDefenseArea;
|
||||
|
||||
private void OnCanEditorDefenseAreaChanged()
|
||||
{
|
||||
if (canEditorDefenseArea)
|
||||
{
|
||||
canEditorBlockArea = false;
|
||||
canEditorArea = false;
|
||||
canEditorMinesArea = false;
|
||||
canBrushTerrainType = false;
|
||||
canEditorSingleRegion = false;
|
||||
canEditorSingleBlockRegion = false;
|
||||
ClearBlockRegionColor();
|
||||
ClearRegionColor();
|
||||
ClearMinesRegionColor();
|
||||
}
|
||||
else
|
||||
{
|
||||
ClearDefenseRegionColor();
|
||||
SceneView.RepaintAll();
|
||||
_currEditDefenseRegion = null;
|
||||
canEditorSingleDefenseRegion = false;
|
||||
}
|
||||
}
|
||||
|
||||
[LabelText("刷怪触发区列表")]
|
||||
[ShowIf("@!_isLegionMap&&canEditorDefenseArea")]
|
||||
[VerticalGroup("刷怪触发区/RegionInfo"), Indent]
|
||||
[ListDrawerSettings(CustomAddFunction = "CustomAddDefenseRegion",
|
||||
CustomRemoveIndexFunction = "CustomRemoveDefenseRegion",
|
||||
DraggableItems = false)]
|
||||
public List<DefenseRegionArea> defenseRegionList = new();
|
||||
|
||||
private void CustomAddDefenseRegion()
|
||||
{
|
||||
var region = new MapData.Region();
|
||||
_currentMapData.defenseRegions.Add(region);
|
||||
UpdateDefenseRegion();
|
||||
}
|
||||
|
||||
private void CustomRemoveDefenseRegion(int index)
|
||||
{
|
||||
ClearDefenseRegionColor();
|
||||
_currentMapData.defenseRegions.RemoveAt(index);
|
||||
UpdateDefenseRegion();
|
||||
}
|
||||
|
||||
private void UpdateDefenseRegion()
|
||||
{
|
||||
defenseRegionList.Clear();
|
||||
if (_currentMapData != null)
|
||||
{
|
||||
var index = 0;
|
||||
foreach (var region in _currentMapData.defenseRegions)
|
||||
{
|
||||
var defenseRegion = new DefenseRegionArea(region)
|
||||
{
|
||||
id = index,
|
||||
regionCount = region.positions.Count,
|
||||
};
|
||||
|
||||
defenseRegionList.Add(defenseRegion);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ClearDefenseRegionColor()
|
||||
{
|
||||
if (_map == null)
|
||||
return;
|
||||
foreach (var defenseRegion in _map.MapData.defenseRegions)
|
||||
{
|
||||
_map.SetBlocksColor(defenseRegion.positions, false, DefenseRegionColor);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion*/
|
||||
|
||||
#region 阻挡球编辑
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
Loading…
Reference in New Issue