예제 #1
0
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            var info = new EntityInfo() {
                Name = xmlNode.RequireAttribute("name").Value,
                MaxAlive = xmlNode.TryAttribute<int>("maxAlive", 50),
                GravityFlip = xmlNode.TryElementValue<bool>("GravityFlip"),
                Components = new List<IComponentInfo>()
            };

            ReadEditorData(xmlNode, info);

            var deathNode = xmlNode.Element("Death");
            if (deathNode != null)
                info.Death = _effectReader.Load(deathNode);

            foreach (var compReader in ComponentReaders)
            {
                var element = compReader.NodeName != null ? xmlNode.Element(compReader.NodeName) : xmlNode;
                if (element != null)
                {
                    var comp = compReader.Load(element, project);
                    if (comp != null)
                        info.Components.Add(comp);
                }
            }

            if (info.PositionComponent == null)
                info.Components.Add(new PositionComponentInfo());

            if (info.MovementComponent == null && HasMovementEffects(info))
                info.Components.Add(new MovementComponentInfo() { EffectInfo = new MovementEffectPartInfo() });

            project.AddEntity(info);
            return info;
        }
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new LadderComponentInfo();
            comp.HitBoxes = node.Elements("Hitbox").Select(GetHitbox).ToList();

            return comp;
        }
        public IComponentInfo Load(XElement node, Project project)
        {
            var spriteComponent = new SpriteComponentInfo();

            FilePath sheetPath = null;
            var sheetNode = node.Element("Tilesheet");
            if (sheetNode != null)
            {
                sheetPath = FilePath.FromRelative(sheetNode.Value, project.BaseDir);
                spriteComponent.SheetPath = sheetPath;
            }

            foreach (var spriteNode in node.Elements("Sprite"))
            {
                if (sheetPath == null)
                {
                    var sprite = _spriteReader.LoadSprite(spriteNode, project.BaseDir);
                    spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite);
                }
                else
                {
                    var sprite = _spriteReader.LoadSprite(spriteNode);
                    sprite.SheetPath = sheetPath;
                    spriteComponent.Sprites.Add(sprite.Name ?? "Default", sprite);
                }
            }

            if (spriteComponent.SheetPath != null || spriteComponent.Sprites.Any())
                return spriteComponent;
            else
                return null;
        }
예제 #4
0
 public void Load(Project project, XElement xmlNode)
 {
     foreach (var menuNode in xmlNode.Elements("Menu"))
     {
         AddMenu(menuNode, project);
     }
 }
        public IComponentInfo Load(XElement node, Project project)
        {
            var component = new CollisionComponentInfo();

            foreach (var boxnode in node.Elements("Hitbox"))
            {
                var box = GetHitbox(boxnode);

                foreach (var groupnode in boxnode.Elements("Hits"))
                    box.Hits.Add(groupnode.Value);

                foreach (var groupnode in boxnode.Elements("Group"))
                    box.Groups.Add(groupnode.Value);

                foreach (var resistNode in boxnode.Elements("Resist"))
                {
                    var resistName = resistNode.GetAttribute<string>("name");
                    float mult = resistNode.GetAttribute<float>("multiply");
                    box.Resistance.Add(resistName, mult);
                }

                component.HitBoxes.Add(box);
            }

            component.Enabled = node.TryAttribute<bool>("Enabled");

            return component;
        }
예제 #6
0
 public void Load(Project project, XElement xmlNode)
 {
     foreach (XElement sceneNode in xmlNode.Elements("Scene"))
     {
         _sceneReader.Load(project, sceneNode);
     }
 }
예제 #7
0
 public void Load(Project project, XElement xmlNode)
 {
     foreach (var fontNode in xmlNode.Elements("Font"))
     {
         _fontReader.Load(project, fontNode);
     }
 }
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new StateComponentInfo();
            foreach (var state in node.Elements("State"))
            {
                var stateInfo = ReadState(state);
                comp.States.Add(stateInfo);
            }

            foreach (var triggerInfo in node.Elements("Trigger"))
            {
                var statesNode = triggerInfo.Element("States");
                var states = statesNode != null ? statesNode.Value.Split(',').Select(s => s.Trim()).ToList() : null;

                var trigger = _triggerReader.Load(triggerInfo);

                if (trigger.Priority == null)
                    trigger.Priority = ((IXmlLineInfo)triggerInfo).LineNumber;

                comp.Triggers.Add(new MultiStateTriggerInfo() {
                    States = states,
                    Trigger = trigger
                });
            }

            return comp;
        }
예제 #9
0
 public void Load(Project project, XElement node)
 {
     foreach (var fontNode in node.Elements("Font"))
     {
         //LoadFont(project, fontNode);
     }
 }
예제 #10
0
 public void Load(Project project, XElement xmlNode)
 {
     foreach (var node in xmlNode.Elements("Sound"))
     {
         _soundReader.Load(project, node);
     }
 }
예제 #11
0
        public void Load(Project project, XElement xmlNode)
        {
            foreach (var node in xmlNode.Elements("Palette"))
            {
                var palette = PaletteFromXml(node, project.BaseDir);

                project.AddPalette(palette);
            }
        }
예제 #12
0
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            var group = new IncludedObjectGroup();
            foreach (var node in xmlNode.Elements("Sound"))
            {
                group.Add(_soundReader.Load(project, node));
            }

            return group;
        }
예제 #13
0
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            var group = new IncludedObjectGroup();
            foreach (var fontNode in xmlNode.Elements("Font"))
            {
                group.Add(_fontReader.Load(project, fontNode));
            }

            return group;
        }
예제 #14
0
        public void Load(Project project, XElement node)
        {
            var palette = new PaletteInfo();

            var imagePathRelative = node.RequireAttribute("image").Value;
            palette.ImagePath = FilePath.FromRelative(imagePathRelative, project.BaseDir);
            palette.Name = node.RequireAttribute("name").Value;

            project.AddPalette(palette);
        }
예제 #15
0
        public ProjectDocument CreateNew(string directory)
        {
            var project = new Project()
            {
                GameFile = FilePath.FromRelative("game.xml", directory)
            };

            var p = new ProjectDocument(new ProjectFileStructure(project), project);
            return p;
        }
예제 #16
0
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            var group = new IncludedObjectGroup();
            foreach (var menuNode in xmlNode.Elements("Menu"))
            {
                group.Add(_menuReader.Load(project, menuNode));
            }

            return group;
        }
예제 #17
0
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            var group = new IncludedObjectGroup();
            foreach (XElement sceneNode in xmlNode.Elements("Scene"))
            {
                group.Add(_sceneReader.Load(project, sceneNode));
            }

            return group;
        }
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            var group = new IncludedObjectGroup();
            foreach (var node in xmlNode.Elements("Palette"))
            {
                var palette = PaletteFromXml(node, project.BaseDir);
                group.Add(palette);
                project.AddPalette(palette);
            }

            return group;
        }
 private void LoadProperties(Project project, XElement node)
 {
     var propHead = node.Element("Properties");
     if (propHead != null)
     {
         foreach (var propNode in propHead.Elements("Properties"))
         {
             var properties = _tilesetReader.LoadProperties(propNode);
             project.AddEntityProperties(properties);
         }
     }
 }
예제 #20
0
        public ProjectDocument(IProjectFileStructure fileStructure, Project project)
        {
            Project = project;
            FileStructure = fileStructure;

            entities = project.Entities.ToDictionary(e => e.Name, e => e);
            foreach (var entity in project.Entities)
            {
                ((App)App.Current).AnimateSprite(entity.DefaultSprite);
                entity.DefaultSprite.Play();
            }
        }
        public IIncludedObject Load(Project project, XElement xmlNode)
        {
            LoadProperties(project, xmlNode);

            var group = new IncludedObjectGroup();
            foreach (var node in xmlNode.Elements("Entity"))
            {
                group.Add(this._entityReader.Load(project, node));
            }

            return group;
        }
예제 #22
0
        public void Load(Project project, XElement node)
        {
            var menu = new MenuInfo();

            LoadHandlerBase(menu, node, project.BaseDir);

            foreach (var keyNode in node.Elements("State"))
            {
                menu.States.Add(LoadMenuState(keyNode, project.BaseDir));
            }

            project.AddMenu(menu);
        }
예제 #23
0
        public IIncludedObject Load(Project project, XElement node)
        {
            var menu = new MenuInfo();

            LoadBase(menu, node, project.BaseDir);

            foreach (var keyNode in node.Elements("State"))
            {
                menu.States.Add(LoadMenuState(keyNode, project.BaseDir));
            }

            project.AddMenu(menu);
            return menu;
        }
예제 #24
0
        public SpriteEditor(Project project)
        {
            InitializeComponent();
            this.project = project;

            snap = true;
            spriteWidth = spriteHeight = 32;
            textWidth.Text = textHeight.Text = "32";

            InitSprite(32, 32);

            timer = new Timer();
            timer.Interval = 17;
            timer.Tick += new EventHandler(timer_Tick);
            timer.Start();
        }
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new HealthComponentInfo();
            comp.Max = node.TryAttribute<float>("max", node.TryElementValue<float>("Max"));

            comp.StartValue = node.TryAttribute<float?>("startValue");

            XElement meterNode = node.Element("Meter");
            if (meterNode != null)
            {
                comp.Meter = _meterReader.LoadMeter(meterNode, project.BaseDir);
            }

            comp.FlashFrames = node.TryAttribute("flash", node.TryElementValue<int>("Flash"));

            return comp;
        }
예제 #26
0
        public StageSelectEdit(ProjectEditor editor)
        {
            project = editor.Project;

            InitializeComponent();
            this.stageSelect = project.StageSelects.FirstOrDefault();
            this.preview.Image = new Bitmap(project.ScreenWidth, project.ScreenHeight);

            bossX.Value = stageSelect.BossSpacingHorizontal;
            bossY.Value = stageSelect.BossSpacingVertical;

            comboSlot.SelectedIndex = -1;
            foreach (var stage in project.Stages) comboStages.Items.Add(stage.Name);

            if (stageSelect.Background != null)
            {
                textBackground.Text = stageSelect.Background.Absolute;
                try
                {
                    this.background = (Bitmap)Image.FromFile(stageSelect.Background.Absolute);
                    this.background.SetResolution(this.preview.Image.HorizontalResolution, this.preview.Image.VerticalResolution);
                }
                catch
                {
                    this.textBackground.Text = "";
                }
            }

            if (stageSelect.Music != null)
            {

            }

            if (stageSelect.ChangeSound != null)
            {
                if (stageSelect.ChangeSound.Type == AudioType.Wav)
                {
                    textSound.Text = stageSelect.ChangeSound.Path.Absolute;
                }
            }

            ReDraw();
        }
예제 #27
0
        public void Load(Project project, XElement xmlNode)
        {
            foreach (var node in xmlNode.Elements("Entity"))
            {
                var info = new EntityInfo() {
                    Name = node.RequireAttribute("name").Value,
                    MaxAlive = node.TryAttribute<int>("maxAlive", 50)
                };

                var editorData = node.Element("EditorData");
                if (editorData != null)
                {
                    info.EditorData = new EntityEditorData() {
                        DefaultSpriteName = editorData.TryAttribute<string>("defaultSprite"),
                        HideFromPlacement = editorData.TryAttribute<bool>("hide", false)
                    };
                }

                FilePath sheetPath = null;
                var sheetNode = node.Element("Tilesheet");
                if (sheetNode != null)
                    sheetPath = FilePath.FromRelative(sheetNode.Value, project.BaseDir);

                foreach (var spriteNode in node.Elements("Sprite"))
                {
                    if (sheetPath == null)
                    {
                        var sprite = GameXmlReader.LoadSprite(spriteNode, project.BaseDir);
                        info.Sprites.Add(sprite.Name ?? "Default", sprite);
                    }
                    else
                    {
                        var sprite = GameXmlReader.LoadSprite(spriteNode);
                        sprite.SheetPath = sheetPath;
                        info.Sprites.Add(sprite.Name ?? "Default", sprite);
                    }

                }

                project.AddEntity(info);
            }
        }
예제 #28
0
        public void LoadIncludedFile(Project project, string filePath)
        {
            _project = project;

            try
            {
                XDocument document = XDocument.Load(filePath, LoadOptions.SetLineInfo);
                foreach (XElement element in document.Elements())
                {
                    if (_readers.ContainsKey(element.Name.LocalName))
                    {
                        _readers[element.Name.LocalName].Load(project, element);
                    }
                }
            }
            catch (GameXmlException ex)
            {
                ex.File = filePath;
                throw;
            }
        }
예제 #29
0
        public void Load(Project project, XElement xmlNode)
        {
            var info = new FontInfo();

            info.Name = xmlNode.RequireAttribute("name").Value;
            info.CharWidth = xmlNode.GetAttribute<int>("charwidth");
            info.CaseSensitive = xmlNode.GetAttribute<bool>("cased");

            foreach (var lineNode in xmlNode.Elements("Line"))
            {
                var x = lineNode.GetAttribute<int>("x");
                var y = lineNode.GetAttribute<int>("y");

                var lineText = lineNode.Value;

                info.AddLine(x, y, lineText);
            }

            info.ImagePath = FilePath.FromRelative(xmlNode.RequireAttribute("image").Value, project.BaseDir);

            project.AddFont(info);
        }
        public IComponentInfo Load(XElement node, Project project)
        {
            var comp = new WeaponComponentInfo();
            comp.Weapons = node.Elements("Weapon")
                .Select(x => {
                    var w = new WeaponInfo() {
                        Name = x.GetAttribute<string>("name"),
                        EntityName = x.GetAttribute<string>("entity"),
                        Ammo = x.TryAttribute<int?>("ammo"),
                        Usage = x.TryAttribute<int?>("usage"),
                        Palette = x.TryAttribute<int?>("palette")
                    };

                    var meterNode = x.Element("Meter");
                    if (meterNode != null)
                        w.Meter = _meterReader.LoadMeter(meterNode, project.BaseDir);

                    return w;
                })
                .ToList();

            return comp;
        }