public void Load(ContentManager Content) { Random r = new Random(); Dictionary <string, PaintedTile[]> biomes = new Dictionary <string, PaintedTile[]>(); foreach (var tile in TilePerBiome) { var textures = new PaintedTile[tile.Value.max - tile.Value.min]; for (int i = tile.Value.min; i < tile.Value.max; i++) { textures[i] = new PaintedTile() { texture = Content.Load <Texture2D>($"{tile.Value.filename}{i}"), biome = tile.Value.biome, family = tile.Key }; textures[i].tick = 360; textures[i].timer = r.Next(0, 360); } biomes.Add(tile.Key, textures); } textures = biomes; foreach (var name in PlacePaths.Keys) { Places[name] = Content.Load <Texture2D>(PlacePaths[name]); } foreach (var name in CharPaths.Keys) { Chars[name] = Content.Load <Texture2D>(CharPaths[name]); } }
public void Draw(SpriteBatch spriteBatch, SpriteFont font) { time++; { // draw map for (int i = 0; i < MapWidth; i++) { for (int j = 0; j < MapHeight; j++) { PaintedTile tex = fields[i, j]; if (fields[i, j] == null) { tex = textures["_"][0]; } if (tex.timer >= tex.tick) { tex.timer = 0; } var scale = Vector2.One; var dt = 0.0f; var st = 0.0f; if (tex.biome == "water") { dt = 1f; st = 0.03f; if (tex.timer == 1) { Put(i, j, tex.biome); } } else if (tex.biome == "moors") { dt = 0.33f; st = 0.05f; } else if (tex.biome == "forest") { dt = 0.33f; st = 0.02f; } tex.timer += dt; float s = 1.0f + (float)Math.Sin(tex.timer * Math.PI / 180.0f) * st; scale *= s; var origin = new Vector2(tex.texture.Width / 2, tex.texture.Height / 2); spriteBatch.Draw(tex.texture, XY(i, j), null, tex.color, 0, origin, scale, SpriteEffects.None, 0); } } } // draw town titles foreach (var town in TownTitles) { var d = town.Key; var s = town.Value; var tex = this[town.Value.Key]; tex.timer += 0.1f; if (tex.timer >= tex.tick) { tex.timer = 0; } var size = TownFields[tex.symbol].Count; var scale = 1.0f + (0.12f * size) + (float)Math.Sin(tex.timer * Math.PI / 180.0f) * 0.1f; for (int i = -2; i < 3; i++) { for (int j = -2; j < 3; j++) { spriteBatch.DrawString(font, s.Value, d - new Vector2(i, 30 + j), new Color(105, 105, 108), 0, font.MeasureString(s.Value) / 2, scale, SpriteEffects.None, 1); } } spriteBatch.DrawString(font, s.Value, d - new Vector2(0, 30), Color.White, 0, font.MeasureString(s.Value) / 2, scale, SpriteEffects.None, 1); } // draw locations // draw characters }