示例#1
0
        public static void DrawPlayer(Graphics graphics, Entity entity, bool isDebugMode = false)
        {
            var player = entity as Player;

            if (player == null || player.InvincibilityTime % 2 != 0)
            {
                return;
            }
            graphics.TranslateTransform(player.X, player.Y);
            graphics.RotateTransform(player.Direction);
            var x = -PlayerBaseBitmap.Width / 2;
            var y = -PlayerBaseBitmap.Height / 2;

            graphics.DrawImage(PlayerBaseBitmap, x, y);
            graphics.DrawImage(BoostersBitmaps[player.BoostersLevel], x, y);
            graphics.DrawImage(GunsBitmaps[player.GunsAmountLevel], x, y);
            if (isDebugMode)
            {
                DrawUtils.DrawCollisionBox(graphics, player);
            }

            graphics.RotateTransform(-player.Direction);
            graphics.TranslateTransform(-player.X, -player.Y);
        }
        public static void DrawEntity(Graphics graphics, Entity entity, bool isDebugMode = false)
        {
            var texture = entity as ISingleTexture;

            if (texture == null)
            {
                return;
            }
            graphics.TranslateTransform(entity.X, entity.Y);
            graphics.RotateTransform(entity.Direction);

            if (Bitmaps.ContainsKey(texture.GetTextureFileName()))
            {
                var bitmap = Bitmaps[texture.GetTextureFileName()];
                DrawUtils.DrawCenteredBitmap(graphics, bitmap);
            }
            if (isDebugMode)
            {
                DrawUtils.DrawCollisionBox(graphics, entity);
            }

            graphics.RotateTransform(-entity.Direction);
            graphics.TranslateTransform(-entity.X, -entity.Y);
        }