Exemplo n.º 1
0
 private void AddLoot(Enemy e)
 {
     var r = new Random();
     int amount = 0;
     int type = r.Next(0, 10);
     amount = SelectAmount(type, amount, r);
     int tmp = r.Next(1, 100);
     if (tmp < e.DropRate && !e.Boss)
     {
         PowerUps.Add(new Loot(type, amount, e.X, e.Y));
     }
     else if (e.Boss)
     {
         PowerUps.Add(new BossLoot(e.X, e.Y));
     }
 }
Exemplo n.º 2
0
        private void DrawNormalEnemy(Enemy enemy)
        {
            if (enemy.Type != 1)
            {

                spriteBatch.Draw(dummyTexture, new Rectangle(enemy.X, enemy.Y - 10, enemy.Width, 3), Color.Red);
                double lifelength = (enemy.Width / (double)enemy.MaxHealt) * enemy.Healt;
                spriteBatch.Draw(dummyTexture, new Rectangle(enemy.X, enemy.Y - 10, (int)lifelength, 3),
                                 new Color(7, 237, 15));
            }
            if (enemy.Type == 1)
            {
                var origin = new Vector2();
                origin.X = EnemyComet.Width / (float)2;
                origin.Y = EnemyComet.Height / (float)2;
                var screePos = new Vector2();
                screePos.X = enemy.X + (enemy.Width / 2);
                screePos.Y = enemy.Y + (enemy.Height / 2);
                var nonUniformScale = new Vector2();
                nonUniformScale.X = enemy.Width / (float)EnemyComet.Width;
                nonUniformScale.Y = enemy.Height / (float)EnemyComet.Height;
                //  spriteBatch.Draw(dummyTexture, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height), Color.White);
                spriteBatch.Draw(EnemyComet, screePos, null, Color.White, (float)((Comet)enemy).rotate, origin,
                                 nonUniformScale, SpriteEffects.None, 0f);
            }

            if (enemy.Type == 2)
            {
                spriteBatch.Draw(EnemySentry, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height),
                                 Color.White);
            }

            if (enemy.Type == 3)
            {
                spriteBatch.Draw(CargoCrateT, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height),
                                 Color.White);
            }

            if (enemy.Type == 4)
            {

                Vector2 realPos = new Vector2(((Striker)enemy).pos.X + enemy.Width / 2, ((Striker)enemy).pos.Y + enemy.Height / 2);
                spriteBatch.Draw(
                       EnemyStriker,
                       realPos,
                       null,
                       Color.White,
                       ((Striker)enemy).Angle,

                      new Vector2(
                           enemy.Width / 2,
                           enemy.Height / 2),
                       1.0f,
                       SpriteEffects.None,
                       1.0f);
            }
            if (enemy.Type == 5)
            {
                spriteBatch.Draw(EnemyBomber, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height),
                                 Color.White);
            }

            if (enemy.Type == 6)
            {
                if (((ChargingSentry) enemy).Angle == 0)
                {
                    spriteBatch.Draw(EnemySentry, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height),
                                 Color.White);
                }
                else
                {

                    Vector2 realPos = new Vector2(((ChargingSentry) enemy).pos.X + enemy.Width/2,
                                                  ((ChargingSentry) enemy).pos.Y + enemy.Height/2);
                    spriteBatch.Draw(
                        EnemySentryReversed,
                        realPos,
                        null,
                        Color.White,
                        ((ChargingSentry) enemy).Angle,

                        new Vector2(
                            enemy.Width/2,
                            enemy.Height/2),
                        1.0f,
                        SpriteEffects.None,
                        1.0f);
                }

            }
            if (enemy.Type == 7)
            {
                spriteBatch.Draw(EnemyDestroyer, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height),
                             Color.White);

            }
        }
Exemplo n.º 3
0
 private void AddExplosion(Enemy e)
 {
     SoundController.PlayExplosion();
     var animatedExplosion = new AnimatedExplosion(Vector2.Zero, 0.0f, 1.0f, 0.5f, e.X, e.Y, e.Width, e.Height, e.Speed);
     var res = spriteController.AddExplosion(animatedExplosion, 10);
     Explosions.Add(res);
 }
Exemplo n.º 4
0
        private void DrawBoss(Enemy enemy)
        {
            spriteBatch.Draw(dummyTexture, new Rectangle(100, Game1.TopLimit + 40, Game1.SWidth - 200, 30),
                             Color.Red);
            double lifelength = ((Game1.SWidth - 200) / (double)enemy.MaxHealt) * enemy.Healt;
            spriteBatch.Draw(dummyTexture, new Rectangle(100, Game1.TopLimit + 40, (int)lifelength, 30),
                             new Color(7, 237, 15));

            spriteBatch.Draw(SmallBossT, new Rectangle(enemy.X, enemy.Y, enemy.Width, enemy.Height),
                             Color.White);
        }