Beispiel #1
0
        // draw the given unit's graphic
        private void DrawGraphic(SpriteBatch sb, UnitInstance unit)
        {
            if (unit == null)
            {
                return; // don't render anything if the unit is null
            }
            // calculate the units position
            Vector2   tileCentre = boardRenderer.GetTileCentre(unit.Location);
            Rectangle dest       = new Rectangle(
                (int)tileCentre.X - boardRenderer.TileSize / 2,
                (int)tileCentre.Y - boardRenderer.TileSize / 2,
                boardRenderer.TileSize,
                boardRenderer.TileSize);
            // draw the correct sprite at the unit's position
            SpriteAtlas atlas = Engine.Instance.Content.GetAsset <SpriteAtlas>(unit.BaseUnit.IconAtlas);

            atlas.Draw(sb, unit.BaseUnit.IconKey, dest); // TODO this might be bad for performance
        }