145 lines
4.6 KiB
C#
145 lines
4.6 KiB
C#
|
using MongoDB.Bson.Serialization.Attributes;
|
|||
|
using MongoDB.Bson.Serialization.Options;
|
|||
|
using Sirenix.OdinInspector;
|
|||
|
using System.Collections;
|
|||
|
using System.Collections.Generic;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
namespace Cal
|
|||
|
{
|
|||
|
[HideReferenceObjectPicker]
|
|||
|
[System.Serializable]
|
|||
|
public struct CastParam
|
|||
|
{
|
|||
|
public SkillCastType skillCastType;
|
|||
|
|
|||
|
public CastBaseType castBaseType;
|
|||
|
|
|||
|
[LabelText("百分比(真实值)")]
|
|||
|
public float skillCast;
|
|||
|
|
|||
|
[ShowIf("castBaseType",CastBaseType.Other)]
|
|||
|
public AttributeType attributeType;
|
|||
|
}
|
|||
|
public class SkillLogicConfigCollection
|
|||
|
{
|
|||
|
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
|||
|
public Dictionary<int, SkillLogicConfig> skillDic = new Dictionary<int, SkillLogicConfig>();
|
|||
|
}
|
|||
|
|
|||
|
[BsonIgnoreExtraElements]
|
|||
|
[System.Serializable]
|
|||
|
public class SkillLogicConfig
|
|||
|
{
|
|||
|
[ReadOnly]
|
|||
|
[LabelText("技能Id"), PropertyOrder(-1)]
|
|||
|
[BsonRequired]
|
|||
|
public int skillId;
|
|||
|
|
|||
|
public string skillName;
|
|||
|
|
|||
|
[LabelText("最大等级")]
|
|||
|
public int maxLevel;
|
|||
|
|
|||
|
[LabelText("消耗")]
|
|||
|
[SerializeField]
|
|||
|
public CastParam cast = new CastParam { skillCastType = SkillCastType.消耗精力};
|
|||
|
|
|||
|
public SkillTypes skillType;
|
|||
|
|
|||
|
[SuffixLabel("毫秒",true)]
|
|||
|
public int CD;
|
|||
|
|
|||
|
[ShowIf("skillType",SkillTypes.引导)]
|
|||
|
[LabelText("引导持续时间")]
|
|||
|
[SuffixLabel("毫秒",true)]
|
|||
|
public int duration;
|
|||
|
|
|||
|
|
|||
|
[ShowIf("skillType", SkillTypes.引导)]
|
|||
|
[LabelText("引导触发间隔")]
|
|||
|
[SuffixLabel("毫秒", true)]
|
|||
|
public int interval;
|
|||
|
|
|||
|
[LabelText("队伍类型")]
|
|||
|
public Cal.TeamType teamType = TeamType.敌方队伍;
|
|||
|
|
|||
|
[LabelText("排除的类型(可多选)")]
|
|||
|
public Cal.TargetFlagType flagType = TargetFlagType.无法造成伤害的;
|
|||
|
|
|||
|
[LabelText("描述")]
|
|||
|
[LabelWidth(50)]
|
|||
|
[MultiLineProperty(3)]
|
|||
|
public string desc;
|
|||
|
|
|||
|
[DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.ExpandedFoldout)]
|
|||
|
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
|||
|
public Dictionary<SkillEventCondition, SkillOptionBase[]> skillEventDic;
|
|||
|
|
|||
|
|
|||
|
[LabelText("modifier列表")]
|
|||
|
[DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.ExpandedFoldout)]
|
|||
|
[BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)]
|
|||
|
[OnValueChanged("OnChangedDic", true)]
|
|||
|
public Dictionary<ModifierId, ModifierConfig> modifierDic;
|
|||
|
|
|||
|
#if UNITY_EDITOR
|
|||
|
private List<ModifierId> idList = new List<ModifierId>();
|
|||
|
private List<ModifierId> needModifiyIdList = new List<ModifierId>();
|
|||
|
private void OnChangedDic()
|
|||
|
{
|
|||
|
idList = idList ?? new List<ModifierId>();
|
|||
|
needModifiyIdList = needModifiyIdList ?? new List<ModifierId>();
|
|||
|
idList.Clear();
|
|||
|
needModifiyIdList.Clear();
|
|||
|
if (modifierDic == null)
|
|||
|
return;
|
|||
|
foreach (var kp in modifierDic)
|
|||
|
{
|
|||
|
if (kp.Key.Value / 100 != skillId)
|
|||
|
needModifiyIdList.Add(kp.Key);
|
|||
|
if (kp.Value == null) continue;
|
|||
|
if (kp.Value.Id.Value != kp.Key.Value)
|
|||
|
idList.Add(kp.Key);
|
|||
|
}
|
|||
|
foreach (var item in idList)
|
|||
|
{
|
|||
|
if (modifierDic.TryGetValue(item, out var modifierConfig))
|
|||
|
{
|
|||
|
modifierConfig.Id = new ModifierId
|
|||
|
{
|
|||
|
Value = item.Value
|
|||
|
};
|
|||
|
}
|
|||
|
}
|
|||
|
foreach (var item in needModifiyIdList)
|
|||
|
{
|
|||
|
if (!modifierDic.TryGetValue(item, out var modifierConfig))
|
|||
|
continue;
|
|||
|
modifierDic.Remove(item);
|
|||
|
modifierDic.Add(new ModifierId
|
|||
|
{
|
|||
|
Value = item.Value % 100 + skillId * 100
|
|||
|
}, modifierConfig);
|
|||
|
}
|
|||
|
}
|
|||
|
public void Clone(SkillLogicConfig _logic)
|
|||
|
{
|
|||
|
skillEventDic = null;
|
|||
|
modifierDic = null;
|
|||
|
System.Type type = this.GetType();
|
|||
|
var arr = type.GetFields(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
|
|||
|
foreach (var fieldInfo in arr)
|
|||
|
{
|
|||
|
if (fieldInfo.DeclaringType == type)
|
|||
|
{
|
|||
|
fieldInfo.SetValue(_logic, fieldInfo.GetValue(this));
|
|||
|
}
|
|||
|
}
|
|||
|
_logic.skillId = skillId;
|
|||
|
}
|
|||
|
#endif
|
|||
|
}
|
|||
|
|
|||
|
}
|