Esempio n. 1
0
        public ComponentFactory(ComponentInfoManager componentInfoManager)
        {
            if (componentInfoManager == null) throw new ArgumentNullException("componentInfoManager");

            this.componentInfoManager = componentInfoManager;

            PropertyHandlers = new List<IPropertyHandler>();
            PropertyHandlers.Add(DefaultPropertyHandler.Instance);
            PropertyHandlers.Add(XnaTypePropertyHandler.Instance);
            PropertyHandlers.Add(new ComponentPropertyHandler(this));
        }
Esempio n. 2
0
    void Awake()
    {
        if (Instance)
        {
            Destroy(this);
        }
        Instance = this;

        for (int i = 0; i < InfoList.Length; i++)
        {
            if (!AllComponentsInfo.ContainsKey(InfoList[i].Type))
            {
                AllComponentsInfo.Add(InfoList[i].Type, new List <ComponentInfo>());
            }

            AllComponentsInfo[InfoList[i].Type].Add(InfoList[i]);
        }
    }
Esempio n. 3
0
        static void Main(string[] args)
        {
            //================================================================
            //
            // Shared ComponentTypeRegistory
            //

            var typeRegistory = new ComponentTypeRegistory();
            typeRegistory.SetTypeDefinitionName(typeof(SCurve5));
            typeRegistory.SetTypeDefinitionName(typeof(Perlin));
            typeRegistory.SetTypeDefinitionName(typeof(SumFractal));
            typeRegistory.SetTypeDefinitionName(typeof(ScaleBias));

            //================================================================
            //
            // ComponentInfoManager
            //

            var componentInfoManager = new ComponentInfoManager(typeRegistory);

            //================================================================
            //
            // ComponentBundleBuilder
            //

            var myNoise = new ScaleBias
            {
                Scale = 0.5f,
                Bias = 0.5f,
                Source = new SumFractal
                {
                    Source = new Perlin
                    {
                        Seed = 300,
                        FadeCurve = new SCurve5()
                    }
                }
            };

            var builder = new ComponentBundleBuilder(componentInfoManager);
            builder.Add("scaleBias", myNoise);

            //================================================================
            //
            // Serialization
            //

            ComponentBundleDefinition definition;
            builder.BuildDefinition(out definition);

            var xmlSerializer = new XmlSerializerAdapter(typeof(ComponentBundleDefinition));
            xmlSerializer.WriterSettings.Indent = true;
            xmlSerializer.WriterSettings.OmitXmlDeclaration = true;

            var resource = FileResourceLoader.Instance.LoadResource("file:///" + Directory.GetCurrentDirectory() + "/Noise.xml");
            using (var stream = resource.Create())
            {
                xmlSerializer.Serialize(stream, definition);
            }

            //================================================================
            //
            // Deserialization
            //

            ComponentBundleDefinition deserializedDefinition;
            using (var stream = resource.Open())
            {
                deserializedDefinition = (ComponentBundleDefinition) xmlSerializer.Deserialize(stream, null);
            }

            //================================================================
            //
            // Exit
            //

            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }
Esempio n. 4
0
        static void Main(string[] args)
        {
            //================================================================
            //
            // Shared ComponentTypeRegistory
            //

            var typeRegistory = new ComponentTypeRegistory();

            typeRegistory.SetTypeDefinitionName(typeof(SCurve5));
            typeRegistory.SetTypeDefinitionName(typeof(Perlin));
            typeRegistory.SetTypeDefinitionName(typeof(SumFractal));
            typeRegistory.SetTypeDefinitionName(typeof(ScaleBias));

            //================================================================
            //
            // ComponentInfoManager
            //

            var componentInfoManager = new ComponentInfoManager(typeRegistory);

            //================================================================
            //
            // ComponentBundleBuilder
            //

            var myNoise = new ScaleBias
            {
                Scale  = 0.5f,
                Bias   = 0.5f,
                Source = new SumFractal
                {
                    Source = new Perlin
                    {
                        Seed      = 300,
                        FadeCurve = new SCurve5()
                    }
                }
            };

            var builder = new ComponentBundleBuilder(componentInfoManager);

            builder.Add("scaleBias", myNoise);

            //================================================================
            //
            // Serialization
            //

            ComponentBundleDefinition definition;

            builder.BuildDefinition(out definition);

            var xmlSerializer = new XmlSerializerAdapter(typeof(ComponentBundleDefinition));

            xmlSerializer.WriterSettings.Indent             = true;
            xmlSerializer.WriterSettings.OmitXmlDeclaration = true;

            var resource = FileResourceLoader.Instance.LoadResource("file:///" + Directory.GetCurrentDirectory() + "/Noise.xml");

            using (var stream = resource.Create())
            {
                xmlSerializer.Serialize(stream, definition);
            }

            //================================================================
            //
            // Deserialization
            //

            ComponentBundleDefinition deserializedDefinition;

            using (var stream = resource.Open())
            {
                deserializedDefinition = (ComponentBundleDefinition)xmlSerializer.Deserialize(stream, null);
            }

            //================================================================
            //
            // Exit
            //

            Console.WriteLine("Press Enter to exit.");
            Console.ReadLine();
        }