Exemplo n.º 1
0
        private void EnemyFire(EShip es)
        {
            if (es.canShoot)
            {
                Image i;

                if (es.Type == 0)
                {
                    i = Properties.Resources.lazer;
                }
                else
                {
                    i = Properties.Resources.plasma;
                }

                if (ship != null)
                {
                    Vector pointing = new Vector(ship.Pos - es.Pos);
                    int    height   = Properties.Resources.Emeny.Height;

                    Missile m = new Missile(new Vector(0, 0),
                                            new Vector(0, 0), 0, 0,
                                            i, false);

                    m.PlaceMissile(new Vector(es.Pos), (int)pointing.Angle, height);

                    newMissles.Add(m);
                }
                es.Vel            = new Vector(rand.Next(-5, 5), rand.Next(-5, 5));
                es.AngularV       = rand.Next(-10, 10);
                es.shoot.Interval = rand.Next(1, 4) * 1000;
            }
        }
Exemplo n.º 2
0
        public void AddEnemies()
        {
            foreach (EShip enemy in enemies)
            {
                if (!enemy.canShoot)
                {
                    int   imagevariation = rand.Next(0, 2);
                    Image i;

                    if (imagevariation == 0)
                    {
                        i = Properties.Resources.Emeny;
                    }
                    else
                    {
                        i = Properties.Resources.Emeny2;
                    }


                    EShip e = new EShip(new Vector(enemy.Pos), new Vector(rand.Next(-5, 5), rand.Next(-5, 5)), rand.Next(0, 360), rand.Next(-7, 7), i, imagevariation);
                    e.fire += EnemyFire;
                    enemiesToAdd.Add(e);
                }
            }
        }