public void TryLoad(StageLinkInfo info) { var stageReader = Game.CurrentGame.FileReaderProvider.GetStageReader(info.StagePath); StageInfo map = stageReader.Load(info.StagePath); var handler = new StageHandler(map); var joins = new Dictionary <ScreenInfo, Dictionary <Join, JoinHandler> >(); foreach (var screen in map.Screens.Values) { joins[screen] = new Dictionary <Join, JoinHandler>(); } foreach (Join join in map.Joins) { var screenOne = map.Screens[join.screenOne]; var screenTwo = map.Screens[join.screenTwo]; JoinHandler handlerOne = CreateJoin(join, handler, screenOne); joins[screenOne].Add(join, handlerOne); JoinHandler handlerTwo = CreateJoin(join, handler, screenTwo); joins[screenTwo].Add(join, handlerTwo); } var screens = new Dictionary <string, ScreenHandler>(); foreach (var screen in map.Screens.Values) { screens[screen.Name] = CreateScreen(handler, screen, joins[screen].Values.ToList()); } handler.InitScreens(screens); handler.WinHandler = info.WinHandler; if (info.LoseHandler == null) { // repeat this stage handler.LoseHandler = new HandlerTransfer { Fade = true, Type = HandlerType.Stage, Name = info.Name }; } else { handler.LoseHandler = info.LoseHandler; } _loadedStages[info.Name] = handler; }
public void TryLoad(StageLinkInfo info) { var stageReader = new StageXmlReader(); StageInfo map = stageReader.LoadStageXml(info.StagePath); var handler = new StageHandler(map); var joins = new Dictionary<ScreenInfo, Dictionary<Join, JoinHandler>>(); foreach (var screen in map.Screens.Values) { joins[screen] = new Dictionary<Join, JoinHandler>(); } foreach (Join join in map.Joins) { var screenOne = map.Screens[join.screenOne]; var screenTwo = map.Screens[join.screenTwo]; JoinHandler handlerOne = CreateJoin(join, handler, screenOne); joins[screenOne].Add(join, handlerOne); JoinHandler handlerTwo = CreateJoin(join, handler, screenTwo); joins[screenTwo].Add(join, handlerTwo); } var screens = new Dictionary<string, ScreenHandler>(); foreach (var screen in map.Screens.Values) { screens[screen.Name] = CreateScreen(handler, screen, joins[screen].Values.ToList()); } handler.InitScreens(screens); handler.WinHandler = info.WinHandler; if (info.LoseHandler == null) { // repeat this stage handler.LoseHandler = new HandlerTransfer { Fade = true, Type = HandlerType.Stage, Name = info.Name }; } else { handler.LoseHandler = info.LoseHandler; } _loadedStages[info.Name] = handler; }