Пример #1
0
        private MenuStateInfo LoadMenuState(XElement node, string basePath)
        {
            var info = new MenuStateInfo();

            info.Name = node.RequireAttribute("name").Value;

            info.Fade = node.TryAttribute <bool>("fade");

            var startNode = node.Element("SelectOption");

            if (startNode != null)
            {
                var startNameAttr = startNode.Attribute("name");
                var startVarAttr  = startNode.Attribute("var");

                if (startNameAttr != null)
                {
                    info.StartOptionName = startNameAttr.Value;
                }

                if (startVarAttr != null)
                {
                    info.StartOptionVar = startVarAttr.Value;
                }
            }

            info.Commands = _commandReader.LoadCommands(node, basePath);

            return(info);
        }
Пример #2
0
        private KeyFrameInfo LoadKeyFrame(XElement node, string basePath)
        {
            var info = new KeyFrameInfo();

            info.Frame = node.GetAttribute <int>("frame");

            info.Fade = node.TryAttribute <bool>("fade");

            info.Commands = _commandReader.LoadCommands(node, basePath);

            return(info);
        }
Пример #3
0
        private ScreenInfo LoadScreenXml(XElement node, FilePath stagePath, Tileset tileset)
        {
            string id = node.RequireAttribute("id").Value;

            var screen = new ScreenInfo(id, tileset);

            screen.Layers.Add(LoadScreenLayer(node, stagePath.Absolute, id, tileset, 0, 0, false));

            foreach (var overlay in node.Elements("Overlay"))
            {
                var  name       = overlay.RequireAttribute("name").Value;
                var  x          = overlay.TryAttribute <int>("x");
                var  y          = overlay.TryAttribute <int>("y");
                bool foreground = overlay.TryAttribute <bool>("foreground");
                bool parallax   = overlay.TryAttribute <bool>("parallax");

                var layer = LoadScreenLayer(overlay, stagePath.Absolute, name, tileset, x, y, foreground);
                layer.Parallax = parallax;

                screen.Layers.Add(layer);
            }

            foreach (XElement teleport in node.Elements("Teleport"))
            {
                TeleportInfo info;
                int          from_x = teleport.TryAttribute <int>("from_x");
                int          from_y = teleport.TryAttribute <int>("from_y");
                int          to_x   = teleport.TryAttribute <int>("to_x");
                int          to_y   = teleport.TryAttribute <int>("to_y");
                info.From         = new Point(from_x, from_y);
                info.To           = new Point(to_x, to_y);
                info.TargetScreen = teleport.Attribute("to_screen").Value;

                screen.Teleports.Add(info);
            }

            var blocks = new List <BlockPatternInfo>();

            foreach (XElement blockNode in node.Elements("Blocks"))
            {
                BlockPatternInfo pattern = _blockReader.FromXml(blockNode);
                screen.BlockPatterns.Add(pattern);
            }

            screen.Commands = _commandReader.LoadCommands(node, stagePath.BasePath);

            return(screen);
        }