예제 #1
0
        public static BTData.BaseField CreateVariableField(VariableFieldDesigner variableFieldData)
        {
            BTData.BaseField data = null;

            switch (variableFieldData.VariableFieldType)
            {
            case FieldType.IntField:
                BTData.IntField  intField         = new BTData.IntField();
                IntFieldDesigner intFieldDesigner = variableFieldData.Value as IntFieldDesigner;
                intField.FieldName = variableFieldData.VariableFieldName;
                intField.Value     = intFieldDesigner.Value;
                data = intField;
                break;

            case FieldType.LongField:
                BTData.LongField  longField         = new BTData.LongField();
                LongFieldDesigner longFieldDesigner = variableFieldData.Value as LongFieldDesigner;
                longField.FieldName = variableFieldData.VariableFieldName;
                longField.Value     = longFieldDesigner.Value;
                data = longField;
                break;

            case FieldType.FloatField:
                BTData.FloatField  floatField         = new BTData.FloatField();
                FloatFieldDesigner floatFieldDesigner = variableFieldData.Value as FloatFieldDesigner;
                floatField.FieldName = variableFieldData.VariableFieldName;
                floatField.Value     = floatFieldDesigner.Value;
                data = floatField;
                break;

            case FieldType.DoubleField:
                BTData.DoubleField  doubleField         = new BTData.DoubleField();
                DoubleFieldDesigner doubleFieldDesigner = variableFieldData.Value as DoubleFieldDesigner;
                doubleField.FieldName = variableFieldData.VariableFieldName;
                doubleField.Value     = doubleFieldDesigner.Value;
                data = doubleField;
                break;

            case FieldType.StringField:
                BTData.StringField  stringField         = new BTData.StringField();
                StringFieldDesigner stringFieldDesigner = variableFieldData.Value as StringFieldDesigner;
                stringField.FieldName = variableFieldData.VariableFieldName;
                stringField.Value     = stringFieldDesigner.Value;
                data = stringField;
                break;

            case FieldType.BooleanField:
                BTData.BooleanField  booleanField         = new BTData.BooleanField();
                BooleanFieldDesigner booleanFieldDesigner = variableFieldData.Value as BooleanFieldDesigner;
                booleanField.FieldName = variableFieldData.VariableFieldName;
                booleanField.Value     = booleanFieldDesigner.Value;
                data = booleanField;
                break;
            }

            return(data);
        }
예제 #2
0
        public static BTData.BaseField CreateField(FieldDesigner fieldData)
        {
            BTData.BaseField data = null;

            switch (fieldData.FieldType)
            {
            case FieldType.IntField:
                BTData.IntField  intField         = new BTData.IntField();
                IntFieldDesigner intFieldDesigner = fieldData.Field as IntFieldDesigner;
                intField.FieldName = fieldData.FieldName;
                intField.Value     = intFieldDesigner.Value;
                data = intField;
                break;

            case FieldType.LongField:
                BTData.LongField  longField         = new BTData.LongField();
                LongFieldDesigner longFieldDesigner = fieldData.Field as LongFieldDesigner;
                longField.FieldName = fieldData.FieldName;
                longField.Value     = longFieldDesigner.Value;
                data = longField;
                break;

            case FieldType.FloatField:
                BTData.FloatField  floatField         = new BTData.FloatField();
                FloatFieldDesigner floatFieldDesigner = fieldData.Field as FloatFieldDesigner;
                floatField.FieldName = fieldData.FieldName;
                floatField.Value     = floatFieldDesigner.Value;
                data = floatField;
                break;

            case FieldType.DoubleField:
                BTData.DoubleField  doubleField         = new BTData.DoubleField();
                DoubleFieldDesigner doubleFieldDesigner = fieldData.Field as DoubleFieldDesigner;
                doubleField.FieldName = fieldData.FieldName;
                doubleField.Value     = doubleFieldDesigner.Value;
                data = doubleField;
                break;

            case FieldType.StringField:
                BTData.StringField  stringField         = new BTData.StringField();
                StringFieldDesigner stringFieldDesigner = fieldData.Field as StringFieldDesigner;
                stringField.FieldName = fieldData.FieldName;
                stringField.Value     = stringFieldDesigner.Value;
                data = stringField;
                break;

            case FieldType.ColorField:
                BTData.ColorField  colorField         = new BTData.ColorField();
                ColorFieldDesigner colorFieldDesigner = fieldData.Field as ColorFieldDesigner;
                colorField.FieldName = fieldData.FieldName;
                colorField.Value    |= colorFieldDesigner.R << 24;
                colorField.Value    |= colorFieldDesigner.G << 16;
                colorField.Value    |= colorFieldDesigner.B << 8;
                colorField.Value    |= colorFieldDesigner.A;
                data = colorField;
                break;

            case FieldType.Vector2:
                BTData.Vector2Field  vector2Field         = new BTData.Vector2Field();
                Vector2FieldDesigner vector2FieldDesigner = fieldData.Field as Vector2FieldDesigner;
                vector2Field.FieldName = fieldData.FieldName;
                vector2Field.X         = vector2FieldDesigner.X;
                vector2Field.Y         = vector2FieldDesigner.Y;
                data = vector2Field;
                break;

            case FieldType.Vector3:
                BTData.Vector3Field  vector3Field         = new BTData.Vector3Field();
                Vector3FieldDesigner vector3FieldDesigner = fieldData.Field as Vector3FieldDesigner;
                vector3Field.FieldName = fieldData.FieldName;
                vector3Field.X         = vector3FieldDesigner.X;
                vector3Field.Y         = vector3FieldDesigner.Y;
                vector3Field.Z         = vector3FieldDesigner.Z;
                data = vector3Field;
                break;

            case FieldType.EnumField:
                BTData.EnumField  enumField         = new BTData.EnumField();
                EnumFieldDesigner enumFieldDesigner = fieldData.Field as EnumFieldDesigner;
                enumField.FieldName = fieldData.FieldName;
                enumField.Value     = enumFieldDesigner.ValueInt;
                data = enumField;
                break;

            case FieldType.BooleanField:
                BTData.BooleanField  booleanField         = new BTData.BooleanField();
                BooleanFieldDesigner booleanFieldDesigner = fieldData.Field as BooleanFieldDesigner;
                booleanField.FieldName = fieldData.FieldName;
                booleanField.Value     = booleanFieldDesigner.Value;
                data = booleanField;
                break;

            case FieldType.RepeatIntField:
                BTData.RepeatIntField  repeatIntField         = new BTData.RepeatIntField();
                RepeatIntFieldDesigner repeatIntFieldDesigner = fieldData.Field as RepeatIntFieldDesigner;
                repeatIntField.FieldName = fieldData.FieldName;
                if (repeatIntFieldDesigner.Value.Count > 0)
                {
                    repeatIntField.Value = new List <int>();
                    for (int i = 0; i < repeatIntFieldDesigner.Value.Count; i++)
                    {
                        repeatIntField.Value.Add(repeatIntFieldDesigner.Value[i]);
                    }
                }
                data = repeatIntField;
                break;

            case FieldType.RepeatLongField:
                BTData.RepeatLongField  repeatLongField         = new BTData.RepeatLongField();
                RepeatLongFieldDesigner repeatLongFieldDesigner = fieldData.Field as RepeatLongFieldDesigner;
                repeatLongField.FieldName = fieldData.FieldName;
                if (repeatLongFieldDesigner.Value.Count > 0)
                {
                    repeatLongField.Value = new List <long>();
                    for (int i = 0; i < repeatLongFieldDesigner.Value.Count; i++)
                    {
                        repeatLongField.Value.Add(repeatLongFieldDesigner.Value[i]);
                    }
                }

                data = repeatLongField;
                break;

            case FieldType.RepeatFloatField:
                BTData.RepeatFloatField  repeatFloatField         = new BTData.RepeatFloatField();
                RepeatFloatFieldDesigner repeatFloatFieldDesigner = fieldData.Field as RepeatFloatFieldDesigner;
                repeatFloatField.FieldName = fieldData.FieldName;
                if (repeatFloatFieldDesigner.Value.Count > 0)
                {
                    repeatFloatField.Value = new List <float>();
                    for (int i = 0; i < repeatFloatFieldDesigner.Value.Count; i++)
                    {
                        repeatFloatField.Value.Add(repeatFloatFieldDesigner.Value[i]);
                    }
                }
                data = repeatFloatField;
                break;

            case FieldType.RepeatVector2Field:
                BTData.RepeatVector2Field  repeatVector2Field         = new BTData.RepeatVector2Field();
                RepeatVector2FieldDesigner repeatVector2FieldDesigner = fieldData.Field as RepeatVector2FieldDesigner;
                repeatVector2Field.FieldName = fieldData.FieldName;
                if (repeatVector2FieldDesigner.Value.Count > 0)
                {
                    for (int i = 0; i < repeatVector2FieldDesigner.Value.Count; i++)
                    {
                        Vector2        vector2 = repeatVector2FieldDesigner.Value[i];
                        BTData.Vector2 temp    = new BTData.Vector2();
                        temp.X = vector2.X;
                        temp.Y = vector2.Y;
                        repeatVector2Field.Value.Add(temp);
                    }
                }
                data = repeatVector2Field;
                break;

            case FieldType.RepeatVector3Field:
                BTData.RepeatVector3Field  repeatVector3Field         = new BTData.RepeatVector3Field();
                RepeatVector3FieldDesigner repeatVector3FieldDesigner = fieldData.Field as RepeatVector3FieldDesigner;
                repeatVector3Field.FieldName = fieldData.FieldName;
                for (int i = 0; i < repeatVector3FieldDesigner.Value.Count; i++)
                {
                    Vector3        vector3 = repeatVector3FieldDesigner.Value[i];
                    BTData.Vector3 temp    = new BTData.Vector3();
                    temp.X = vector3.X;
                    temp.Y = vector3.Y;
                    temp.Z = vector3.Z;
                    repeatVector3Field.Value.Add(temp);
                }
                data = repeatVector3Field;
                break;

            case FieldType.RepeatStringField:
                BTData.RepeatStringField  repeatStringField         = new BTData.RepeatStringField();
                RepeatStringFieldDesigner repeatStringFieldDesigner = fieldData.Field as RepeatStringFieldDesigner;
                repeatStringField.FieldName = fieldData.FieldName;
                if (repeatStringFieldDesigner.Value.Count > 0)
                {
                    repeatStringField.Value = new List <string>();
                    for (int i = 0; i < repeatStringFieldDesigner.Value.Count; i++)
                    {
                        repeatStringField.Value.Add(repeatStringFieldDesigner.Value[i]);
                    }
                }
                data = repeatStringField;
                break;
            }

            return(data);
        }