Esempio n. 1
0
        //Hanterar "shooting"
        private void HandleShooting(GameTime gameTime)
        {
            lastTimeShot += gameTime.ElapsedGameTime.Milliseconds;

            if (lastTimeShot >= shootingDelay)
            {
                EnemyGreenBullet bullet1 = new EnemyGreenBullet(Game, spriteSheet);
                EnemyGreenBullet bullet2 = new EnemyGreenBullet(Game, spriteSheet);

                bullet1.PositionX = PositionX - 10;
                bullet1.PositionY = PositionY + 16;
                bullet1.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
                bullet1.Initialize();
                bullet1.Duration = 500;

                bullet2.PositionX = PositionX + 10;
                bullet2.PositionY = PositionY + 16;
                bullet2.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
                bullet2.Initialize();
                bullet2.Duration = 500;


                Game.stateManager.shooterState.gameObjects.Add(bullet1);
                Game.stateManager.shooterState.gameObjects.Add(bullet2);

                lastTimeShot -= shootingDelay;

                Game.soundEffectsManager.PlaySoundEffect(SoundEffects.SmallLaser, soundPan);
            }
        }
Esempio n. 2
0
        //Hanterar "shooting"
        private void HandleShooting(GameTime gameTime)
        {
            lastTimeShot += gameTime.ElapsedGameTime.Milliseconds;

            if (lastTimeShot >= shootingDelay)
            {
                lastTimeShot -= shootingDelay;

                EnemyGreenBullet laser1 = new EnemyGreenBullet(Game, spriteSheet);
                laser1.PositionX = PositionX - 2;
                laser1.PositionY = PositionY - 2;
                laser1.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
                laser1.Initialize();
                laser1.Duration  = 500;
                laser1.DrawLayer = .5f;

                EnemyGreenBullet laser2 = new EnemyGreenBullet(Game, spriteSheet);
                laser2.PositionX = PositionX + 2;
                laser2.PositionY = PositionY + 2;
                laser2.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
                laser2.Initialize();
                laser2.Duration  = 500;
                laser2.DrawLayer = .5f;

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

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

            if (shootingDelay2 != -1 && lastTimeShot >= shootingDelay2)
            {
                lastTimeShot -= shootingDelay2;

                EnemyGreenBullet laser1 = new EnemyGreenBullet(Game, spriteSheet);
                laser1.PositionX = PositionX - 2;
                laser1.PositionY = PositionY - 2;
                laser1.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
                laser1.Initialize();
                laser1.Duration  = 500;
                laser1.DrawLayer = .5f;

                EnemyGreenBullet laser2 = new EnemyGreenBullet(Game, spriteSheet);
                laser2.PositionX = PositionX + 2;
                laser2.PositionY = PositionY + 2;
                laser2.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
                laser2.Initialize();
                laser2.Duration  = 500;
                laser2.DrawLayer = .5f;

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

                shootingDelay2 = -1;

                Game.soundEffectsManager.PlaySoundEffect(SoundEffects.SmallLaser, soundPan);
            }
        }
        //public override void Draw(SpriteBatch spriteBatch)
        //{
        //    if (!IsKilled)
        //    {
        //        if (lastTimeShot >= ShootingDelay - 1000 && ShootObject != null)
        //            spriteBatch.Draw(shooting.CurrentFrame.Texture, Position, shooting.CurrentFrame.SourceRectangle, Color.White, 0.0f, CenterPoint, 1.0f, SpriteEffects.None, DrawLayer);
        //        else
        //        {
        //            base.Draw(spriteBatch);
        //        }
        //    }
        //}
        //
        //private void UpdateAnimation(GameTime gameTime)
        //{
        //    if (lastTimeShot >= ShootingDelay - 1000)
        //        shooting.Update(gameTime);
        //}

        protected override void ShootingPattern(GameTime gameTime)
        {
            EnemyGreenBullet bullet = new EnemyGreenBullet(Game, spriteSheet);

            bullet.PositionX = PositionX;
            bullet.PositionY = PositionY;
            bullet.Direction = MathFunctions.ScaleDirection(ShootObject.Position - Position);
            bullet.Initialize();
            bullet.Duration = 1000;

            Game.stateManager.shooterState.gameObjects.Add(bullet);
        }
        protected override void ShootingPattern(GameTime gameTime)
        {
            EnemyGreenBullet laser1 = new EnemyGreenBullet(Game, spriteSheet);

            laser1.PositionX = PositionX;
            laser1.PositionY = PositionY;
            laser1.Direction = new Vector2(0, 1.0f);
            laser1.Initialize();
            laser1.Duration = 500;
            laser1.Speed   *= 1.5f;

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