Ejemplo n.º 1
0
 public void RandomGenerateBotPlane(int number, bool startImmediately = false)
 {
     lock (locker)
     {
         for (int i = 0; i < number;)
         {
             Random random = new Random((int)DateTime.Now.Ticks);
             if (random.Next(18) == 0)
             {
                 Point  pos     = new Point(random.Next(0, maxWidth), 0);
                 Random random1 = new Random();
                 if (random1.Next(18) == 0)
                 {
                     EnemyFighter.FighterType fighterType = (EnemyFighter.FighterType)random.Next(0, 3);
                     IPlane plane = new EnemyFighter(pos, fighterType);
                     if (startImmediately)
                     {
                         plane.Start();
                     }
                     if (planes.TryAdd(plane.GetID(), plane))
                     {
                         i++;
                     }
                 }
             }
         }
     }
 }
Ejemplo n.º 2
0
        public void CreateBotPlane(bool startImmediately)
        {
            Random random = new Random((int)DateTime.Now.Ticks);
            Point  pos    = new Point(random.Next(0, maxWidth), 0);

            EnemyFighter.FighterType fighterType = (EnemyFighter.FighterType)random.Next(0, 3);
            IPlane plane = new EnemyFighter(pos, fighterType);

            if (startImmediately)
            {
                plane.Start();
            }
            lock (locker)
            {
                planes.TryAdd(plane.GetID(), plane);
            }
        }