コード例 #1
0
ファイル: BagelDrawer.cs プロジェクト: Leoltron/Shooter
        public static void DrawBagel(Graphics graphics, Entity entity, bool isDebugMode = false)
        {
            var bagel = entity as BagelEnemy;

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

            if (bagel.Health > 1)
            {
                DrawUtils.DrawCenteredBitmap(graphics,
                                             bagel.Health - 1 < DamagedBagelBitmapsAmount
                        ? DamagedBagelBitmaps[bagel.Health - 1]
                        : DamagedBagelBitmaps[DamagedBagelBitmaps.Length - 1]);
            }
            DrawUtils.DrawCenteredBitmap(graphics, BagelBitmaps[bagel.BagelType]);
            if (isDebugMode)
            {
                DrawUtils.DrawCollisionBox(graphics, bagel);
            }

            graphics.RotateTransform(-bagel.Direction);
            graphics.TranslateTransform(-bagel.X, -bagel.Y);
        }
コード例 #2
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);
        }
コード例 #3
0
        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);
        }