public static void loadLevelMap() { Chunk.loadMapData(levelName); map = new ChunkMap(); try { wiringEditor = DataSerializer.Deserialize <WiringEditor>(levelName + "Wiring"); } catch (Exception e) { wiringEditor = new WiringEditor { rects = new List <SelectRect>(), connections = new List <WireConnection>() }; } wiringEditor.applyWiring(); }
protected override void Initialize() { // TODO: Add your initialization logic here graphics.PreferredBackBufferHeight = 1080; graphics.PreferredBackBufferWidth = 1920; Window.IsBorderless = false; Window.AllowUserResizing = true; graphics.ApplyChanges(); // level settings levelSettingsDict["Old"] = new LevelSettings { playerStartPos = new Vector2(30, 40) }; levelSettingsDict["Sam"] = new LevelSettings { playerStartPos = new Vector2(10, 70) }; levelSettingsDict["Gravity"] = new LevelSettings { playerStartPos = new Vector2(15, 94) }; foreach (var level in levels) { if (!levelSettingsDict.Keys.Contains(level)) { levelSettingsDict[level] = new LevelSettings(); } } base.Initialize(); Textures.loadTextures(); Tile.exportTilePalette(); SoundPlayer.loadEffects(); calm = SoundPlayer.getEffect("CalmSong"); chaos = SoundPlayer.getEffect("ChaosSong"); calmI = calm.CreateInstance(); chaosI = chaos.CreateInstance(); calmI.IsLooped = true; chaosI.IsLooped = true; calmI.Play(); calmI.Volume = 1.0F; chaosI.Play(); chaosI.Volume = 0.0F; camera = new Camera(Vector2.Zero, 5); player = new Player(playerStartPos()); for (int i = 0; i < particles.Length; i++) { particles[i] = new List <Particle>(); } resetLevel(); renderTarget = new RenderTarget2D( GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight, false, GraphicsDevice.PresentationParameters.BackBufferFormat, DepthFormat.Depth24); // UI pauseUI.Add(new UIButton(unPauseClicked, new Vector2(200, 200), new Vector2(300, 100), "Resume")); pauseUI.Add(new UIButton(() => { restartRun(); unPauseClicked(); }, new Vector2(250, 310), new Vector2(300, 100), "Restart")); pauseUI.Add(new UIButton(() => uiScreen = new MainMenuScreen(), new Vector2(300, 420), new Vector2(300, 100), "Main Menu")); pauseUI.Add(new UIButton(() => uiScreen = new LevelSelectScreen(), new Vector2(350, 530), new Vector2(300, 100), "Level Select")); pauseUI.Add(new UIButton(exitGame, new Vector2(400, 640), new Vector2(300, 100), "Exit Game")); pauseUI.Add(new PauseStats(new Vector2(1920 - 250, 1080 / 2F), new Vector2(400, 1080 - 400))); // stats try { stats = new Stats(DataSerializer.Deserialize <StatData>("Stats")); } catch (Exception e) { stats = new Stats(); Logger.warn("Found no pre-existing stats!, making new instance"); } }