Esempio n. 1
0
        protected override void SecondaryShootingPattern(GameTime gameTime)
        {
            double width         = Math.PI;
            double numberOfShots = 7;

            List <double> spreadDirections = MathFunctions.GetSpreadDirList(width, numberOfShots);

            int shotNbr    = 0;
            int centerShot = (int)(numberOfShots / 2) + 1;

            foreach (double dir in spreadDirections)
            {
                shotNbr++;
                if (shotNbr == centerShot)
                {
                    continue;
                }

                EnemyWeakRedLaser laser = new EnemyWeakRedLaser(Game, spriteSheet);
                laser.Position  = Position;
                laser.Direction = MathFunctions.DirFromRadians(dir);
                laser.Initialize();

                laser.Speed    *= 0.3f;
                laser.Duration *= 1.5f;

                Game.stateManager.shooterState.gameObjects.Add(laser);
            }
        }
Esempio n. 2
0
        protected override void SecondaryShootingPattern(GameTime gameTime)
        {
            double width         = 2 * Math.PI;
            int    numberOfShots = 6;

            double randomOffset = random.NextDouble() * Math.PI * 2;

            List <double> spreadDirections = MathFunctions.GetSpreadDirList(width, numberOfShots);

            foreach (double dir in spreadDirections)
            {
                EnemyWeakRedLaser laser1 = new EnemyWeakRedLaser(Game, spriteSheet);
                laser1.PositionX = PositionX;
                laser1.PositionY = PositionY;

                double shootDir = dir + randomOffset;

                laser1.Direction = MathFunctions.DirFromRadians(shootDir);
                laser1.Initialize();
                laser1.Speed    *= 1.0f;
                laser1.Duration *= 0.4f;

                Game.stateManager.shooterState.gameObjects.Add(laser1);
            }
        }
Esempio n. 3
0
        //Hanterar "shooting"
        private void HandleShooting(GameTime gameTime)
        {
            lastTimeShot += gameTime.ElapsedGameTime.Milliseconds;

            if (lastTimeShot >= shootingDelay)
            {
                EnemyWeakRedLaser laser1 = new EnemyWeakRedLaser(Game, spriteSheet);
                laser1.PositionX = PositionX - 5;
                laser1.PositionY = PositionY + 8;
                laser1.Direction = new Vector2(0, 1.0f);
                laser1.Initialize();
                laser1.Duration = 500;

                EnemyWeakRedLaser laser2 = new EnemyWeakRedLaser(Game, spriteSheet);
                laser2.PositionX = PositionX + 5;
                laser2.PositionY = PositionY + 8;
                laser2.Direction = new Vector2(0, 1.0f);
                laser2.Initialize();
                laser2.Duration = 500;

                EnemyWeakRedLaser laser3 = new EnemyWeakRedLaser(Game, spriteSheet);
                laser3.PositionX = PositionX + 8;
                laser3.PositionY = PositionY + 5;
                laser3.Direction = new Vector2(0, 1.0f);
                laser3.Initialize();
                laser3.Duration = 500;

                EnemyWeakRedLaser laser4 = new EnemyWeakRedLaser(Game, spriteSheet);
                laser4.PositionX = PositionX - 8;
                laser4.PositionY = PositionY + 5;
                laser4.Direction = new Vector2(0, 1.0f);
                laser4.Initialize();
                laser4.Duration = 500;

                Game.stateManager.shooterState.gameObjects.Add(laser1);
                Game.stateManager.shooterState.gameObjects.Add(laser2);
                Game.stateManager.shooterState.gameObjects.Add(laser3);
                Game.stateManager.shooterState.gameObjects.Add(laser4);

                lastTimeShot -= shootingDelay;

                Game.soundEffectsManager.PlaySoundEffect(SoundEffects.SmallLaser, soundPan);
            }
        }
        protected override void ShootingPattern(GameTime gameTime)
        {
            EnemyWeakRedLaser laser1 = new EnemyWeakRedLaser(Game, spriteSheet);

            laser1.PositionX = PositionX - 4;
            laser1.PositionY = PositionY;
            laser1.Direction = new Vector2(0, 1.0f);
            laser1.Initialize();
            laser1.Duration *= 0.8f;

            EnemyWeakRedLaser laser2 = new EnemyWeakRedLaser(Game, spriteSheet);

            laser2.PositionX = PositionX + 4;
            laser2.PositionY = PositionY;
            laser2.Direction = new Vector2(0, 1.0f);
            laser2.Initialize();
            laser2.Duration *= 0.8f;

            Game.stateManager.shooterState.gameObjects.Add(laser1);
            Game.stateManager.shooterState.gameObjects.Add(laser2);
        }
        protected override void ShootingPattern(GameTime gameTime)
        {
            int    nbrOfShots = 12;
            double spread     = Math.PI / 8;

            Vector2 initDir = MathFunctions.ScaleDirection(ShootObject.Position - Position);

            for (int n = 0; n < nbrOfShots; n++)
            {
                EnemyWeakRedLaser bullet = new EnemyWeakRedLaser(Game, spriteSheet);
                bullet.PositionX = PositionX;
                bullet.PositionY = PositionY;

                bullet.Direction = MathFunctions.SpreadDir(initDir, spread);
                bullet.Initialize();
                bullet.Duration *= 0.8f;
                bullet.Speed    *= 0.8f;

                bullet.SetSpreadSpeed(random);

                Game.stateManager.shooterState.gameObjects.Add(bullet);
            }
        }
Esempio n. 6
0
        private void HandleShooting(GameTime gameTime)
        {
            lastTimeShot += gameTime.ElapsedGameTime.Milliseconds;

            if (lastTimeShot >= shootingDelay)
            {
                EnemyWeakRedLaser laser1 = new EnemyWeakRedLaser(Game, spriteSheet);
                EnemyWeakRedLaser laser2 = new EnemyWeakRedLaser(Game, spriteSheet);

                if (cannons == 0)
                {
                    laser1.PositionX = PositionX - 32;
                    laser1.PositionY = PositionY + 1;
                    laser1.Direction = new Vector2(0, 1.0f);
                    laser1.Initialize();
                    laser1.Duration = 500;

                    laser2.PositionX = PositionX + 32;
                    laser2.PositionY = PositionY + 1;
                    laser2.Direction = new Vector2(0, 1.0f);
                    laser2.Initialize();
                    laser2.Duration = 500;

                    cannons = 1;
                }

                else if (cannons == 1)
                {
                    laser1.PositionX = PositionX - 13;
                    laser1.PositionY = PositionY + 29;
                    laser1.Direction = new Vector2(0, 1.0f);
                    laser1.Initialize();
                    laser1.Duration = 500;

                    laser2.PositionX = PositionX + 13;
                    laser2.PositionY = PositionY + 29;
                    laser2.Direction = new Vector2(0, 1.0f);
                    laser2.Initialize();
                    laser2.Duration = 500;

                    cannons = 2;
                }

                else
                {
                    laser1.PositionX = PositionX - 2;
                    laser1.PositionY = PositionY + 1;
                    laser1.Direction = new Vector2(0, 1.0f);
                    laser1.Initialize();
                    laser1.Duration = 500;

                    laser2.PositionX = PositionX + 2;
                    laser2.PositionY = PositionY + 1;
                    laser2.Direction = new Vector2(0, 1.0f);
                    laser2.Initialize();
                    laser2.Duration = 500;

                    cannons = 0;
                }

                Game.stateManager.shooterState.gameObjects.Add(laser1);
                Game.stateManager.shooterState.gameObjects.Add(laser2);

                lastTimeShot -= shootingDelay;

                Game.soundEffectsManager.PlaySoundEffect(SoundEffects.SmallLaser, soundPan);
            }
        }