Esempio n. 1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            SpriteBatch = new SpriteBatch(GraphicsDevice);

            // Load some default fonts.
            MediumFont      = ContentManager.Load <GameFont>("Fonts/MediumFont");
            MediumFont.Size = 24;

            // Load loading icon atlas.
            LoadingIconSprite       = new AnimatedSprite(ContentManager.Load <Texture2D>("Textures/LoadingIconAtlas"), 128, 128, 60);
            LoadingIconSprite.Pivot = new Vector2(0.5f, 0.5f);

            // Create the main sprite atlas.
            SpriteAtlas = new SpriteAtlas(2048, 2048);

            // Loading missing texture sprite.
            MissingTextureSprite       = SpriteAtlas.Add("Textures/MissingTexture");
            MissingTextureSprite.Pivot = new Vector2(0.5f, 1f); // Bottom center.

            // Temporarily load tiles here.
            TreeTile              = SpriteAtlas.Add("Textures/TileComps/Trees");
            MountainTile          = SpriteAtlas.Add("Textures/TileComps/Mountain");
            TileShadowTopRight    = SpriteAtlas.Add("Textures/TileShadowTopRight");
            TileShadowTopLeft     = SpriteAtlas.Add("Textures/TileShadowTopLeft");
            TileShadowBottomRight = SpriteAtlas.Add("Textures/TileShadowBottomRight");
            TileShadowBottomLeft  = SpriteAtlas.Add("Textures/TileShadowBottomLeft");
            HouseTile             = SpriteAtlas.Add("Textures/TileComps/House");

            // Load definitions.
            string defPath = Path.Combine(ContentDirectory, "Defs");

            DefDatabase = new DefDatabase();
            Debug.StartTimer("Load def files");
            DefDatabase.AddAllFromDirectory(defPath);
            Debug.StopTimer(true);
            Debug.StartTimer("Parse & resolve defs");
            DefDatabase.Load();
            Debug.StopTimer(true);

            // Tile loading from defs.
            Debug.StartTimer("Tile def load");
            DefFactory <Tile, TileDef> .Init("Tile");

            Debug.StopTimer(true);

            Debug.StartTimer("Tile comp def load");
            DefFactory <TileComponent, TileCompDef> .Init("TileComp");

            Debug.StopTimer(true);

            Debug.StartTimer("Entity comp def load");
            DefFactory <Entity, EntityDef> .Init("Entity");

            Debug.StopTimer(true);

            SpriteAtlas.Pack(false);

            Loop.Start();
        }