Exemplo n.º 1
0
        /// <summary>
        /// Loads the field from a given directory
        /// </summary>
        /// <param name="directory">field directory</param>
        /// <returns>whether the process was successful</returns>
        bool LoadField(string directory)
        {
            fieldPath = directory;

            fieldObject = new GameObject("Field");

            FieldDefinition.Factory = delegate(Guid guid, string name)
            {
                return(new UnityFieldDefinition(guid, name));
            };

            if (!File.Exists(directory + "\\definition.bxdf"))
            {
                return(false);
            }

            FieldDataHandler.Load(fieldPath);
            Controls.Init();

            string loadResult;

            fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + "\\definition.bxdf", out loadResult);
            Debug.Log(loadResult);
            fieldDefinition.CreateTransform(fieldObject.transform);
            return(fieldDefinition.CreateMesh(directory + "\\mesh.bxda"));
        }
Exemplo n.º 2
0
    bool LoadField(string directory)
    {
        fieldObject = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };

        string loadResult;

        fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + "\\definition.bxdf", out loadResult);
        Debug.Log(loadResult);
        fieldDefinition.CreateTransform(fieldObject.transform);
        return(fieldDefinition.CreateMesh(directory + "\\mesh.bxda"));
    }
Exemplo n.º 3
0
    private void TryLoadField()
    {
        activeField = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };

        Debug.Log(filePath);
        string loadResult;

        field = (UnityFieldDefinition)BXDFProperties.ReadProperties(filePath + "definition.bxdf", out loadResult);
        Debug.Log(loadResult);
        field.CreateTransform(activeField.transform);
        fieldLoaded = field.CreateMesh(filePath + "mesh.bxda");
    }
Exemplo n.º 4
0
    private void TryLoadField()
    {
        activeField = new GameObject("Field");

        FieldDefinition.Factory = delegate(Guid guid, string name)
        {
            return(new UnityFieldDefinition(guid, name));
        };
        try
        {
            string loadResult;
            UnityFieldDefinition field = (UnityFieldDefinition)BXDFProperties.ReadProperties(Application.dataPath + "//resources//ConfigurationEnvironment//definition.bxdf", out loadResult);
            Debug.Log(loadResult);
            field.CreateTransform(activeField.transform);
            bool fieldLoaded = field.CreateMesh(Application.dataPath + "//resources//ConfigurationEnvironment//mesh.bxda");
        }
        catch
        {
            Debug.Log("Field loading failed!");
        }
    }
Exemplo n.º 5
0
        /// <summary>
        /// Loads the field from a given directory
        /// </summary>
        /// <param name="directory">field directory</param>
        /// <returns>whether the process was successful</returns>
        bool LoadField(string directory)
        {
            if (string.IsNullOrEmpty(directory))
            {
                UserMessageManager.Dispatch("Field not found", 7);
            }
            fieldPath = directory;

            fieldObject = new GameObject("Field");

            FieldDefinition.Factory = delegate(Guid guid, string name)
            {
                return(new UnityFieldDefinition(guid, name));
            };

            bool isEmptyGrid = directory == "" || new DirectoryInfo(directory).Name == UnityFieldDefinition.EmptyGridName;

            if (!File.Exists(directory + Path.DirectorySeparatorChar + "definition.bxdf") && !isEmptyGrid)
            {
                return(false);
            }

            FieldDataHandler.LoadFieldMetaData(fieldPath);

            Controls.Load();
            Controls.UpdateFieldControls();
            if (!Controls.HasBeenSaved())
            {
                Controls.Save(true);
            }

            if (isEmptyGrid)
            {
                return(true);
            }
            fieldDefinition = (UnityFieldDefinition)BXDFProperties.ReadProperties(directory + Path.DirectorySeparatorChar + "definition.bxdf", out string loadResult);
            // Debug.Log("Field load result: " + loadResult);
            fieldDefinition.CreateTransform(fieldObject.transform);
            return(fieldDefinition.CreateMesh(directory + Path.DirectorySeparatorChar + "mesh.bxda"));
        }
Exemplo n.º 6
0
        private void BuildTestProcessedSchemaFiles()
        {
            var processedSchemaFiles = new UnitySchemaProcessor(new[]
            {
                new SchemaFileRaw
                {
                    completePath    = fakeFileName,
                    enumDefinitions = new EnumDefinitionRaw[0],
                    typeDefinitions = new[]
                    {
                        new TypeDefinitionRaw
                        {
                            qualifiedName    = "usertypewithint32",
                            enumDefinitions  = new EnumDefinitionRaw[0],
                            fieldDefinitions = new[]
                            {
                                new FieldDefinitionRaw
                                {
                                    singularType = new TypeReferenceRaw
                                    {
                                        builtInType = "int32"
                                    }
                                }
                            }
                        },
                        new TypeDefinitionRaw
                        {
                            qualifiedName    = "usertypewithstring",
                            enumDefinitions  = new EnumDefinitionRaw[0],
                            fieldDefinitions = new[]
                            {
                                new FieldDefinitionRaw
                                {
                                    singularType = new TypeReferenceRaw
                                    {
                                        builtInType = "string"
                                    }
                                }
                            }
                        }
                    },
                    componentDefinitions = new[]
                    {
                        new ComponentDefinitionRaw
                        {
                            name           = "component-with-int",
                            dataDefinition = new TypeReferenceRaw
                            {
                                userType = "usertypewithint32"
                            }
                        },
                        new ComponentDefinitionRaw
                        {
                            name           = "component-with-string",
                            dataDefinition = new TypeReferenceRaw
                            {
                                userType = "usertypewithstring"
                            }
                        }
                    }
                }
            }).ProcessedSchemaFiles;

            BlittableFlagger.SetBlittableFlags(processedSchemaFiles);

            BlittableComponentDefinition = processedSchemaFiles.First().ComponentDefinitions
                                           .Find(definition => definition.Name == "component-with-int");
            NonBlittableComponentDefinition = processedSchemaFiles.First().ComponentDefinitions
                                              .Find(definition => definition.Name == "component-with-string");

            BlittableFieldDefinition = BlittableComponentDefinition.DataDefinition.typeDefinition.FieldDefinitions
                                       .First();
            NonBlittableFieldDefinition = NonBlittableComponentDefinition.DataDefinition.typeDefinition.FieldDefinitions
                                          .First();
        }