示例#1
0
        private static void ProcessTextureItem(string layer, Vector2 scrollSpeed, XmlNode properties, ContentManager cm)
        {
            ObjectInformation oi = new ObjectInformation();

            oi.scrollSpeed = scrollSpeed;
            oi.layer       = layer;
            oi.name        = "TEMP";

            foreach (XmlNode child in properties.ChildNodes)
            {
                switch (child.Name)
                {
                case "Name":
                    oi.name = child.InnerText;
                    break;

                case "Position":
                    oi.position = ExtractVector2(child);
                    break;

                case "CustomProperties":
                    oi.customProperties = ExtractCustomProperties(child);
                    break;

                case "Rotation":
                    oi.rotation = ExtractFloat(child);
                    break;

                case "Scale":
                    oi.scale = ExtractVector2(child);;
                    break;

                case "FlipHorizontally":
                    oi.flipH = ExtractBool(child);
                    break;

                case "FlipVertically":
                    oi.flipV = ExtractBool(child);
                    break;

                case "TexturePathRelativeToContentRoot":

                    String[] splitString = child.FirstChild.Value.Split('\\');

                    try
                    {
                        oi.texture = cm.Load <Texture2D>(child.FirstChild.Value);
                    }
                    //This causes major performance issues at the moment
                    catch (ContentLoadException e)
                    {
                    }


                    break;
                }
            }
            objectProcessor.ProcessTextureObject(oi);
        }
示例#2
0
        private static void ParseTextureItem(XmlNode textureItem, Vector2 scrollSpeed, String layerName, ContentManager cm)
        {
            ObjectInformation oi = new ObjectInformation();

            oi.scrollSpeed = scrollSpeed;
            oi.layer       = layerName;
            oi.name        = "TEMP";

            foreach (XmlNode child in textureItem.ChildNodes)
            {
                switch (child.Name)
                {
                case "Position":
                    oi.position = ExtractVector2(child);
                    break;

                case "CustomProperties":
                    oi.customProperties = ExtractCustomProperties(child);
                    break;

                case "Rotation":
                    oi.rotation = ExtractFloat(child);
                    break;

                case "Scale":
                    oi.scale = ExtractVector2(child);;
                    break;

                case "FlipHorizontally":
                    oi.flipH = ExtractBool(child);
                    break;

                case "FlipVertically":
                    oi.flipV = ExtractBool(child);
                    break;

                case "asset_name":
                    //oi.texture = cm.Load<Texture2D>(child.FirstChild.Value);
                    String[] splitString = child.FirstChild.Value.Split('\\');
                    String   name        = splitString[splitString.Length - 1];
                    oi.name = name;
                    break;
                }
            }
            objectProcessor.ProcessTextureObject(oi);
        }
        private static void ParseTextureItem(XmlNode textureItem, Vector2 scrollSpeed, String layerName, ContentManager cm)
        {
            ObjectInformation oi = new ObjectInformation();

            oi.scrollSpeed = scrollSpeed;
            oi.layer       = layerName;
            oi.name        = "TEMP";

            foreach (XmlNode child in textureItem.ChildNodes)
            {
                switch (child.Name)
                {
                case "Position":
                    oi.position = ExtractVector2(child);
                    break;

                case "CustomProperties":
                    oi.customProperties = ExtractCustomProperties(child);
                    break;

                case "Rotation":
                    oi.rotation = ExtractFloat(child);
                    break;

                case "Scale":
                    oi.scale = ExtractVector2(child);;
                    break;

                case "FlipHorizontally":
                    oi.flipH = ExtractBool(child);
                    break;

                case "FlipVertically":
                    oi.flipV = ExtractBool(child);
                    break;

                case "Origin":
                    oi.origin = ExtractVector2(child);
                    break;

                case "asset_name":
                    try
                    {
                        oi.texturePath = child.FirstChild.Value;
                        oi.texture     = cm.Load <Texture2D>(oi.texturePath);
                    }
                    //This causes major performance issues at the moment
                    catch (ContentLoadException e)
                    {
                        bool hej = true;
                    }

                    String[] splitString = child.FirstChild.Value.Split('\\');
                    oi.textureName = splitString[splitString.Length - 1];

                    String name = GetObjectName(textureItem);
                    oi.name = name;
                    break;
                }
            }

            Vector2 middle = Vector2.Zero;

            if (oi.texture != null)
            {
                middle = new Vector2(oi.texture.Width / 2, oi.texture.Height / 2);
                Vector2 offset = middle - oi.origin;
                oi.position += offset;
            }
            //oi.origin *= oi.scale;
            objectProcessor.ProcessTextureObject(oi);
        }