using MongoDB.Bson.Serialization.Attributes; using MongoDB.Bson.Serialization.Options; using Sirenix.OdinInspector; using System.Collections; using System.Collections.Generic; using ET; using System.IO; using System; using UnityEngine; #if UNITY_EDITOR using UnityEditor; using System.Linq; #endif namespace Cal { [GUIColor(1, 0.6f, 0)] [Serializable] public struct ModifierId : IComparable, IComparable, IEquatable { #if UNITY_EDITOR [LabelText("技能Id")] // [ValueDropdown("Getparam1")] [BsonIgnore] private int param1 { get { return Value / 100; } set { Value = value * 100 + param2; } } [LabelText("编号")] // [ValueDropdown("Getparam2")] [BsonIgnore] private int param2 { get { return Value % 100; } set { Value = param1 * 100 + value; } } #endif public int CompareTo(object obj) { return this.Value.CompareTo(((ModifierId)obj).Value); } public int CompareTo(ModifierId other) { return this.Value.CompareTo(other.Value); } public bool Equals(ModifierId other) { return Value.Equals(other.Value); } public static bool operator ==(ModifierId a, ModifierId b) { return a.Equals(b); } public static bool operator !=(ModifierId a, ModifierId b) { return !a.Equals(b); } public override bool Equals(object obj) { return base.Equals(obj); } public override int GetHashCode() { return base.GetHashCode(); } public override string ToString() { return Value.ToString(); } [HideInInspector] public int Value; #if UNITY_EDITOR [ShowInInspector] [ReadOnly] [BsonIgnore] [LabelText("Id")] [LabelWidth(30)] private string ValueInInspector { get => $"{Value / 100}+{Value % 100}"; set { } } [ButtonGroup("自动匹配")] [Button("自动匹配ModifierId")] void AutoModifierId() { try { param1 = XNode.NodeGraph.activeGraph.As().Id; param2 = XNode.NodeGraph.activeGraph.As().maxModifierId++; UnityEditor.AssetDatabase.Refresh(); } catch (Exception e) { Log.Error(e); } } #endif } [BsonIgnoreExtraElements] [HideReferenceObjectPicker] [System.Serializable] public class ModifierConfig { //[LabelText("Modifier Id"), PropertyOrder(0)] //[HideInInspector] #if UNITY [SerializeField] #endif public ModifierId Id; [PropertyOrder(1)] public string name; #if UNITY_EDITOR [FoldoutGroup("属性"), PropertyOrder(2)] [LabelText("包括的等级数量")] [ShowInInspector] [PropertyRange(1, 10)] private int levelCount { get { if (levelList == null) return 0; return levelList.Count; } set { levelList = new List(); for (int i = 0; i < value; i++) { levelList.Add( i + 1); } } } #endif [FoldoutGroup("属性")] [LabelText("包括的等级"), PropertyOrder(3)] public List levelList = new List { 1 }; [FoldoutGroup("属性")] [LabelText("Tag"), PropertyOrder(4)] public ModifierTag tag; [FoldoutGroup("属性")] [LabelText("免疫的Tag"), PropertyOrder(4)] public ModifierTag immuneTag; [FoldoutGroup("属性")] [LabelText("免疫的Tag组"), PropertyOrder(4)] public ModifierTag[] immuneTagArr; [FoldoutGroup("属性")] [LabelText("属性"), PropertyOrder(4)] public ModifierAttribute attribute = ModifierAttribute.可刷新; [FoldoutGroup("属性")] [LabelText("可叠加类型"), PropertyOrder(5)] [OnValueChanged("ResetThinkInterval")] public OverlableBuffType overlayType = OverlableBuffType.无; private void ResetThinkInterval() { if (overlayType == OverlableBuffType.无) thinkInterval = new SkillParam { skillSourcetype = SkillSourcetype.None }; } [FoldoutGroup("属性")] [HideIf("overlayType", OverlableBuffType.无)] [LabelText("单次叠加层数"), PropertyOrder(5)] [SerializeField] public SkillParam perOverlay = new SkillParam { skillSourcetype = SkillSourcetype.Changable }; [FoldoutGroup("属性")] [LabelText("持续时间"), PropertyOrder(5)] [SerializeField] public SkillParam continueTime; [FoldoutGroup("属性"), PropertyOrder(8)] public BuffType buffType = BuffType.Buff; [FoldoutGroup("属性"), PropertyOrder(10)] [LabelText("是否能被驱散")] public bool canBeClear = false; [FoldoutGroup("属性"), PropertyOrder(13)] [LabelText("定时器类型")] public ThinkerType thinkerType = ThinkerType.无; [FoldoutGroup("属性"), PropertyOrder(13)] [LabelText("定时器间隔")] [ShowIf("thinkerType", ThinkerType.自定义)] #if UNITY [SerializeField] #endif public SkillParam thinkInterval = new SkillParam { skillSourcetype = SkillSourcetype.None }; [FoldoutGroup("属性"), PropertyOrder(13)] [LabelText("图标Id")] public string iconId; [FoldoutGroup("属性"), PropertyOrder(13)] [LabelText("图标描述")] public string iconDesc; [FoldoutGroup("属性"), PropertyOrder(13)] [LabelText("特效Id")] public int effectId; [FoldoutGroup("属性"), PropertyOrder(13)] [LabelText("特效附着点")] [HideIf("effectId", 0)] public EffectAttachType effectAttachType; [LabelText("修改属性"), PropertyOrder(14)] public ModifierValueType valueK; [LabelText("属性数值"), PropertyOrder(14)] [HideIf("valueK", ModifierValueType.无)] [SerializeField] public SkillParam valueV; [LabelText("修改状态"), PropertyOrder(15)] public ModifierStateType stateK; [LabelText("状态控制"), PropertyOrder(15)] [HideIf("stateK", ModifierStateType.无)] public StateStateType stateV; [LabelText("Modifier列表"), PropertyOrder(16)] #if UNITY_EDITOR [DictionaryDrawerSettings(DisplayMode = DictionaryDisplayOptions.ExpandedFoldout)] [HideInInspector] #endif [BsonDictionaryOptions(DictionaryRepresentation.ArrayOfArrays)] public Dictionary modifierEventDic; #if UNITY public ModifierConfig Clone() { modifierEventDic = null; ModifierConfig modifierConfig = new ModifierConfig(); 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(modifierConfig, fieldInfo.GetValue(this)); } } return modifierConfig; } public void CheckData() { if(overlayType == OverlableBuffType.无) { perOverlay.skillSourcetype = SkillSourcetype.None; perOverlay.values = null; } if(thinkerType == ThinkerType.无) { thinkInterval.skillSourcetype = SkillSourcetype.None; thinkInterval.values = null; } if(valueK == ModifierValueType.无) { valueV.skillSourcetype = SkillSourcetype.None; valueV.values = null; } } #endif } }