Ejemplo n.º 1
0
        private void createRandomEnemies()
        {
            // Create Enemies [RANDOMLY]
            int chanceToSpawn = r.Next(25);                                                   // Inverse chance to spawn (ie. 25 is 1/25 chance, 100, is 1/100 chance)

            if (chanceToSpawn == 0 && EnemyShips.Count < 20)                                  // Limit destructibles to 20
            {
                int                 health       = 50;                                        // Initial Health of Enemy
                int                 fireDamage   = r.Next(50);                                // Firing Damage of Enemy
                int                 fireSpeed    = r.Next(50);                                // Firing Speed of Enemy
                Vector2             moveSpeed    = new Vector2(0, (r.Next(2) + 4));           // Movement Speed of Enemy
                int                 xPos         = r.Next(graphics.PreferredBackBufferWidth); // Initial X Position of the enemy at the top of the screen
                Vector2             position     = new Vector2(xPos, 0);
                List <WeaponObject> enemyWeapons = new List <WeaponObject>();
                int                 numWeps      = r.Next(2) + 1;
                for (int i = 0; i < numWeps; i++)
                {
                    float FireSpeed = r.Next(100, 500);
                    enemyWeapons.Add(new WeaponObject(false, 1, (int)(0.5 * FireSpeed), -10, 0.3, 1, FireSpeed));
                }
                EnemyShip enemy = new EnemyShip(position, health, enemyWeapons, moveSpeed);

                enemy.Initialize(new EnemyParticleEngine(enemyEmitTextures, new Vector2(xPos, 0)));

                //destructibleObjects.Add(enemy);
                EnemyShips.Enqueue(enemy); // Put it in the queue
            }
        } // Randomly generate enemies at the top of the screen TEMPORARY SOLUTION
Ejemplo n.º 2
0
        private void createRandomEnemies()
        {
            // Create Enemies [RANDOMLY]
            int chanceToSpawn = r.Next(25); // Inverse chance to spawn (ie. 25 is 1/25 chance, 100, is 1/100 chance)
            if (chanceToSpawn == 0 && EnemyShips.Count < 20) // Limit destructibles to 20
            {
                int health = 50; // Initial Health of Enemy
                int fireDamage = r.Next(50); // Firing Damage of Enemy
                int fireSpeed = r.Next(50); // Firing Speed of Enemy
                Vector2 moveSpeed = new Vector2(0, (r.Next(2) + 4)); // Movement Speed of Enemy
                int xPos = r.Next(graphics.PreferredBackBufferWidth); // Initial X Position of the enemy at the top of the screen
                Vector2 position = new Vector2(xPos, 0);
                List<WeaponObject> enemyWeapons = new List<WeaponObject>();
                int numWeps = r.Next(2) + 1;
                for (int i = 0; i < numWeps; i++)
                {
                    float FireSpeed = r.Next(100, 500);
                    enemyWeapons.Add(new WeaponObject(false, 1, (int)(0.5 * FireSpeed), -10, 0.3, 1, FireSpeed));
                }
                EnemyShip enemy = new EnemyShip(position, health, enemyWeapons, moveSpeed);

                enemy.Initialize(new EnemyParticleEngine(enemyEmitTextures, new Vector2(xPos, 0)));

                //destructibleObjects.Add(enemy);
                EnemyShips.Enqueue(enemy); // Put it in the queue
            }
        }