public ScreenDocument AddScreen(string name, int tile_width, int tile_height)
        {
            var screen = new MegaMan.Common.ScreenInfo(name, Tileset.Tileset);

            int[,] tiles = new int[tile_width, tile_height];

            screen.Layers.Add(new ScreenLayerInfo(name, new TileLayer(tiles, Tileset.Tileset, 0, 0), false, new List <EntityPlacement>(), new List <ScreenLayerKeyframe>()));

            map.Screens.Add(name, screen);

            if (StartScreen == null)
            {
                map.StartScreen = map.Screens.Keys.First();
                Dirty           = true;
            }

            ScreenDocument doc = WrapScreen(screen);

            // now I can do things like fire an event... how useful!
            if (ScreenAdded != null)
            {
                ScreenAdded(doc);
            }

            return(doc);
        }
        public void AddScreen(string name, int tile_width, int tile_height)
        {
            var screen = new MegaMan.Common.ScreenInfo(name, Tileset);

            int[][] tiles = new int[tile_height][];
            for (int y = 0; y < tile_height; y++)
            {
                tiles[y] = new int[tile_width];
            }

            screen.Layers.Add(new ScreenLayerInfo(name, new TileLayer(tiles, Tileset, 0, 0), new List <EntityPlacement>(), new List <ScreenLayerKeyframe>()));

            map.Screens.Add(name, screen);

            if (StartScreen == null)
            {
                StartScreen = map.Screens.Keys.First();
            }

            ScreenDocument doc = WrapScreen(screen);

            // now I can do things like fire an event... how useful!
            if (ScreenAdded != null)
            {
                ScreenAdded(doc);
            }

            Save();
        }
Exemple #3
0
        private ScreenDocument WrapScreen(MegaMan.Common.ScreenInfo screen)
        {
            ScreenDocument doc = new ScreenDocument(screen, this);

            doc.Renamed     += ScreenRenamed;
            doc.TileChanged += () => Dirty = true;
            doc.Resized     += (w, h) => OnScreenResized(doc, w, h);
            return(doc);
        }
        private ScreenDocument WrapScreen(MegaMan.Common.ScreenInfo screen)
        {
            ScreenDocument doc = new ScreenDocument(screen, this);

            screens.Add(screen.Name, doc);
            doc.Renamed     += ScreenRenamed;
            doc.TileChanged += () => Dirty = true;
            return(doc);
        }
Exemple #5
0
        public ScreenHandler(ScreenInfo screen, IEnumerable<ScreenLayer> layers, IEnumerable<JoinHandler> joins,
            IEnumerable<BlocksPattern> blockPatterns, IGameplayContainer container)
        {
            Screen = screen;
            patterns = new List<BlocksPattern>();
            spawnedEntities = new List<GameEntity>();

            this.layers = layers;

            this.patterns = blockPatterns.ToList();

            this.joins = joins;

            teleportEnabled = new List<bool>(screen.Teleports.Select(info => false));

            this.container = container;
        }
Exemple #6
0
        public void SaveScreen(ScreenInfo screen)
        {
            _writer.WriteStartElement("Screen");
            _writer.WriteAttributeString("id", screen.Name);

            foreach (var command in screen.Commands)
            {
                if (!(command is SceneEntityCommandInfo))
                    command.Save(_writer);
            }

            foreach (var entity in screen.Layers[0].Entities)
                entity.Save(_writer);

            foreach (var layer in screen.Layers.Skip(1))
            {
                layer.Save(_writer);
            }

            foreach (BlockPatternInfo pattern in screen.BlockPatterns)
            {
                //pattern.Save(writer);
            }

            foreach (TeleportInfo teleport in screen.Teleports)
            {
                _writer.WriteStartElement("Teleport");
                _writer.WriteAttributeString("from_x", teleport.From.X.ToString());
                _writer.WriteAttributeString("from_y", teleport.From.Y.ToString());
                _writer.WriteAttributeString("to_screen", teleport.TargetScreen);
                _writer.WriteAttributeString("to_x", teleport.To.X.ToString());
                _writer.WriteAttributeString("to_y", teleport.To.Y.ToString());
                _writer.WriteEndElement();
            }

            _writer.WriteEndElement();

            foreach (var layer in screen.Layers)
            {
                layer.Tiles.Save(Path.Combine(_stageInfo.StagePath.Absolute, layer.Name + ".scn"));
            }
        }
Exemple #7
0
 public void RenameScreen(ScreenInfo screen, string name)
 {
     this.Screens.Remove(screen.Name);
     screen.Name = name;
     this.Screens.Add(name, screen);
 }
Exemple #8
0
        public ScreenDocument AddScreen(string name, int tile_width, int tile_height)
        {
            var screen = new MegaMan.Common.ScreenInfo(name, Tileset.Tileset);

            int[,] tiles = new int[tile_width, tile_height];

            screen.Layers.Add(new ScreenLayerInfo(name, new TileLayer(tiles, Tileset.Tileset, 0, 0), false, new List<EntityPlacement>(), new List<ScreenLayerKeyframe>()));

            map.Screens.Add(name, screen);

            if (StartScreen == null)
            {
                map.StartScreen = map.Screens.Keys.First();
                Dirty = true;
            }

            ScreenDocument doc = WrapScreen(screen);

            // now I can do things like fire an event... how useful!
            if (ScreenAdded != null) ScreenAdded(doc);

            return doc;
        }
Exemple #9
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 = HandlerXmlReader.LoadCommands(node, stagePath.BasePath);

            return screen;
        }
 public void RenameScreen(ScreenInfo screen, string name)
 {
     this.Screens.Remove(screen.Name);
     screen.Name = name;
     this.Screens.Add(name, screen);
 }
Exemple #11
0
 public ScreenDocument(ScreenInfo screen, StageDocument stage)
 {
     Stage = stage;
     this.screen = screen;
 }
        public void AddScreen(string name, int tile_width, int tile_height)
        {
            var screen = new MegaMan.Common.ScreenInfo(name, Tileset);

            int[][] tiles = new int[tile_height][];
            for (int y = 0; y < tile_height; y++)
            {
                tiles[y] = new int[tile_width];
            }

            screen.Layers.Add(new ScreenLayerInfo(name, new TileLayer(tiles, Tileset, 0, 0), new List<EntityPlacement>(), new List<ScreenLayerKeyframe>()));

            map.Screens.Add(name, screen);

            if (StartScreen == null) StartScreen = map.Screens.Keys.First();

            ScreenDocument doc = WrapScreen(screen);

            // now I can do things like fire an event... how useful!
            if (ScreenAdded != null) ScreenAdded(doc);

            Save();
        }
Exemple #13
0
        private ScreenHandler CreateScreen(StageHandler stage, ScreenInfo screen, IEnumerable<JoinHandler> joins)
        {
            var patterns = new List<BlocksPattern>(screen.BlockPatterns.Count);

            foreach (BlockPatternInfo info in screen.BlockPatterns)
            {
                BlocksPattern pattern = new BlocksPattern(info, stage, _entityPool);
                patterns.Add(pattern);
            }

            var layers = new List<ScreenLayer>();
            foreach (var layerInfo in screen.Layers)
            {
                layers.Add(new ScreenLayer(layerInfo, stage, _respawnTracker));
            }

            return new ScreenHandler(screen, layers, joins, patterns, stage);
        }
Exemple #14
0
        private JoinHandler CreateJoin(Join join, StageHandler stage, ScreenInfo screen)
        {
            if (join.bossDoor)
            {
                return new BossDoorHandler(join, stage, _entityPool, screen.Tileset.TileSize, screen.PixelHeight, screen.PixelWidth, screen.Name);
            }

            return new JoinHandler(join, screen.Tileset.TileSize, screen.PixelHeight, screen.PixelWidth, screen.Name);
        }
        public void AddScreen(ScreenInfo screen)
        {
            var doc = WrapScreen(screen);
            _map.Screens.Add(screen.Name, screen);

            if (StartScreen == null)
            {
                _map.StartScreen = _map.Screens.Keys.First();
                Dirty = true;
            }

            if (ScreenAdded != null) ScreenAdded(doc);
        }
        public ScreenDocument AddScreen(string name, int tile_width, int tile_height)
        {
            var screen = new ScreenInfo(name, Tileset.Tileset);

            int[,] tiles = new int[tile_width, tile_height];

            screen.Layers.Add(new ScreenLayerInfo(name, new TileLayer(tiles, Tileset.Tileset, 0, 0), false, new List<ScreenLayerKeyframe>()));

            _map.Screens.Add(name, screen);

            if (StartScreen == null)
            {
                _map.StartScreen = _map.Screens.Keys.First();
                Dirty = true;
            }

            ScreenDocument doc = WrapScreen(screen);

            if (ScreenAdded != null) ScreenAdded(doc);

            return doc;
        }