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

659 lines
22 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using UnityEngine;
using Sirenix.OdinInspector;
using System.Collections.Generic;
using System.Runtime.Serialization;
using cfg.AICfg;
namespace Gameplay.Level
{
[Serializable]
public class LevelData
{
#region class
[Serializable]
public class Region
{
public int id;
public List<int> positions = new();
[LabelText("手动指定中心格子索引")] public int centerCellIndex = -1;
public string note; // 策划使用备注
}
[Serializable]
public class BlockRegion
{
public int id;
public List<int> positions = new();
/// <summary>
/// 指示路径
/// </summary>
public string path;
/// <summary>
/// 指示位置
/// </summary>
public Vector3 centerPos = Vector3.zero;
public string note; // 策划使用备注
}
[Serializable]
public class NPCInfo
{
[HideInInspector] public int index; // LocalID
[HideInInspector] public int id; // 怪物ID
[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>();
[HideInInspector] public CharacterToward npcToward;
[HideInInspector] public List<int> groups = new List<int>(4);
[HideInInspector] public bool isHideOnLoad;
[ReadOnly][LabelText("所属波数")] public int waveIndex;
[LabelText("延迟出现时间(s)")] public float refreshTime;
[LabelText("巡逻路线ID")] public int patrolRoadID = -1;
[LabelText("显示路径")] public bool showRoadLine;
[LabelText("指定区域ID")] public int specifyRegionID = -1;
[LabelText("预设路径id")] public int presetPathId = -1;
[LabelText("阵营ID 0:己方1:敌方2:中立")] public int troopId;
[LabelText("是否开启侦察")] public bool isOpenInvestigate = true;
}
[Serializable]
public class PatrolInfo
{
[HorizontalGroup("PatrolInfo")] [LabelText("巡逻点位")]
public int cellIndex;
[HideInInspector] public Vector2Int patrolPoint;
[HorizontalGroup("PatrolInfo")] [LabelText("等待时间")]
public float waitTime = 0f;
}
[Serializable]
public class PatrolData
{
[HorizontalGroup("PatrolData")] [ReadOnly]
public int id;
[HorizontalGroup("PatrolData")] [LabelText("巡逻点位数据")]
public List<PatrolInfo> patrolInfos = new();
}
[Serializable]
public class TaskInfo
{
[HideInInspector] public int taskID;
[LabelText("任务类型")] public ConditionModifier taskCondition = new(ConditionUtil.GetAllConditionFilter());
[LabelText("任务注释")] public string taskNote; // 策划使用备注
[LabelText("任务文本替换")] public string taskDesc; // 手写stringKey
[LabelText("前置任务")] public int preTaskID;
[LabelText("后置任务")] public int postTaskID;
[OnDeserialized]
public void OnAfterDeserialize(StreamingContext context)
{
taskCondition.SetFilterTypes(ConditionUtil.GetAllConditionFilter());
}
}
[Serializable]
public class SpawnMonsterData
{
[LabelText("波次ID")] public int waveIndex;
[LabelText("刷新方式")] public ELevelUnitGenType refreshType = ELevelUnitGenType.Default;
[LabelText("间隔时间")] [ShowIf("@refreshType==ELevelUnitGenType.TimeLoop")]
public int refreshInterval;
[LabelText("最大次数 (-1无限循环), 如果为跳转则表示跳转ID")]
public int maxCount;
[LabelText("首波延迟时间")] public float firstDelay = 1f; // 首次延迟时间
}
[Serializable]
public class LevelTriggerData
{
[HideInInspector] public int triggerTaskID;
[LabelText("刷怪波次")] public int wave;
[LabelText("触发Effect类型")] public ELevelTriggerEffectType effectType = ELevelTriggerEffectType.StartGenUnit;
[LabelText("怪物波次IDs")] [ShowIf("@effectType==ELevelTriggerEffectType.ForceKillUnits")]
public List<int> waveList = new List<int>();
[LabelText("触发间隔")] [ShowIf("@effectType==ELevelTriggerEffectType.StartFullSceneDamage")]
public float repeatInterval = 3f; // 重复触发间隔(秒)默认3秒
[LabelText("伤害buffId")] [ShowIf("@effectType==ELevelTriggerEffectType.StartFullSceneDamage")]
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;
[HideInInspector] [LabelText("区域争夺触发区ID")] public int triggerTaskID;
[LabelText("占领时间")] public float captureTime;
}
[Serializable]
public class RadarInfo
{
[LabelText("雷达建筑LocalID")] public int localId;
[LabelText("雷达范围(半径圈数)")] public int range;
[LabelText("占领时间")] public float captureTime;
[LabelText("扫描速度(度/秒)")] public float scanSpeed = 60f;
}
[Serializable]
public class SearchLightInfo
{
[LabelText("探照灯建筑LocalID")] public int localID;
[LabelText("初始位置")]public int startCellIndex;
[HideInInspector] public List<int> interactivePoints = new List<int>();
[LabelText("点位时间")] public float captureTime;
[LabelText("照亮范围")]public int range;
[LabelText("是否循环 (否为折返)")]public bool isLoop;
}
[Serializable]
public class BombAreaInfo
{
[HideInInspector] [LabelText("触发条件")] public int triggerTaskID;
[LabelText("轰炸间隔")] public float intervalTime;
[LabelText("轰炸次数")] public int bombCount;
[LabelText("最小轰炸中心数量")] public int bombMinCount;
[LabelText("最大轰炸中心数量")] public int bombMaxCount;
}
#region LevelGuide
/// <summary>
/// 波次横幅显示
/// </summary>
[Serializable]
public class WaveInfoData
{
[ReadOnly] [LabelText("ID")] public int localID;
[LabelText("触发波次ID")] public int waveID = -1;
[LabelText("第几次循环")] public int loopCount = 1;
[LabelText("是否显示横幅")] public bool showWaveInfo;
}
/// <summary>
/// 关卡进度引导
/// </summary>
[Serializable]
public class ProgressGuideData
{
[LabelText("ID")] public int id;
[LabelText("关卡进度参数:类型")] public ELevelGuideProgressType progressType;
[HideInInspector] [LabelText("触发条件")] public int triggerTaskID;
[HideInInspector] [LabelText("完成条件")] public int finishTaskID;
public ProgressGuideData(ProgressGuideData data)
{
progressType = data.progressType;
triggerTaskID = data.triggerTaskID;
finishTaskID = data.finishTaskID;
}
public ProgressGuideData()
{
progressType = ELevelGuideProgressType.SuccessProgress;
}
}
/// <summary>
/// 关卡立标引导
/// </summary>
[Serializable]
public class SetFlagGuideData
{
[LabelText("ID")] public int id;
[LabelText("立标类型")] public ELevelGuideSetFlagType setFlagType;
[LabelText("选择单位类型")] [ShowIf("@setFlagType==ELevelGuideSetFlagType.Unit")]
public ESetFlagUnitType unitType;
[LabelText("对应ID")] public int setFlagID;
[HorizontalGroup("1")] [LabelText("立标提示内容")]
public string setFlagKey;
[HorizontalGroup("1")] [LabelText("备注")]
public string note; // 策划使用备注
[HideInInspector] [LabelText("立标配置ID")]
public int guideTagID; // 编辑器使用
[HideInInspector] [LabelText("立标路径")] public string guideTagPath;
[HideInInspector] [LabelText("触发条件")] public int triggerTaskID;
[HideInInspector] [LabelText("完成条件")] public int finishTaskID;
public SetFlagGuideData(SetFlagGuideData data)
{
setFlagType = data.setFlagType;
unitType = data.unitType;
setFlagID = data.setFlagID;
setFlagKey = data.setFlagKey;
guideTagID = data.guideTagID;
guideTagPath = data.guideTagPath;
triggerTaskID = data.triggerTaskID;
finishTaskID = data.finishTaskID;
}
public SetFlagGuideData()
{
setFlagType = ELevelGuideSetFlagType.CellIndex;
unitType = ESetFlagUnitType.Self;
setFlagID = -1;
}
}
/// <summary>
/// 关卡信息面板引导
/// </summary>
[Serializable]
public class InfoPanelGuideData
{
[LabelText("ID")] public int id;
[HorizontalGroup("1")] [LabelText("标题ID")]
public string titleKey;
[HorizontalGroup("1")] [LabelText("备注")]
public string noteTitle; // 策划使用备注
[HorizontalGroup("2")] [LabelText("内容ID")]
public string contentKey;
[HorizontalGroup("2")] [LabelText("备注")]
public string noteContent; // 策划使用备注
[HideInInspector] [LabelText("触发条件")] public int triggerTaskID;
[HideInInspector] [LabelText("完成条件")] public int finishTaskID;
public InfoPanelGuideData(InfoPanelGuideData data)
{
titleKey = data.titleKey;
contentKey = data.contentKey;
triggerTaskID = data.triggerTaskID;
finishTaskID = data.finishTaskID;
}
public InfoPanelGuideData()
{
}
}
#endregion
#region 关卡AI广播
/// <summary>
/// AI广播对象类型
/// </summary>
public enum E_AIBroadcastTargetType
{
[LabelText("怪物组")] EnemyGroup,
[LabelText("所有怪物,包括未出生的")] AllEnemy,
[LabelText("所有怪物,不包括未出生的")] AllCurEnemy,
[LabelText("怪物")] Enemy,
}
/// <summary>
/// AI行为目标类型
/// </summary>
public enum E_AIActionTarget
{
[LabelText("单位目标")] Unit,
[LabelText("建筑目标")] Build,
[LabelText("地格目标")] Cell,
[LabelText("区域目标")] Area,
[LabelText("路径ID")] Path,
[LabelText("我方全体非强隐单位")] SelfTroop,
}
/// <summary>
/// AI预设切换类型
/// </summary>
public enum E_AIPresetChangeType
{
None,
[LabelText("整体预设")] All = 1,
[LabelText("区域巡逻")] AreaPatrol = 2,
[LabelText("路径巡逻")] PathPatrol = 3,
[LabelText("驻守")] Idle = 4,
[LabelText("常规到达")] NormalReach = 5,
//[LabelText("上车到达")]
//VehicleReach = 6,
[LabelText("存活")] Living = 7,
[LabelText("常规")] Normal = 8,
[LabelText("舍命")] LayLive = 9,
[LabelText("牛皮糖")] StickyCandy = 10,
}
/// <summary>
/// AI广播数据
/// </summary>
[Serializable]
public sealed class AIBroadcastData
{
[HideInInspector] [LabelText("触发条件")] public int triggerTaskID;
[LabelText("AI广播对象类型")] public E_AIBroadcastTargetType aiBroadcastTargetType;
[LabelText("目标id列表")]
[ShowIf(
"@E_AIBroadcastTargetType.EnemyGroup == aiBroadcastTargetType || E_AIBroadcastTargetType.Enemy == aiBroadcastTargetType")]
public List<int> listTargetId;
[LabelText("AI行为")] public EAIAction AIAction;
[LabelText("AI行为目标")] [ShowIf("@EAIAction.None != AIAction")]
public E_AIActionTarget AIActionTarget;
[LabelText("单位目标id")]
[ShowIf("@EAIAction.None != AIAction && AIActionTarget != E_AIActionTarget.SelfTroop")]
public int actionTargetId;
[LabelText("AI状态切换")] public EAIState AIState;
[LabelText("AI预设切换类型")] public E_AIPresetChangeType AIPresetChangeType;
[LabelText("AI预设ID")] [ShowIf("@E_AIPresetChangeType.All == AIPresetChangeType")]
public int AIPresetId;
[LabelText("是否循环巡逻true:循环false:往返")]
[ShowIf(
"@E_AIPresetChangeType.AreaPatrol == AIPresetChangeType || E_AIPresetChangeType.PathPatrol == AIPresetChangeType")]
public bool isLoopPatrol;
[LabelText("巡逻地点ID")]
[ShowIf(
"@E_AIPresetChangeType.AreaPatrol == AIPresetChangeType || E_AIPresetChangeType.PathPatrol == AIPresetChangeType")]
public int PatrolId;
[LabelText("入住建筑类型")]
[ShowIf(
"@E_AIPresetChangeType.Idle == AIPresetChangeType || E_AIPresetChangeType.Normal == AIPresetChangeType || E_AIPresetChangeType.Living == AIPresetChangeType")]
public List<int> listBuildType;
[LabelText("是否回到出生点")] [ShowIf("@E_AIPresetChangeType.Idle == AIPresetChangeType")]
public bool IsBackBirth;
#region 常规到达
[LabelText("前进速度类型true:移速false:巡逻速度")] [ShowIf("@E_AIPresetChangeType.NormalReach == AIPresetChangeType")]
public bool reachSpeedType;
[LabelText("遇敌后是否攻击")] [ShowIf("@E_AIPresetChangeType.NormalReach == AIPresetChangeType")]
public bool reachOpenAttack;
#endregion
#region 存活
[LabelText("是否回到上一个状态")] [ShowIf("@E_AIPresetChangeType.Living == AIPresetChangeType")]
public bool isBackState;
[LabelText("是否限制追踪距离")]
[ShowIf(
"@E_AIPresetChangeType.Normal == AIPresetChangeType || E_AIPresetChangeType.LayLive == AIPresetChangeType")]
public bool isLimitDistance;
#endregion
}
#endregion
/// <summary>
/// 角色方向(兼容老方向)
/// </summary>
public enum CharacterToward
{
Toward1 = 6,
Toward2 = 1,
Toward3 = 7,
Toward4 = 2,
Toward5 = 8,
Toward6 = 3,
Toward7 = 9,
Toward8 = 4,
Toward9 = 10,
Toward10 = 5,
Toward11 = 11,
Toward12 = 0,
}
/// <summary>
/// 占领数据
/// </summary>
[Serializable]
public class CaptureInfo
{
[LabelText("占领区ID")] public int captureRegionID;
[LabelText("占领点位")] public List<int> capturePoints = new List<int>();
[LabelText("进度标识点")] public int captureFlag;
[LabelText("占领时间")] public int CaptureProgress = 0;
[LabelText("占领地面特效ID")] public int captureEffectID;
[LabelText("占领地面完成特效ID")] public int captureFinishEffectID;
[LabelText("占领地面特效创建地格")] public int captureEffectPoint;
}
/// <summary>
/// 撤离数据
/// </summary>
[Serializable]
public class RetreatInfo
{
public List<int> retreatPoints = new List<int>();
public int retreatFlag;
}
[Serializable]
public class GroupInfo
{
public int groupID;
public string groupName;
}
#endregion
public LevelData()
{
}
[HideInInspector] public List<TaskInfo> taskInfos = new();
/// <summary>
/// 巡逻路径
/// </summary>
[HideInInspector] public List<PatrolData> patrolRoadData = new();
/// <summary>
/// 巡逻区域
/// </summary>
[HideInInspector] public List<PatrolData> patrolRegionData = new();
#region 关卡胜利失败星级条件
[HideInInspector] public int successTaskID;
[HideInInspector] public int failTaskID;
[HideInInspector] public List<int> starTaskIDs = new() { 0, 0, 0 };
#endregion
#region 评分关卡条件
[BoxGroup("支线(战役)")] [LabelText("设置该关卡为评分关卡")] [HideInInspector]
public bool scoreLevel;
[HideInInspector] public List<int> scoreTaskID = new(15);
[HideInInspector] public List<ConditionModifier> scoreTarget = new(15);
#endregion
[HideInInspector] public List<LevelTriggerData> levelTriggerDatas = new();
[BoxGroup("特殊需求")] [LabelText("初始生命百分值")]
public float initialHealthPercent = 1.0f;
[BoxGroup("特殊需求")] [LabelText("初始护盾百分值")]
public float initialShieldPercent = 1.0f;
[BoxGroup("敌人波次管理")] [LabelText("敌人波次刷新类型")]
public List<SpawnMonsterData> spawnMonsterDatas;
[BoxGroup("敌人波次管理")] [LabelText("波次横幅显示数据")] [ListDrawerSettings(CustomAddFunction = "OnAddWaveInfoData")]
public List<WaveInfoData> waveInfoDatas = new();
private void OnAddWaveInfoData()
{
var waveInfoData = new WaveInfoData
{
localID = waveInfoDatas.Count + 1
};
waveInfoDatas.Add(waveInfoData);
}
#region 关卡引导
[HideInInspector] [LabelText("关卡进度")] public List<ProgressGuideData> progressGuideDatas = new();
[HideInInspector] [LabelText("立标数据")] public List<SetFlagGuideData> setFlagGuideDatas = new();
[HideInInspector] [LabelText("信息板数据")] public List<InfoPanelGuideData> infoPanelGuideDatas = new();
#endregion
#region 关卡AI广播
[HideInInspector] [LabelText("关卡AI广播进度")]
public List<AIBroadcastData> listAIBroadcastData = new();
#endregion
[HideInInspector] public List<NPCInfo> npcInfos = new();
[HideInInspector] public List<NPCInfo> midNpcInfos = new();
[HideInInspector] public List<NPCInfo> selfNpcInfos = new();
[HideInInspector] public Dictionary<int, List<int>> npcGroupInfos = new();
/// <summary>
/// 阻挡攻击数据
/// </summary>
[HideInInspector] public List<MapData.BlockSphereInfo> BlockSphereInfos = new();
[HideInInspector] public List<CaptureInfo> CapturePoints = new(8);
[HideInInspector] public List<int> enemyRetreatReusablePoints = new List<int>();
[HideInInspector] public RetreatInfo retreatPoints = new RetreatInfo();
[HideInInspector] public int fallBackCount;
#region 地区相关
/// <summary>
/// 出战区
/// </summary>
[HideInInspector] public int preparingRegionId;
/// <summary>
/// 出战区朝向
/// </summary>
[HideInInspector] public CharacterToward preparingRegionToward;
/// <summary>
/// PVP防守区
/// </summary>
[HideInInspector] public int pvpDefendRegionId;
/// <summary>
/// PVP防守方朝向
/// </summary>
[HideInInspector] public CharacterToward pvpDefendToward;
/// <summary>
/// 雷区
/// </summary>
[HideInInspector] public List<Region> minesRegions = new();
/// <summary>
/// 阻挡区
/// </summary>
[HideInInspector] public List<BlockRegion> blockRegions = new();
/// <summary>
/// 触发区
/// </summary>
[HideInInspector] public List<Region> defenseRegions = new();
/// <summary>
/// 战旗
/// </summary>
[HideInInspector] public List<HoldFlagData> holdGFlagInfos = new List<HoldFlagData>();
/// <summary>
/// 雷达信息
/// </summary>
[HideInInspector] public List<RadarInfo> radarInfos = new List<RadarInfo>();
/// <summary>
/// 探照灯信息
/// </summary>
[HideInInspector] public List<SearchLightInfo> searchLightInfos = new List<SearchLightInfo>();
/// <summary>
/// 轰炸区信息
/// </summary>
[HideInInspector] public List<BombAreaInfo> bombAreaInfos = new List<BombAreaInfo>();
#endregion
#region 怪物组相关 策划使用
[HideInInspector] public List<GroupInfo> groupInfos = new();
#endregion
}
}