コード例 #1
0
ファイル: DialogueTypes.cs プロジェクト: XCVG/commoncore
 public SkillCheckNode(SkillCheckType checkType, SkillCheckComparison comparisonType, SkillCheckTarget targetType, string target, IComparable value, string passNext, string failNext, bool appendCheckText)
 {
     CheckType       = checkType;
     ComparisonType  = comparisonType;
     TargetType      = targetType;
     Target          = target;
     Value           = value;
     PassNext        = passNext;
     FailNext        = failNext;
     AppendCheckText = appendCheckText;
 }
コード例 #2
0
        public static SkillCheckNode ParseSkillCheck(JToken jt)
        {
            //parse check type
            string         checkTypeString = jt.Value <string>("checkType");
            SkillCheckType checkType       = (SkillCheckType)Enum.Parse(typeof(SkillCheckType), checkTypeString, true);

            //parse next values
            string passNext = jt.Value <string>("passNext");
            string failNext = jt.Value <string>("failNext");

            //parse appendCheckText
            bool appendCheckText = false;

            if (!jt["appendCheckText"].IsNullOrEmpty())
            {
                appendCheckText = jt["appendCheckText"].ToObject <bool>();
            }

            //parse target type and target
            SkillCheckTarget targetType = default;
            string           target     = null;

            if (!jt["stat"].IsNullOrEmpty())
            {
                targetType = SkillCheckTarget.Stat;
                target     = jt["stat"].ToString();
            }
            else if (!jt["skill"].IsNullOrEmpty())
            {
                targetType = SkillCheckTarget.Skill;
                target     = jt["skill"].ToString();
            }
            else if (!jt["av"].IsNullOrEmpty())
            {
                targetType = SkillCheckTarget.ActorValue;
                target     = jt["av"].ToString();
            }
            else
            {
                throw new NotSupportedException();
            }

            //parse comparison type and value
            SkillCheckComparison comparisonType = default;
            string comparisonFieldName          = null;

            if (!jt["greater"].IsNullOrEmpty())
            {
                comparisonType      = SkillCheckComparison.Greater;
                comparisonFieldName = "greater";
            }
            else if (!jt["greaterEqual"].IsNullOrEmpty())
            {
                comparisonType      = SkillCheckComparison.GreaterEqual;
                comparisonFieldName = "greaterEqual";
            }
            else if (!jt["equal"].IsNullOrEmpty())
            {
                comparisonType      = SkillCheckComparison.Equal;
                comparisonFieldName = "equal";
            }
            else if (!jt["less"].IsNullOrEmpty())
            {
                comparisonType      = SkillCheckComparison.Less;
                comparisonFieldName = "less";
            }
            else if (!jt["lessEqual"].IsNullOrEmpty())
            {
                comparisonType      = SkillCheckComparison.LessEqual;
                comparisonFieldName = "lessEqual";
            }
            else
            {
                throw new NotSupportedException();
            }

            string      valueString = jt.Value <string>(comparisonFieldName);
            IComparable value       = (IComparable)TypeUtils.StringToNumericAuto(valueString); //ouch

            return(new SkillCheckNode(checkType, comparisonType, targetType, target, value, passNext, failNext, appendCheckText));
        }