protected override void Initialize() { MainGraphicsDevice = base.GraphicsDevice; GameWindow = base.Window; IsMouseVisible = true; Window.AllowUserResizing = true; Debug.Init(); JContent = new JContent(); JContent.RegisterLoader(new TextureLoader()); JContent.RegisterLoader(new FontLoader()); JContent.RegisterLoader(new SpriteLoader()); UponRegisterContentLoaders?.Invoke(JContent); ScreenManager = new ScreenManager(); ScreenManager.RegisterNew(new CameraMoveScreen()).Active = false; ScreenManager.RegisterNew(new LoadingScreen()).Active = true; ScreenManager.RegisterNew(new DebugDisplayScreen()).Active = true; UponRegisterScreens?.Invoke(ScreenManager); Entities = new EntityManager(); TileMap = new TileLayer(); if (PathfindingThreadCount < 1) { throw new Exception($"Pathfinding thread count must be at least 1. {PathfindingThreadCount} is not a valid value."); } Pathfinding = new Pathfinding(PathfindingThreadCount); Pathfinding.Start(); ScreenManager.Initialize(); base.Initialize(); }
protected override void LoadContent() { XNAContent = base.Content; // Create a new SpriteBatch, which can be used to draw textures. MainSpriteBatch = new SpriteBatch(GraphicsDevice); InitUI(); Debug.Log("Initialized UI engine."); // Create the main atlas packer. packer = new FixedSizeSpritePacker(1024, 1024, 1); JContent.Packer = packer; // Create a 'pixel' texture. var pixel = new Texture2D(GraphicsDevice, 1, 1, false, SurfaceFormat.Color); pixel.SetData(new Color[1] { Color.White }); Pixel = packer.TryPack(pixel, "White Pixel"); MissingTextureSprite = JContent.Load <Sprite>("Missing"); // Load most content from the screens. ScreenManager.LoadContent(JContent); UponLoadContent?.Invoke(JContent); // Pack the atlas with all those loaded sprites. MainAtlas = packer.CreateSpriteAtlas(true); JContent.Packer = null; packer.Dispose(); packer = null; Debug.Log("After all screens loaded content, the main atlas has been created!"); Debug.Log("Main Atlas: " + MainAtlas); // Start the other thread, the main game loop. Loop.Start(); }