188 lines
6.6 KiB
C#
188 lines
6.6 KiB
C#
using System;
|
|
using UnityEngine;
|
|
using Sirenix.OdinInspector;
|
|
using UnityEngine.Serialization;
|
|
using System.Collections.Generic;
|
|
using System.Runtime.Serialization;
|
|
|
|
namespace Gameplay.Level
|
|
{
|
|
[Serializable]
|
|
public class LevelData
|
|
{
|
|
[Serializable]
|
|
public class Stage
|
|
{
|
|
[LabelText("名称")] private string name;
|
|
[LabelText("描述")] private string desc;
|
|
|
|
[FormerlySerializedAs("goal")] [LabelText("胜利条件")]
|
|
public ConditionModifier successCondition = new(ConditionUtil.LevelSuccessConditionFilter);
|
|
|
|
[LabelText("失败条件")] [ListDrawerSettings(CustomAddFunction = "OnAddFailCondition")]
|
|
public List<ConditionModifier> 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);
|
|
}
|
|
}
|
|
}
|
|
|
|
[Serializable]
|
|
public class NPCInfo
|
|
{
|
|
[HideInInspector] public int index;
|
|
[HideInInspector] public int id;
|
|
[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);
|
|
[LabelText("编组")] public List<int> groups = new List<int>(4);
|
|
[LabelText("防守距离")] public int defensiveDistance;
|
|
}
|
|
|
|
[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,
|
|
DefendAI,
|
|
StupidDefendAI,
|
|
None,
|
|
}
|
|
|
|
public enum AttachAIType
|
|
{
|
|
None,
|
|
ChainAI,
|
|
ProvokeAI,
|
|
SpecialBehaviorAI,
|
|
AttackProtectUnitAI,
|
|
}
|
|
|
|
public LevelData()
|
|
{
|
|
}
|
|
|
|
[LabelText("出战区")] [HideInInspector] public int preparingRegionId;
|
|
|
|
[LabelText("出战区朝向")] [HideInInspector] public CharacterToward preparingRegionToward;
|
|
|
|
[LabelText("撤退区")] [HideInInspector] public int fallbackRegionId;
|
|
|
|
[LabelText("敌方撤退区")] [HideInInspector] public int enemyFallbackRegionId;
|
|
|
|
[LabelText("PVP防守区")] [HideInInspector]
|
|
public int pvpDefendRegionId;
|
|
|
|
[LabelText("PVP防守方朝向")] [HideInInspector]
|
|
public CharacterToward pvpDefendToward;
|
|
|
|
[LabelText("阶段")] public List<Stage> stages = new List<Stage>(8);
|
|
|
|
[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)
|
|
};
|
|
|
|
[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);
|
|
}
|
|
|
|
[HideInInspector] public List<NPCInfo> npcInfos = new List<NPCInfo>(16);
|
|
|
|
[HideInInspector] public List<NPCInfo> selfNpcInfos = new List<NPCInfo>(16);
|
|
|
|
[Serializable]
|
|
public class CaptureInfo
|
|
{
|
|
[LabelText("占领点位")] public int CapturePoint;
|
|
[LabelText("占领时间")] public int CaptureProgress = 0;
|
|
}
|
|
|
|
[HideInInspector] public List<CaptureInfo> CapturePoints = new(8);
|
|
|
|
[HideInInspector] public List<int> flagStartPoints = new List<int>();
|
|
|
|
[HideInInspector] public List<int> flagEndPoints = new List<int>();
|
|
|
|
[HideInInspector] public List<int> fallbackSinglePoints = new List<int>();
|
|
|
|
[HideInInspector] public List<int> fallbackReusablePoints = new List<int>();
|
|
|
|
[HideInInspector] public int fallBackCount;
|
|
|
|
[OnDeserialized]
|
|
public void OnAfterDeserialize(StreamingContext context)
|
|
{
|
|
if (starTarget.Count != 3)
|
|
{
|
|
starTarget.Clear();
|
|
starTarget.Add(new ConditionModifier());
|
|
starTarget.Add(new ConditionModifier());
|
|
starTarget.Add(new ConditionModifier());
|
|
}
|
|
|
|
foreach (var starCondition in starTarget)
|
|
{
|
|
starCondition.SetFilterTypes(ConditionUtil.LevelStarConditionFilter);
|
|
}
|
|
|
|
foreach (var scoreCondition in scoreTarget)
|
|
{
|
|
scoreCondition.SetFilterTypes(ConditionUtil.LevelScoreConditionFilter, scoreLevel);
|
|
}
|
|
}
|
|
}
|
|
} |