NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/GameWrapper/Level/LevelData.cs

208 lines
7.2 KiB
C#
Raw Normal View History

2023-08-22 19:08:45 +08:00
using System;
using UnityEngine;
2024-06-04 16:50:16 +08:00
using Sirenix.OdinInspector;
2023-11-06 18:20:55 +08:00
using UnityEngine.Serialization;
2024-06-04 16:50:16 +08:00
using System.Collections.Generic;
using System.Runtime.Serialization;
2023-08-22 19:08:45 +08:00
namespace Gameplay.Level
{
[Serializable]
public class LevelData
{
[Serializable]
public class Stage
{
2024-11-12 20:31:06 +08:00
[LabelText("名称")] private string name;
[LabelText("描述")] private string desc;
[FormerlySerializedAs("goal")] [LabelText("胜利条件")]
2023-11-21 15:04:56 +08:00
public ConditionModifier successCondition = new(ConditionUtil.LevelSuccessConditionFilter);
2024-11-12 20:31:06 +08:00
[LabelText("失败条件")] [ListDrawerSettings(CustomAddFunction = "OnAddFailCondition")]
2023-11-06 18:20:55 +08:00
public List<ConditionModifier> failConditions = new();
2024-11-12 20:31:06 +08:00
2023-11-06 18:20:55 +08:00
private void OnAddFailCondition()
{
2023-11-06 19:18:24 +08:00
ConditionModifier conditionModifier = new();
conditionModifier.SetFilterTypes(ConditionUtil.LevelFailConditionFilter);
2023-11-06 18:20:55 +08:00
failConditions.Add(conditionModifier);
}
2024-11-12 20:31:06 +08:00
2023-11-06 19:18:24 +08:00
[OnDeserialized]
public void OnAfterDeserialize(System.Runtime.Serialization.StreamingContext context)
{
successCondition.SetFilterTypes(ConditionUtil.LevelSuccessConditionFilter);
foreach (var failCondition in failConditions)
{
failCondition.SetFilterTypes(ConditionUtil.LevelFailConditionFilter);
}
}
2023-08-22 19:08:45 +08:00
}
2024-11-12 20:31:06 +08:00
2023-08-22 19:08:45 +08:00
[Serializable]
public class NPCInfo
2024-11-12 20:31:06 +08:00
{
2024-11-13 13:21:36 +08:00
[HideInInspector] public int index;
2024-11-12 20:31:06 +08:00
[HideInInspector] public int id;
2025-04-07 14:34:27 +08:00
// 仅供展示
2024-11-12 20:31:06 +08:00
[ReadOnly] public int level;
[ReadOnly] [LabelText("位置")] public Vector2Int position;
[LabelText("初始护盾")] public float shield;
[LabelText("初始血量")] public float ph;
[LabelText("初始士气")] public float morale;
[LabelText("Buff")] public List<int> buff = new List<int>();
[LabelText("DeBuff")] public List<int> deBuff = new List<int>();
[LabelText("AI类型")] public AIType aIType = AIType.None;
[LabelText("特殊触发AI")] public AttachAIType attachAIType;
[HideInInspector] public CharacterToward npcToward;
[LabelText("巡逻信息")] public List<PatrolInfo> patrolInfos = new List<PatrolInfo>(4);
2024-07-22 14:46:20 +08:00
[LabelText("编组")] public List<int> groups = new List<int>(4);
2024-12-04 18:49:20 +08:00
[LabelText("防守距离")] public int defensiveDistance;
2025-02-17 17:11:38 +08:00
[HideInInspector] public string configName;
2025-02-24 19:26:18 +08:00
[LabelText("是否为中途生成AI")] public bool isHideOnLoad;
2023-10-19 15:00:19 +08:00
}
[Serializable]
public class PatrolInfo
{
2024-11-12 20:31:06 +08:00
[HorizontalGroup("PatrolInfo")] [LabelText("巡逻点位")]
2023-10-19 15:00:19 +08:00
public Vector2Int patrolPoint;
2024-11-12 20:31:06 +08:00
[HorizontalGroup("PatrolInfo")] [LabelText("等待时间")]
public float waitTime = 0f;
2023-08-22 19:08:45 +08:00
}
2025-02-21 17:03:56 +08:00
[Serializable]
public class PrescribedRoadInfo
{
public int roadID;
public List<int> cellIndex = new List<int>();
}
2023-08-22 19:08:45 +08:00
public enum CharacterToward
{
TopLeft,
TopRight,
Right,
BottomRight,
BottomLeft,
Left,
}
public enum AIType
{
BasicAI,
FallBackAI,
2023-10-19 15:00:19 +08:00
FallBackIntensifyAI,
2023-08-22 19:08:45 +08:00
OutflankAI,
2024-12-04 18:49:20 +08:00
DefendAI,
2025-02-21 17:03:56 +08:00
StupidDefendAI,
2024-11-12 20:31:06 +08:00
None,
2023-08-22 19:08:45 +08:00
}
public enum AttachAIType
{
None,
ChainAI,
ProvokeAI,
SpecialBehaviorAI,
2024-12-05 16:05:12 +08:00
AttackProtectUnitAI,
2023-08-22 19:08:45 +08:00
}
2023-11-21 15:04:56 +08:00
public LevelData()
{
2023-08-22 19:08:45 +08:00
}
2024-11-12 20:31:06 +08:00
[LabelText("出战区")] [HideInInspector] public int preparingRegionId;
2023-08-22 19:08:45 +08:00
2024-11-12 20:31:06 +08:00
[LabelText("出战区朝向")] [HideInInspector] public CharacterToward preparingRegionToward;
2023-08-22 19:08:45 +08:00
2024-11-12 20:31:06 +08:00
[LabelText("撤退区")] [HideInInspector] public int fallbackRegionId;
2023-08-22 19:08:45 +08:00
2024-11-12 20:31:06 +08:00
[LabelText("敌方撤退区")] [HideInInspector] public int enemyFallbackRegionId;
[LabelText("PVP防守区")] [HideInInspector]
2023-12-26 18:19:05 +08:00
public int pvpDefendRegionId;
2024-11-12 20:31:06 +08:00
[LabelText("PVP防守方朝向")] [HideInInspector]
2023-12-26 18:19:05 +08:00
public CharacterToward pvpDefendToward;
2023-10-19 15:00:19 +08:00
2024-11-12 20:31:06 +08:00
[LabelText("阶段")] public List<Stage> stages = new List<Stage>(8);
2023-08-22 19:08:45 +08:00
2024-08-27 14:18:39 +08:00
[LabelText("设置该关卡为评分关卡")] public bool scoreLevel = false;
[LabelText("星级目标"), HideIf("scoreLevel")] [ListDrawerSettings(HideAddButton = true, HideRemoveButton = true)]
public List<ConditionModifier> starTarget = new()
{
new ConditionModifier(ConditionUtil.LevelStarConditionFilter),
new ConditionModifier(ConditionUtil.LevelStarConditionFilter),
new ConditionModifier(ConditionUtil.LevelStarConditionFilter)
};
2024-08-27 14:18:39 +08:00
[LabelText("评分目标"), ShowIf("scoreLevel")] [ListDrawerSettings(CustomAddFunction = "OnAddScoreCondition")]
public List<ConditionModifier> scoreTarget = new List<ConditionModifier>(15);
private void OnAddScoreCondition()
{
ConditionModifier conditionModifier = new();
conditionModifier.SetFilterTypes(ConditionUtil.LevelScoreConditionFilter, true);
scoreTarget.Add(conditionModifier);
}
2024-06-04 16:50:16 +08:00
2025-02-21 17:03:56 +08:00
/// <summary>
/// 刷新生成点位
/// </summary>
[HideInInspector] public List<int> refreshPoints = new List<int>();
/// <summary>
/// 指定路线
/// </summary>
[HideInInspector] public List<PrescribedRoadInfo> roadInfos = new List<PrescribedRoadInfo>(4);
2024-11-12 20:31:06 +08:00
[HideInInspector] public List<NPCInfo> npcInfos = new List<NPCInfo>(16);
2024-11-13 19:11:46 +08:00
[HideInInspector] public List<NPCInfo> selfNpcInfos = new List<NPCInfo>(16);
2024-11-12 20:31:06 +08:00
2024-11-25 13:39:03 +08:00
[Serializable]
public class CaptureInfo
{
2024-11-12 20:31:06 +08:00
[LabelText("占领点位")] public int CapturePoint;
[LabelText("占领时间")] public int CaptureProgress = 0;
}
2024-11-12 20:31:06 +08:00
[HideInInspector] public List<CaptureInfo> CapturePoints = new(8);
2024-11-12 20:31:06 +08:00
2024-11-07 15:05:36 +08:00
[HideInInspector] public List<int> flagStartPoints = new List<int>();
2024-11-12 20:31:06 +08:00
[HideInInspector] public List<int> flagEndPoints = new List<int>();
2024-11-12 20:31:06 +08:00
2024-11-11 13:46:47 +08:00
[HideInInspector] public List<int> fallbackSinglePoints = new List<int>();
2024-11-12 20:31:06 +08:00
2024-11-11 13:46:47 +08:00
[HideInInspector] public List<int> fallbackReusablePoints = new List<int>();
2024-11-12 20:31:06 +08:00
2024-11-26 16:58:42 +08:00
[HideInInspector] public int fallBackCount;
2023-11-08 15:05:19 +08:00
[OnDeserialized]
public void OnAfterDeserialize(StreamingContext context)
{
2023-11-21 15:04:56 +08:00
if (starTarget.Count != 3)
{
starTarget.Clear();
starTarget.Add(new ConditionModifier());
starTarget.Add(new ConditionModifier());
starTarget.Add(new ConditionModifier());
}
2024-11-12 20:31:06 +08:00
2023-11-08 15:05:19 +08:00
foreach (var starCondition in starTarget)
{
starCondition.SetFilterTypes(ConditionUtil.LevelStarConditionFilter);
}
2024-11-12 20:31:06 +08:00
2024-11-01 18:33:42 +08:00
foreach (var scoreCondition in scoreTarget)
{
scoreCondition.SetFilterTypes(ConditionUtil.LevelScoreConditionFilter, scoreLevel);
}
2023-11-08 15:05:19 +08:00
}
2023-08-22 19:08:45 +08:00
}
}