public static void Render(GameEngine engine, GraphicsRenderer renderer, ClientMap map, GameTime gameTime) { Dictionary <int, List <CoreAbstractEntity> > sortedEntities = GetEntitiesByTilePosition(map); (ClientMapTile tile, Vector2 position) = GetHighlightedTile(engine, map); renderer.Start(); for (int i = 0; i < map.Width * map.Height; ++i) { int tileX = i % map.Width; int tileY = i / map.Width; float drawX = tileX * ClientMapTile.TILE_WIDTH; float drawY = tileY * ClientMapTile.TILE_HEIGHT; MapTileRenderer.Render(engine, renderer, gameTime, map[i], drawX, drawY); if (tile != null && tileX == (int)position.X && tileY == (int)position.Y) { renderer.Render(AssetRegistry.TILE_SELECTION, drawX, drawY); } if (sortedEntities.ContainsKey(i)) { RenderEntities(engine, renderer, gameTime, sortedEntities[i], map[i], drawX, drawY); } } renderer.Finish(); }
/// <summary> /// Draws a string to the screen using bitmap font. Note that line breaks '\n' is also /// supported, which will begin subsequent texts on the next line. /// /// Fonts are rendered in cartesian co-ordinates and are not affected by renderer offsets. /// You do not wrap the call with <c>renderer.Start()</c> or <c>renderer.Finish()</c> for the invocation. /// </summary> /// <param name="renderer">The renderer to draw textures with.</param> /// <param name="text">String text content to display.</param> /// <param name="x">X co-ordinate, in pixels, of the first character of the text.</param> /// <param name="y">Y co-ordinate, in pixels, of the first character of the text.</param> /// <param name="style">Optional: type of font to use, set to <c cref="STYLE_DEFAULT">FontStyle.STYLE_DEFAULT</c> by default.</param> /// <param name="scale">Optional: size of each character, which is 1.0f magnification by default.</param> public static void Render([NotNull] GraphicsRenderer renderer, string text, float x, float y, FontStyle style = null, float scale = 1.0f) { if (style == null) { style = STYLE_DEFAULT; } renderer.Start(); renderer.PushPerspective(ViewPerspectives.CARTESIAN); float drawX = x; float drawY = y; foreach (char character in text) { if (character == '\n') { drawY += style.GetCharacterHeight() * scale; drawX = x; } Sprite characterImage = style.GetTextureFor(character); if (characterImage != null) { renderer.Render(characterImage, drawX, drawY, applyOffset: false, scale: scale); } drawX += style.GetCharacterWidth(character) * scale; } renderer.PopPerspective(); renderer.Finish(); }
internal static void Render(GameEngine engine, GraphicsRenderer renderer, GameTime gameTime, ClientMapTile tile, float x, float y) { SpriteAnimation tileAnimation = MapTileTextures.GetById(tile.Id); renderer.Render(tileAnimation, x, y, offsetY: tile.HeightOffset); }