Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of a Dart enemy ship
        /// </summary>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Dart ship in the game world</param>
        public Bomber(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            //bomberCount++;
            spritesheet = content.Load<Texture2D>("Spritesheets/newsh$.shp.000000");
            spritesheetExplosion = content.Load<Texture2D>("Spritesheets/newsh6.shp.000000");

            spriteBounds[(int)BomberSteeringState.Right].X = 2;
            spriteBounds[(int)BomberSteeringState.Right].Y = 168;
            spriteBounds[(int)BomberSteeringState.Right].Width = 20;
            spriteBounds[(int)BomberSteeringState.Right].Height = 28;

            spriteBounds[(int)BomberSteeringState.Straight].X = 49;
            spriteBounds[(int)BomberSteeringState.Straight].Y = 168;
            spriteBounds[(int)BomberSteeringState.Straight].Width = 22;
            spriteBounds[(int)BomberSteeringState.Straight].Height = 28;

            spriteBounds[(int)BomberSteeringState.Left].X = 98;
            spriteBounds[(int)BomberSteeringState.Left].Y = 168;
            spriteBounds[(int)BomberSteeringState.Left].Width = 20;
            spriteBounds[(int)BomberSteeringState.Left].Height = 28;

            spriteExplosionBounds[0].X = 74;
            spriteExplosionBounds[0].Y = 85;
            spriteExplosionBounds[0].Width = 12;
            spriteExplosionBounds[0].Height = 12;

            spriteExplosionBounds[1].X = 86;
            spriteExplosionBounds[1].Y = 85;
            spriteExplosionBounds[1].Width = 12;
            spriteExplosionBounds[1].Height = 12;

            spriteExplosionBounds[2].X = 96;
            spriteExplosionBounds[2].Y = 85;
            spriteExplosionBounds[2].Width = 12;
            spriteExplosionBounds[2].Height = 12;

            spriteExplosionBounds[3].X = 108;
            spriteExplosionBounds[3].Y = 85;
            spriteExplosionBounds[3].Width = 12;
            spriteExplosionBounds[3].Height = 12;

            spriteExplosionBounds[4].X = 120;
            spriteExplosionBounds[4].Y = 85;
            spriteExplosionBounds[4].Width = 12;

            spriteExplosionBounds[5].X = 132;
            spriteExplosionBounds[5].Y = 85;
            spriteExplosionBounds[5].Width = 12;
            spriteExplosionBounds[5].Height = 12;

            spriteExplosionBounds[6].X = 144;
            spriteExplosionBounds[6].Y = 85;
            spriteExplosionBounds[6].Width = 12;
            spriteExplosionBounds[6].Height = 12;

            spriteExplosionBounds[7].X = 156;
            spriteExplosionBounds[7].Y = 85;
            spriteExplosionBounds[7].Width = 12;
            spriteExplosionBounds[7].Height = 12;

            spriteExplosionBounds[8].X = 168;
            spriteExplosionBounds[8].Y = 85;
            spriteExplosionBounds[8].Width = 12;
            spriteExplosionBounds[8].Height = 12;

            spriteExplosionBounds[9].X = 180;
            spriteExplosionBounds[9].Y = 85;
            spriteExplosionBounds[9].Width = 12;
            spriteExplosionBounds[9].Height = 12;

            spriteExplosionBounds[10].X = 192;
            spriteExplosionBounds[10].Y = 85;
            spriteExplosionBounds[10].Width = 12;
            spriteExplosionBounds[10].Height = 12;

            spriteExplosionBounds[11].X = 204;
            spriteExplosionBounds[11].Y = 85;
            spriteExplosionBounds[11].Width = 12;
            spriteExplosionBounds[11].Height = 12;

            steeringState = BomberSteeringState.Straight;

            offset = globalOffset;
            globalOffset += 35;
            if (globalOffset >= 140) globalOffset = 0;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a new instance of a Dart enemy ship
        /// </summary>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Dart ship in the game world</param>
        public Bomber(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            //bomberCount++;
            spritesheet          = content.Load <Texture2D>("Spritesheets/newsh$.shp.000000");
            spritesheetExplosion = content.Load <Texture2D>("Spritesheets/newsh6.shp.000000");

            spriteBounds[(int)BomberSteeringState.Right].X      = 2;
            spriteBounds[(int)BomberSteeringState.Right].Y      = 168;
            spriteBounds[(int)BomberSteeringState.Right].Width  = 20;
            spriteBounds[(int)BomberSteeringState.Right].Height = 28;

            spriteBounds[(int)BomberSteeringState.Straight].X      = 49;
            spriteBounds[(int)BomberSteeringState.Straight].Y      = 168;
            spriteBounds[(int)BomberSteeringState.Straight].Width  = 22;
            spriteBounds[(int)BomberSteeringState.Straight].Height = 28;

            spriteBounds[(int)BomberSteeringState.Left].X      = 98;
            spriteBounds[(int)BomberSteeringState.Left].Y      = 168;
            spriteBounds[(int)BomberSteeringState.Left].Width  = 20;
            spriteBounds[(int)BomberSteeringState.Left].Height = 28;

            spriteExplosionBounds[0].X      = 74;
            spriteExplosionBounds[0].Y      = 85;
            spriteExplosionBounds[0].Width  = 12;
            spriteExplosionBounds[0].Height = 12;

            spriteExplosionBounds[1].X      = 86;
            spriteExplosionBounds[1].Y      = 85;
            spriteExplosionBounds[1].Width  = 12;
            spriteExplosionBounds[1].Height = 12;

            spriteExplosionBounds[2].X      = 96;
            spriteExplosionBounds[2].Y      = 85;
            spriteExplosionBounds[2].Width  = 12;
            spriteExplosionBounds[2].Height = 12;

            spriteExplosionBounds[3].X      = 108;
            spriteExplosionBounds[3].Y      = 85;
            spriteExplosionBounds[3].Width  = 12;
            spriteExplosionBounds[3].Height = 12;

            spriteExplosionBounds[4].X     = 120;
            spriteExplosionBounds[4].Y     = 85;
            spriteExplosionBounds[4].Width = 12;

            spriteExplosionBounds[5].X      = 132;
            spriteExplosionBounds[5].Y      = 85;
            spriteExplosionBounds[5].Width  = 12;
            spriteExplosionBounds[5].Height = 12;

            spriteExplosionBounds[6].X      = 144;
            spriteExplosionBounds[6].Y      = 85;
            spriteExplosionBounds[6].Width  = 12;
            spriteExplosionBounds[6].Height = 12;

            spriteExplosionBounds[7].X      = 156;
            spriteExplosionBounds[7].Y      = 85;
            spriteExplosionBounds[7].Width  = 12;
            spriteExplosionBounds[7].Height = 12;

            spriteExplosionBounds[8].X      = 168;
            spriteExplosionBounds[8].Y      = 85;
            spriteExplosionBounds[8].Width  = 12;
            spriteExplosionBounds[8].Height = 12;

            spriteExplosionBounds[9].X      = 180;
            spriteExplosionBounds[9].Y      = 85;
            spriteExplosionBounds[9].Width  = 12;
            spriteExplosionBounds[9].Height = 12;

            spriteExplosionBounds[10].X      = 192;
            spriteExplosionBounds[10].Y      = 85;
            spriteExplosionBounds[10].Width  = 12;
            spriteExplosionBounds[10].Height = 12;

            spriteExplosionBounds[11].X      = 204;
            spriteExplosionBounds[11].Y      = 85;
            spriteExplosionBounds[11].Width  = 12;
            spriteExplosionBounds[11].Height = 12;


            steeringState = BomberSteeringState.Straight;

            offset        = globalOffset;
            globalOffset += 35;
            if (globalOffset >= 140)
            {
                globalOffset = 0;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Updates the Dart ship
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            if (isAlive == false)
            {
                explosionTimer += elapsedTime;
                if (explosionTimer > 0.05)
                {
                    explosionState=++explosionState%12 ;
                    //if(explosionState>11){ delete object
                    explosionTimer = 0;
                }

                return;
            }

            float velocity = 1;

            // Sense the player's position
            PlayerShip player = ScrollingShooterGame.Game.Player;
            Vector2 playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y);
            //groupFireTimer += elapsedTime;
            bombTimer += elapsedTime;
            turboTimer += elapsedTime;
            //once in a while Bomber can turn on extra engine
            if (turboTimer > 7.5f)
            {
                velocity = 2f;
                if (turboTimer > 12f)
                {
                    turboTimer = 0;
                }
            }

            if (playerPosition.X - Bounds.Center.X < -20)
            {
                steeringState = BomberSteeringState.Left;
                this.position.X -= elapsedTime * 40 * velocity;
            }
            else
            {
                if (playerPosition.X - Bounds.Center.X > 20)
                {
                    steeringState = BomberSteeringState.Right;
                    this.position.X += elapsedTime * 40 * velocity;
                }
                else
                {
                    steeringState = BomberSteeringState.Straight;
                    if (playerPosition.Y > this.Bounds.Center.Y)
                    {
                        if (bombTimer > 1.5f)
                        {
                            ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyBomb, position);
                            bombTimer = 0f;
                        }
                    }
                }

            }

            //if (groupFireTimer > (10f * bomberCount) && bombTimer > 1.5f)
            //{
            //    ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.Bomb, position, false);
            //    bombTimer = 0f;
            //    if (groupFireTimer > (13f * bomberCount))
            //    {
            //        groupFireTimer = 0;
            //    }
            //}
            position.Y += elapsedTime * 30 * velocity;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Updates the Dart ship
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            if (isAlive == false)
            {
                explosionTimer += elapsedTime;
                if (explosionTimer > 0.05)
                {
                    explosionState = ++explosionState % 12;
                    //if(explosionState>11){ delete object
                    explosionTimer = 0;
                }

                return;
            }

            float velocity = 1;

            // Sense the player's position
            PlayerShip player         = ScrollingShooterGame.Game.Player;
            Vector2    playerPosition = new Vector2(player.Bounds.Center.X, player.Bounds.Center.Y);

            //groupFireTimer += elapsedTime;
            bombTimer  += elapsedTime;
            turboTimer += elapsedTime;
            //once in a while Bomber can turn on extra engine
            if (turboTimer > 7.5f)
            {
                velocity = 2f;
                if (turboTimer > 12f)
                {
                    turboTimer = 0;
                }
            }


            if (playerPosition.X - Bounds.Center.X < -20)
            {
                steeringState    = BomberSteeringState.Left;
                this.position.X -= elapsedTime * 40 * velocity;
            }
            else
            {
                if (playerPosition.X - Bounds.Center.X > 20)
                {
                    steeringState    = BomberSteeringState.Right;
                    this.position.X += elapsedTime * 40 * velocity;
                }
                else
                {
                    steeringState = BomberSteeringState.Straight;
                    if (playerPosition.Y > this.Bounds.Center.Y)
                    {
                        if (bombTimer > 1.5f)
                        {
                            ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyBomb, position);
                            bombTimer = 0f;
                        }
                    }
                }
            }

            //if (groupFireTimer > (10f * bomberCount) && bombTimer > 1.5f)
            //{
            //    ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.Bomb, position, false);
            //    bombTimer = 0f;
            //    if (groupFireTimer > (13f * bomberCount))
            //    {
            //        groupFireTimer = 0;
            //    }
            //}
            position.Y += elapsedTime * 30 * velocity;
        }