Пример #1
0
 private void Timer3_Tick(object sender, EventArgs e)
 {
     if (ufo.GetN() > 0)
     {
         Random random = new Random();
         int    index  = random.Next(0, ufo.GetN());
         Ufo    oneUfo = (Ufo)ufo.GetEnemyTypeByIndex(index);
         Graphics.DrawLine(oneUfo.BlusterPen, oneUfo.GetPoint().X + oneUfo.Size.Width / 2, oneUfo.GetPoint().Y + oneUfo.Size.Height, oneUfo.GetPoint().X + oneUfo.Size.Width / 2, ActiveForm.Height);
         oneUfo.Bluster = true;
         Rectangle rectangle = new Rectangle(oneUfo.GetPoint().X + oneUfo.Size.Width / 4,
                                             oneUfo.GetPoint().Y + oneUfo.Size.Height,
                                             oneUfo.Size.Width / 2,
                                             ActiveForm.Height);
         if (player.GetRegion().IsVisible(rectangle, Graphics) && oneUfo.Bluster)
         {
             player.Life--;
         }
         oneUfo.Bluster = false;
     }
 }
Пример #2
0
        public void EnemyBatch(Form1 form1, string enemyType)
        {
            int copyN = n;

            n += DeltaN;
            int    rch;
            Random random = new Random();

            for (int i = copyN; i < n; i++)
            {
                rch = random.Next();
                if (enemyType.Equals("Ufo"))
                {
                    enemy[i] = new Ufo(form1, rch);
                }
                else if (enemyType.Equals("Asteroid"))
                {
                    enemy[i] = new Asteroid(form1, rch);
                }
                form1.Graphics.FillRegion(enemy[i].HatchBrush, enemy[i].Region);
            }
        }