Exemplo n.º 1
0
        private static object GetDefaultValue(Type type, NodeFieldBaseAttribute att)
        {
            if (att.DefaultValue != null)
            {
                if ((BehaviorTreeArgsDict.IsEnumType(type) && BTEnvKey.None != att.DefaultValue.ToString()) || !BehaviorTreeArgsDict.IsEnumType(type))
                {
                    return(att.DefaultValue);
                }
            }
            object value = null;

            if (BehaviorTreeArgsDict.IsDoubleType(type))
            {
                value = default(double);
            }
            else if (BehaviorTreeArgsDict.IsStringType(type))
            {
                value = default(string);
            }
            else if (BehaviorTreeArgsDict.IsFloatType(type))
            {
                value = default(float);
            }
            else if (BehaviorTreeArgsDict.IsBoolType(type))
            {
                value = default(bool);
            }
            else if (BehaviorTreeArgsDict.IsIntType(type))
            {
                value = default(int);
            }
            else if (BehaviorTreeArgsDict.IsLongType(type))
            {
                value = default(long);
            }
            else if (BehaviorTreeArgsDict.IsIntArrType(type))
            {
                value = default(int[]);
            }
            else if (BehaviorTreeArgsDict.IsLongArrType(type))
            {
                value = default(long[]);
            }
            else if (BehaviorTreeArgsDict.IsDoubleArrType(type))
            {
                value = default(double[]);
            }
            else if (BehaviorTreeArgsDict.IsFloatArrType(type))
            {
                value = default(float[]);
            }
            else if (BehaviorTreeArgsDict.IsStringArrType(type))
            {
                value = default(string[]);
            }
            else if (BehaviorTreeArgsDict.IsObjectType(type))
            {
                value = default(Object);
            }
            else if (BehaviorTreeArgsDict.IsEnumType(type))
            {
                Array array = Enum.GetValues(type);
                value = array.GetValue(0).ToString();
            }
            else if (BehaviorTreeArgsDict.IsUnitConfigArrayType(type))
            {
            }
            else if (BehaviorTreeArgsDict.IsSpriteArrayType(type))
            {
                value = default(Sprite[]);
            }
            else if (BehaviorTreeArgsDict.IsObjectArrayType(type))
            {
                value = default(Object[]);
            }
            else if (BehaviorTreeArgsDict.IsConvertble(type))
            {
                value = 1f;
            }
            else
            {
                Log.Error($"行为树节点暂时未支持此类型:{type}!");
                return(null);
            }
            return(value);
        }
Exemplo n.º 2
0
 private void DrawProp(string nodeName, List <NodeFieldDesc> fieldList, NodeParamType nodeParamType)
 {
     for (int i = 0; i < fieldList.Count; i++)
     {
         NodeFieldDesc       desc       = fieldList[i];
         Type                fieldType  = ExportNodeTypeConfig.GetFieldType(nodeName, desc.name);
         ClientNodeTypeProto clientNode = ExportNodeTypeConfig.GetNodeTypeProtoFromDll(nodeName);
         object              newValue   = null;
         if (!mCurBehaviorNode.args_dict.ContainsKey(desc.name))
         {
             mCurBehaviorNode.args_dict.Add(desc.name, new ValueBase());
         }
         if (BehaviorTreeArgsDict.IsStringType(fieldType))
         {
             if (nodeParamType == NodeParamType.Input)
             {
                 newValue = InputEnumFieldValue(desc);
             }
             else if (nodeParamType == NodeParamType.Output && clientNode.classify == NodeClassifyType.Root.ToString())
             {
                 newValue = ConstTextFieldValue(desc);
             }
             else
             {
                 newValue = TextFieldValue(desc);
             }
         }
         else if (BehaviorTreeArgsDict.IsFloatType(fieldType))
         {
             newValue = FloatFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsDoubleType(fieldType))
         {
             newValue = DoubletFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsIntType(fieldType))
         {
             newValue = IntFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsLongType(fieldType))
         {
             newValue = LongFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsBoolType(fieldType))
         {
             newValue = BoolFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsObjectType(fieldType))
         {
             newValue = ObjectFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsIntArrType(fieldType))
         {
             newValue = IntArrFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsLongArrType(fieldType))
         {
             newValue = LongArrFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsStringArrType(fieldType))
         {
             newValue = StrArrFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsFloatArrType(fieldType))
         {
             newValue = FloatArrFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsDoubleArrType(fieldType))
         {
             newValue = DoubleArrFieldValue(desc);
         }
         else if (BehaviorTreeArgsDict.IsEnumType(fieldType))
         {
             if (nodeParamType == NodeParamType.Input)
             {
                 newValue = InputEnumFieldValue(desc);
             }
             else if (nodeParamType == NodeParamType.Output)
             {
                 newValue = OutPutEnumFieldValue(desc);
             }
             else
             {
                 newValue = EnumFieldValue(desc);
             }
         }
         else if (BehaviorTreeArgsDict.IsObjectArrayType(fieldType))
         {
             newValue = ObjectArrFieldValue(desc);
         }
         else
         {
             Log.Error($"行为树节点暂时未支持此类型:{fieldType}!");
             return;
         }
         mCurBehaviorNode.args_dict.SetKeyValueComp(fieldType, desc.name, newValue);
     }
 }