public static ScreenHandler CreateScreen(Screen screen, PositionComponent playerPos, IEnumerable<Join> mapJoins) { List<BlocksPattern> blockPatterns = new List<BlocksPattern>(); foreach (BlockPatternInfo info in screen.BlockPatternInfo) { BlocksPattern pattern = new BlocksPattern(info); blockPatterns.Add(pattern); } var joinList = new List<JoinHandler>(); foreach (Join join in mapJoins) { if (join.screenOne == screen.Name || join.screenTwo == screen.Name) { //JoinHandler handler = CreateJoin(join); //joinList.Add(handler); } } Music music = null; string intropath = (screen.MusicIntroPath != null) ? screen.MusicIntroPath.Absolute : null; string looppath = (screen.MusicLoopPath != null) ? screen.MusicLoopPath.Absolute : null; if (intropath != null || looppath != null) music = Engine.Instance.SoundSystem.LoadMusic(intropath, looppath, 1); return new ScreenHandler(screen, music, playerPos, joinList, blockPatterns); }
public void AddScreen(string name, int tile_width, int tile_height) { var screen = new MegaMan.Common.Screen(tile_width, tile_height, map) {Name = name}; map.Screens.Add(name, screen); if (StartScreen == null) StartScreen = map.Screens.Keys.First(); ScreenDocument doc = WrapScreen(screen); screen.Save(System.IO.Path.Combine(Path.Absolute, name + ".scn")); // now I can do things like fire an event... how useful! if (ScreenAdded != null) ScreenAdded(doc); Save(); }
/* * * LoadScreenXml - Load xml data for screens * */ public void LoadScreenXml(XElement mapXml) { foreach (XElement screen in mapXml.Elements("Screen")) { string id = screen.Attribute("id").Value; Screen s = new Screen(Path.Combine(StagePath.Absolute, id + ".scn"), this); Screens.Add(id, s); if (Screens.Count == 1) { StartScreen = StartScreen ?? id; } foreach (XElement entity in screen.Elements("Entity")) { EntityPlacement info = EntityPlacement.FromXml(entity); info.boss = false; XAttribute palAttr = entity.Attribute("pallete"); if (palAttr != null) info.pallete = palAttr.Value; else info.pallete = "Default"; s.AddEnemy(info); } foreach (XElement teleport in screen.Elements("Teleport")) { TeleportInfo info; int from_x, from_y, to_x, to_y; teleport.Attribute("from_x").Value.TryParse(out from_x); teleport.Attribute("from_y").Value.TryParse(out from_y); teleport.Attribute("to_x").Value.TryParse(out to_x); teleport.Attribute("to_y").Value.TryParse(out 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; s.AddTeleport(info); } foreach (XElement blocks in screen.Elements("Blocks")) { BlockPatternInfo pattern = BlockPatternInfo.FromXml(blocks); s.AddBlockPattern(pattern); } XElement screenmusic = screen.Element("Music"); if (screenmusic != null) { XElement intro = screenmusic.Element("Intro"); XElement loop = screenmusic.Element("Loop"); s.MusicIntroPath = (intro != null) ? FilePath.FromRelative(intro.Value, StagePath.BasePath) : null; s.MusicLoopPath = (loop != null) ? FilePath.FromRelative(loop.Value, StagePath.BasePath) : null; XAttribute nsfAttr = screenmusic.Attribute("nsftrack"); if (nsfAttr != null) { int track; nsfAttr.Value.TryParse(out track); s.MusicNsfTrack = track; } } foreach (XElement entity in screen.Elements("Boss")) { EntityPlacement info = EntityPlacement.FromXml(entity); info.boss = true; s.AddEnemy(info); } } }
public void RenameScreen(Screen screen, string name) { this.Screens.Remove(screen.Name); screen.Name = name; this.Screens.Add(name, screen); }
public ScreenDocument(Screen screen, StageDocument stage) { Stage = stage; this.screen = screen; }