182 lines
5.2 KiB
C#
182 lines
5.2 KiB
C#
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 class Stage
|
||
{
|
||
[LabelText("名称")]
|
||
private string name;
|
||
[LabelText("描述")]
|
||
private string desc;
|
||
[FormerlySerializedAs("goal")]
|
||
[LabelText("胜利条件")]
|
||
public ConditionModifier successCondition = new();
|
||
[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);
|
||
}
|
||
}
|
||
}
|
||
|
||
public enum WeatherType
|
||
{
|
||
[LabelText("晴天")]
|
||
Sunny,
|
||
[LabelText("沙尘暴")]
|
||
SandStorm,
|
||
[LabelText("雨天")]
|
||
Rain,
|
||
[LabelText("雪天")]
|
||
Snow,
|
||
[LabelText("雾天")]
|
||
Fog,
|
||
}
|
||
|
||
public enum DayNightType
|
||
{
|
||
[LabelText("白天")]
|
||
Day,
|
||
[LabelText("晚上")]
|
||
Night,
|
||
}
|
||
|
||
[Serializable]
|
||
public class NPCInfo
|
||
{
|
||
[Sirenix.OdinInspector.ReadOnly]
|
||
public int id;
|
||
public int level;
|
||
[Sirenix.OdinInspector.ReadOnly]
|
||
public Vector2Int position;
|
||
[LabelText("AI类型")]
|
||
public AIType aIType;
|
||
[LabelText("特殊触发AI")]
|
||
public AttachAIType attachAIType;
|
||
[LabelText("朝向")]
|
||
public CharacterToward npcToward;
|
||
[LabelText("巡逻信息")]
|
||
public List<PatrolInfo> patrolInfos = new List<PatrolInfo>(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("出战区")]
|
||
[HideInInspector]
|
||
public int preparingRegionId;
|
||
|
||
[LabelText("出战区朝向")]
|
||
[HideInInspector]
|
||
public CharacterToward preparingRegionToward;
|
||
|
||
[LabelText("撤退区")]
|
||
[HideInInspector]
|
||
public int fallbackRegionId;
|
||
|
||
[LabelText("敌方撤退区")]
|
||
[HideInInspector]
|
||
public int enemyFallbackRegionId;
|
||
|
||
[LabelText("天气")]
|
||
public WeatherType weatherType = WeatherType.Sunny;
|
||
|
||
[LabelText("昼夜")]
|
||
public DayNightType dayNightType = DayNightType.Day;
|
||
|
||
[LabelText("阶段")]
|
||
public List<Stage> stages = new List<Stage>(8);
|
||
|
||
[LabelText("星级目标")]
|
||
[ListDrawerSettings(HideAddButton = true,HideRemoveButton = true)]
|
||
public List<ConditionModifier> starTarget = new List<ConditionModifier>(){new ConditionModifier(ConditionUtil.LevelStarConditionFilter),new ConditionModifier(ConditionUtil.LevelStarConditionFilter),new ConditionModifier(ConditionUtil.LevelStarConditionFilter)};
|
||
|
||
/*[InfoBox("敌人默认朝向为六边形TopLeft,以游戏视角的六边形为模板方向")]
|
||
[LabelText("敌人")] */
|
||
[HideInInspector]
|
||
public List<NPCInfo> npcInfos = new List<NPCInfo>(16);
|
||
|
||
[OnDeserialized]
|
||
public void OnAfterDeserialize(StreamingContext context)
|
||
{
|
||
foreach (var starCondition in starTarget)
|
||
{
|
||
starCondition.SetFilterTypes(ConditionUtil.LevelStarConditionFilter);
|
||
}
|
||
}
|
||
|
||
|
||
}
|
||
} |