Пример #1
0
        public static Sprite LoadFromModule(Module.Module module, XElement node)
        {
            Orion.Core.SpriteDefinition spriteDef = null;
            float x = 0;
            float y = 0;

            foreach (XAttribute attribNode in node.Attributes())
            {
                switch (attribNode.Name.LocalName)
                {
                case "Ref":
                    spriteDef = SpriteDefinition.LoadFromModule(module, attribNode.Value);
                    break;
                }
            }

            foreach (XElement element in node.Elements())
            {
                switch (element.Name.LocalName)
                {
                case "LocationX":
                    x = XmlConvert.ToSingle(element.Value);
                    break;

                case "LocationY":
                    y = XmlConvert.ToSingle(element.Value);
                    break;
                }
            }

            Sprite sprite = new Sprite(spriteDef);

            sprite.Position = new Vector2(x, y);
            return(sprite);
        }
Пример #2
0
        public void LoadSceneFromModule(Module.Module module, string sceneRef)
        {
            try
            {
                XDocument doc = XDocument.Parse(module.GetFileXML(sceneRef, ResourceType.Scene));

                XElement root     = doc.Element("Scene");
                string   typeName = root.Attribute("Type").Value;

                ISceneFactory fac = OrionEngine.Instance.GetFactoryFor <ISceneFactory>(typeName);
                CurrentScene = fac.GetScene(typeName, OrionEngine.Instance, module, root);
            }
            catch (Exception)
            {
                LogManager.Instance.LogError("Error loading scene from module.");
            }
        }
        public static SpriteDefinition LoadFromModule(Module.Module module, string reference)
        {
            SpriteDefinition spriteDef = null;

            string xml = module.GetFileXML(reference, ResourceType.SpriteDef);

            spriteDef = new SpriteDefinition();

            XDocument doc = XDocument.Parse(xml);

            spriteDef.Tag = doc.Element("SpriteDefinition").Attribute("Tag").Value;

            foreach (XElement node in doc.Element("SpriteDefinition").Elements())
            {
                switch (node.Name.LocalName)
                {
                case "Resource":
                {
                    spriteDef.ReferenceName = node.Attribute("Ref").Value;
                    spriteDef.Path          = module.GetResourcePath(spriteDef.ReferenceName, ResourceType.Texture);

                    module.LoadTexture(spriteDef.ReferenceName);
                }
                break;

                case "FrameData":
                    LoadFrameData(node, spriteDef);
                    break;

                case "AnimationList":
                    foreach (XElement listNode in node.Elements())
                    {
                        if (listNode.Name.LocalName == "Animation")
                        {
                            LoadAnimation(listNode, spriteDef);
                        }
                    }
                    break;
                }
            }

            return(spriteDef);
        }
Пример #4
0
 public void SetCurrentModule(Module.Module module)
 {
     CurrentModule = module;
 }