using Sirenix.OdinInspector; using System; using System.Collections.Generic; using System.ComponentModel; using System.Runtime.Serialization; using UnityEngine; using UnityEngine.Serialization; namespace Gameplay.Level { [Serializable] public class LevelData { [Serializable] public struct Goal { public enum GoalType { [LabelText("占领")] Occupy, [LabelText("撤退")] FallBack, [LabelText("歼灭")] KillAll, [LabelText("摧毁")] Destroy, } [LabelText("目标")] public GoalType goalType; [LabelText("位置"), ShowIf("@this.goalType == GoalType.Occupy || this.goalType == GoalType.FallBack")] public Vector2Int position; [LabelText("id"), ShowIf("@this.goalType == GoalType.Destroy")] [MinValue(1), DefaultValue(1)] public int id; } [Serializable] public struct StarGoal { public enum StarGoalType { [LabelText("无伤亡")] AllAlive, // 至少使用N个某职业角色 [LabelText("使用某职业")] LeastJob, [LabelText("使用某部队")] LeastFaction, [LabelText("使用某稀有度")] LeastRarity, [LabelText("时间内")] LeastTime, } [LabelText("星级目标")] public StarGoalType starGoalType; [LabelText("职业"), ShowIf("@this.starGoalType == StarGoalType.LeastJob")] public cfg.CharacterCfg.Ejob job; [LabelText("部队阵营"), ShowIf("@this.starGoalType == StarGoalType.LeastFaction")] public cfg.CharacterCfg.Efaction faction; [LabelText("稀有度"), ShowIf("@this.starGoalType == StarGoalType.LeastRarity")] public int rarity; [LabelText("最少数量"), ShowIf("@this.starGoalType == StarGoalType.LeastJob " + "|| this.starGoalType == StarGoalType.LeastFaction " + "|| this.starGoalType == StarGoalType.LeastRarity")] [MinValue(1)] public int count; [LabelText("时间内(秒)"), ShowIf("@this.starGoalType == StarGoalType.LeastTime")] [MinValue(1)] public int time; } [Serializable] public struct FailCondition { public enum FailType { [LabelText("我方全灭")] AllDead, } [LabelText("失败条件")] public FailType failType; } [Serializable] public class Stage { [LabelText("名称")] private string name; [LabelText("描述")] private string desc; [FormerlySerializedAs("goal")] [LabelText("胜利条件")] public ConditionModifier successCondition = new(); [LabelText("失败条件")] [ListDrawerSettings(CustomAddFunction = "OnAddFailCondition")] public List failConditions = new(); private void OnAddFailCondition() { ConditionModifier conditionModifier = new(); conditionModifier.SetFilterTypes(ConditionUtil.LevelFailConditionFilter); failConditions.Add(conditionModifier); } [OnDeserialized] public void OnAfterDeserialize(System.Runtime.Serialization.StreamingContext context) { successCondition.SetFilterTypes(ConditionUtil.LevelSuccessConditionFilter); foreach (var failCondition in failConditions) { failCondition.SetFilterTypes(ConditionUtil.LevelFailConditionFilter); } } } public enum WeatherType { [LabelText("晴天")] Sunny, [LabelText("沙尘暴")] SandStorm, [LabelText("雨天")] Rain, [LabelText("雪天")] Snow, [LabelText("雾天")] Fog, } public enum DayNightType { [LabelText("白天")] Day, [LabelText("晚上")] Night, } [Serializable] public class NPCInfo { public int id; public int level; public Vector2Int position; [LabelText("AI类型")] public AIType aIType; [LabelText("特殊触发AI")] public AttachAIType attachAIType; [LabelText("朝向")] public CharacterToward npcToward; [LabelText("巡逻信息")] public List patrolInfos = new List(4); } [Serializable] public class PatrolInfo { [HorizontalGroup("PatrolInfo")] [LabelText("巡逻点位")] public Vector2Int patrolPoint; [HorizontalGroup("PatrolInfo")] [LabelText("等待时间")] public float waitTime = 0f; } public enum CharacterToward { TopLeft, TopRight, Right, BottomRight, BottomLeft, Left, } public enum AIType { BasicAI, FallBackAI, FallBackIntensifyAI, OutflankAI, } public enum AttachAIType { None, ChainAI, ProvokeAI, SpecialBehaviorAI, } public LevelData(string id) { this.id = id; } [LabelText("关卡ID")] public string id; [Sirenix.OdinInspector.ReadOnly] [LabelText("地图名称")] public string mapName; [LabelText("出战区")] public int preparingRegionId; [LabelText("出战区朝向")] public CharacterToward preparingRegionToward; [LabelText("撤退区")] public int fallbackRegionId; [LabelText("敌方撤退区")] public int enemyFallbackRegionId; [LabelText("天气")] public WeatherType weatherType = WeatherType.Sunny; [LabelText("昼夜")] public DayNightType dayNightType = DayNightType.Day; [LabelText("阶段")] public List stages = new List(8); [LabelText("星级目标")] public List starGoals = new List(8); [InfoBox("敌人默认朝向为六边形TopLeft,以游戏视角的六边形为模板方向")] [LabelText("敌人")] public List npcInfos = new List(16); } }