91 lines
3.0 KiB
C#
91 lines
3.0 KiB
C#
|
|
using ET;
|
|
using MongoDB.Bson.Serialization.Attributes;
|
|
using Sirenix.OdinInspector;
|
|
#if UNITY_EDITOR
|
|
using UnityEngine;
|
|
using XNode;
|
|
#endif
|
|
|
|
namespace Cal
|
|
{
|
|
[GUIColor(0.5f, 0.8f, 0.5f)]
|
|
[System.Serializable]
|
|
[BsonIgnoreExtraElements]
|
|
public class SkillOption_几率 : SkillOptionBase
|
|
{
|
|
public override SkillOptionType optionType => SkillOptionType.几率;
|
|
|
|
[BoxGroup("$optionType", CenterLabel = true)]
|
|
[LabelText("几率(0-1)")]
|
|
#if UNITY
|
|
[SerializeField]
|
|
#endif
|
|
public SkillParam param;
|
|
|
|
[HideInInspector]
|
|
public SkillOptionBase[] succeedOptionList;
|
|
|
|
[HideInInspector]
|
|
public SkillOptionBase[] failOptionList;
|
|
#if UNITY
|
|
[LabelText("成功操作")]
|
|
[BsonIgnore]
|
|
[Output] public float succeedOptions;
|
|
[LabelText("失败操作")]
|
|
[BsonIgnore]
|
|
[Output] public float failOptions;
|
|
public override NodePort GetNodePort(string fieldName)
|
|
{
|
|
if (fieldName == nameof(succeedOptionList))
|
|
{
|
|
return GetOutputPort("succeedOptions");
|
|
}
|
|
else
|
|
if (fieldName == nameof(failOptionList))
|
|
{
|
|
return GetOutputPort("failOptions");
|
|
}
|
|
return null;
|
|
}
|
|
public override void Serilize(SkillOptionBase skillOption)
|
|
{
|
|
var succeed = GetOutputPort("succeedOptions");
|
|
if (succeed.IsConnected)
|
|
{
|
|
var targetArr = new SkillOptionBase[0];
|
|
foreach (var port in succeed.GetConnections())
|
|
{
|
|
SkillOptionBase _skillOption = System.Activator.CreateInstance(port.node.GetType()) as SkillOptionBase;
|
|
port.node.As<SkillOptionBase>().DeepClone(_skillOption);
|
|
port.node.As<SkillOptionBase>().Clear();
|
|
UnityEditor.ArrayUtility.Add(ref targetArr, _skillOption);
|
|
_skillOption.Serilize(_skillOption);
|
|
}
|
|
skillOption.As<SkillOption_几率>().succeedOptionList = targetArr;
|
|
}
|
|
var fail = GetOutputPort("failOptions");
|
|
if (fail.IsConnected)
|
|
{
|
|
var targetArr = new SkillOptionBase[0];
|
|
foreach (var port in fail.GetConnections())
|
|
{
|
|
SkillOptionBase _skillOption = System.Activator.CreateInstance(port.node.GetType()) as SkillOptionBase;
|
|
port.node.As<SkillOptionBase>().DeepClone(_skillOption);
|
|
port.node.As<SkillOptionBase>().Clear();
|
|
UnityEditor.ArrayUtility.Add(ref targetArr, _skillOption);
|
|
_skillOption.Serilize(_skillOption);
|
|
}
|
|
skillOption.As<SkillOption_几率>().failOptionList = targetArr;
|
|
}
|
|
}
|
|
internal override void Clear()
|
|
{
|
|
succeedOptionList = null;
|
|
failOptionList = null;
|
|
}
|
|
#endif
|
|
|
|
}
|
|
}
|