示例#1
0
        internal void GenerateGlux(bool save = true)
        {
            ArrowProjectToGlueProjectConverter converter = new ArrowProjectToGlueProjectConverter();
            GlueProjectSave glueProjectSave = converter.ToGlueProjectSave(ArrowState.Self.CurrentArrowProject);

            if (glueProjectSave != null)
            {
                foreach (var screen in glueProjectSave.Screens)
                {
                    foreach (var nos in screen.AllNamedObjects)
                    {
                        nos.UpdateCustomProperties();
                    }
                }
                foreach (var entity in glueProjectSave.Entities)
                {
                    foreach (var nos in entity.AllNamedObjects)
                    {
                        nos.UpdateCustomProperties();
                    }
                }
            }

            ArrowState.Self.CurrentGlueProjectSave = glueProjectSave;

            if (save)
            {
                SaveGlux();
            }
        }
示例#2
0
        public void LoadProject(string fileName)
        {
            string extension = FileManager.GetExtension(fileName);

            // better be a .arox
            ArrowProjectSave arrowProject = FileManager.XmlDeserialize <ArrowProjectSave>(fileName);

            ArrowState.Self.CurrentArrowProject = arrowProject;

            ArrowProjectToGlueProjectConverter converter = new ArrowProjectToGlueProjectConverter();
            GlueProjectSave glueProjectSave = converter.ToGlueProjectSave(ArrowState.Self.CurrentArrowProject);

            ArrowState.Self.CurrentGlueProjectSave  = glueProjectSave;
            ArrowState.Self.CurrentGluxFileLocation = fileName;
        }
示例#3
0
        public void TestConversion()
        {
            ArrowProjectSave project = new ArrowProjectSave();

            SpriteSave spriteSave = new SpriteSave();

            spriteSave.X       = 3;
            spriteSave.Y       = 4;
            spriteSave.Name    = "SpriteInstance";
            spriteSave.Texture = "Entities/FirstElement/redball.BMP";


            ArrowElementSave element = new ArrowElementSave();

            element.Name = "FirstElement";
            element.Sprites.Add(spriteSave);
            project.Elements.Add(element);


            element      = new ArrowElementSave();
            element.Name = "ContainerOfFirstElement";
            element.Sprites.Add(spriteSave);
            project.Elements.Add(element);

            ArrowElementInstance instance = new ArrowElementInstance();

            instance.Name = "FirstElementInstance";
            instance.Type = "FirstElement";
            instance.SetVariable("X", 4);
            instance.SetVariable("Y", 5);
            element.ElementInstances.Add(instance);



            ArrowProjectToGlueProjectConverter converter = new ArrowProjectToGlueProjectConverter();

            GlueProjectSave gps = converter.ToGlueProjectSave(project);

            EntitySave firstElementEntity      = gps.Entities.FirstOrDefault(item => item.Name == "Entities/FirstElement");
            EntitySave containerOfFirstElement = gps.Entities.FirstOrDefault(item => item.Name == "Entities/ContainerOfFirstElement");

            if (firstElementEntity.Name.StartsWith("Entities/") == false)
            {
                throw new Exception("Entity names must start with \"Entities/\"");
            }

            if (firstElementEntity.ReferencedFiles.Count == 0)
            {
                throw new Exception("The Entity should automatically contain a ReferencedFile for the redball file");
            }

            if (containerOfFirstElement.NamedObjects.FirstOrDefault(item => item.InstanceName == "FirstElementInstance") == null)
            {
                throw new Exception("The entity should contain a NOS for another element, but it doesn't");
            }

            string gluxString;

            FileManager.XmlSerialize(gps, out gluxString);

            string aroxString;

            FileManager.XmlSerialize(project, out aroxString);
        }