Example #1
0
        private void AddWeaveTypeB(int numSpawn)
        {
            Random rand = new Random(DateTime.Now.Millisecond);

            Ennemy ennemy;

            int randomInt = rand.Next(0, 6);

            // Position de départ de l'ennemie
            int lastPosX = rand.Next(PlayableViewport.X + 100, PlayableViewport.Width / 2);

            for (int i = 0; i < numSpawn; i++)
            {
                ennemy = new Ennemy(Registry.AlienDescriptions[randomInt]);

                ennemy.LoadContent();

                int x = lastPosX + ennemy.Width + 15;
                int y = 0;

                if (i % 2 == 0)
                {
                    y -= ennemy.Height - 5;
                }

                ennemy.Initialize(new Vector2(x, y));
                ennemy.Killed += new EventHandler <EventArgs>(ennemy_Killed);

                lastPosX = (int)ennemy.X;

                Add(ennemy);
            }
        }
Example #2
0
        private void AddWeaveTypeA(int numSpawn)
        {
            Random rand = new Random(DateTime.Now.Millisecond);

            Ennemy ennemy;

            int randomInt = rand.Next(0, 6);

            // Position de départ de l'ennemie
            // Prise en compte du radius
            int lastPosX = rand.Next(PlayableViewport.X + 100, PlayableViewport.Width / 2);

            for (int i = 0; i < numSpawn; i++)
            {
                if (_recycled[randomInt].Count > 0)
                {
                    ennemy = Members.ElementAt(_recycled[randomInt].Pop()) as Ennemy;
                    ennemy.Revive();
                }
                else
                {
                    ennemy = new Ennemy(Registry.AlienDescriptions[randomInt]);
                    ennemy.LoadContent();
                    ennemy.Killed += new EventHandler <EventArgs>(ennemy_Killed);
                }

                int x = lastPosX + ennemy.Width + 15;
                int y = i * (ennemy.Height - 5);

                ennemy.Initialize(new Vector2(x, y));

                lastPosX = (int)ennemy.X;

                Add(ennemy);
            }
        }