Пример #1
0
        void FireControl(Keys k)
        {
            if (sw.ElapsedMilliseconds >= 1000)
            {
                Direction dir = new Direction();
                switch (k)
                {
                case (Keys.Up): dir = Direction.Up; break;

                case (Keys.Down): dir = Direction.Down; break;

                case (Keys.Left): dir = Direction.Left; break;

                case (Keys.Right): dir = Direction.Right; break;

                default: dir = Direction.Still; break;
                }
                if (dir == Direction.Still)
                {
                    return;
                }
                ShootingControl.Shoot(PlayerPanel.Location, dir);
                sw.Restart();
            }
        }
Пример #2
0
        public Enemy(Point pos, Direction dir, Panel l, Size s)
        {
            DangerBullets = new List <Bullet>();
            position      = pos;
            direction     = dir;
            label         = l;
            Action lblact = () =>
            {
                label.Width           = 40;
                label.Height          = 40;
                label.BackColor       = Color.Transparent;
                label.Location        = pos;
                label.BackgroundImage = new Bitmap(Application.StartupPath + "\\enemy_not_bad.png");
            };

            while (!EnemyManager.GetDescriptorStatus())
            {
            }
            label.Invoke(lblact);
            this.s   = s;
            movement = () =>
            {
                label.Location = mover(label.Location);
            };
            EnemyManager.EnemiesMovement += this.MoveAhead;
            ShootingControl.PewPew       += this.AddPotentialKiller;
            ShootingControl.Boom         += this.RemovePotentialKiller;
            DangerBullets.AddRange(ShootingControl.GetBullets());
            OptimizeDirection();
        }
Пример #3
0
 public void RestartGame()
 {
     domework = false;
     //while (working) { }
     tank.Teleport(new Point(this.Width / 2 - 20, this.Height / 2 - 20));
     ShootingControl.ExplodeAll();
     EnemyManager.ExplodeAll();
     control_block  = true;
     this.BackColor = Color.WhiteSmoke;
     basespeed      = 1;
     mf.GameStart();
     label1.Visible = false;
     domework       = true;
 }
Пример #4
0
 void MoveForward()
 {
     while (!EnemyManager.GetDescriptorStatus())
     {
     }
     label.Invoke(movement);
     if (label.Location.X < 0 || label.Location.Y < 0 || label.Location.Y > s.Height || label.Location.X > s.Width)
     {
         ShootingControl.StopPlease();
         ShootingControl.BulletsMovement -= this.MoveForward;
         ShootingControl.BulletExplode(this);
         ShootingControl.DontStopPlease();
     }
 }
Пример #5
0
 private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
 {
     try
     {
         int elapsed      = 0;
         int elapsedtotal = 0;
         while (endless)
         {
             if (control_block && domework)
             {
                 working = true;
                 ShootingControl.MoveBullets();
                 EnemyManager.MoveEnemies();
                 while (stopper)
                 {
                 }
                 Thread.Sleep(10);
                 elapsed      += 10;
                 elapsedtotal += 10;
                 if (elapsedtotal >= 1000)
                 {
                     mf.IncTimeBonus();
                     spawnrate--;
                     elapsedtotal = 0;
                 }
                 if (elapsed >= spawnrate)
                 {
                     EnemyManager.SpawnEnemy();
                     elapsed = 0;
                     mf.IncTimeBonus();
                 }
             }
             working = false;
         }
     }
     catch
     {
     }
 }
Пример #6
0
        void MoveAhead()
        {
            while (!EnemyManager.GetDescriptorStatus())
            {
            }
            label.Invoke(movement);
            distance++;
            if (distance >= 40)
            {
                OptimizeDirection();
                distance = 0;
            }
            Bullet b = null;
            bool   t = false;

            if (DangerBullets.Count != 0)
            {
                t = this.HitCheck(out b);
            }
            if (t || label.Location.X < 0 || label.Location.Y < 0 || label.Location.Y > s.Height || label.Location.X > s.Width)
            {
                while (!EnemyManager.GetDescriptorStatus())
                {
                }
                ShootingControl.StopPlease();
                EnemyManager.EnemyExplode(this);
                if (t)
                {
                    b.EnemyHit = true;
                    ShootingControl.BulletExplode(b);
                    b.Atpison();
                }
                EnemyManager.EnemiesMovement -= this.MoveAhead;
                ShootingControl.PewPew       -= this.AddPotentialKiller;
                ShootingControl.Boom         -= this.RemovePotentialKiller;
                ShootingControl.DontStopPlease();
            }
        }