Esempio n. 1
0
        /// <summary>
        /// Creates a new Blimp
        /// </summary>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Blimp in the game world</param>
        public Blimp(uint id, Vector2 position, ContentManager content)
            : base(id)
        {
            this.position = position;

            spritesheet = content.Load<Texture2D>("Spritesheets/newshi.shp.000000");

            this.Health = (float)maxHealth;

            spriteBounds[(int)BlimpState.Normal].X = 13;
            spriteBounds[(int)BlimpState.Normal].Y = 10;
            spriteBounds[(int)BlimpState.Normal].Width = 70;
            spriteBounds[(int)BlimpState.Normal].Height = 130;

            spriteBounds[(int)BlimpState.Below25].X = 121;
            spriteBounds[(int)BlimpState.Below25].Y = 10;
            spriteBounds[(int)BlimpState.Below25].Width = 24;
            spriteBounds[(int)BlimpState.Below25].Height = 130;

            this.state = BlimpState.Normal;

            velocity = new Vector2(50, 0);

            this.gunTimer = 0;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new Blimp
        /// </summary>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Blimp in the game world</param>
        public Blimp(uint id, Vector2 position, ContentManager content)
            : base(id)
        {
            this.position = position;

            spritesheet = content.Load <Texture2D>("Spritesheets/newshi.shp.000000");

            this.Health = (float)maxHealth;

            spriteBounds[(int)BlimpState.Normal].X      = 13;
            spriteBounds[(int)BlimpState.Normal].Y      = 10;
            spriteBounds[(int)BlimpState.Normal].Width  = 70;
            spriteBounds[(int)BlimpState.Normal].Height = 130;

            spriteBounds[(int)BlimpState.Below25].X      = 121;
            spriteBounds[(int)BlimpState.Below25].Y      = 10;
            spriteBounds[(int)BlimpState.Below25].Width  = 24;
            spriteBounds[(int)BlimpState.Below25].Height = 130;

            this.state = BlimpState.Normal;

            velocity = new Vector2(50, 0);

            this.gunTimer = 0;
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the Blimp
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            position.Y = ScrollingSpeed * elapsedTime;

            // If the blimp is below 25% health switch the sprite
            if (this.Health / maxHealth < 0.25f)
            {
                state = BlimpState.Below25;
            }

            // If the blimp is at 0 health delete it
            else if (Health == 0)
            {
                ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID);
                return;
            }

            // Move the blimp
            if (position.X - 11 <= 5 || position.X + 69 >= this.screenWidth - 30)
            {
                velocity.X *= -1;
            }
            position.X -= elapsedTime * velocity.X;

            this.gunTimer += elapsedTime;

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

                // Get a vector from our position to the player's position
                Vector2 toPlayer = playerPosition - this.position;

                // Shoot the shotgun if the player is within 200 units of the blimp
                if (toPlayer.LengthSquared() < 25000)
                {
                    Vector2 travel = position;
                    travel.X += Bounds.Width / 2;
                    travel.Y += Bounds.Height / 2;
                    ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BlimpShotgun, travel);
                    gunTimer = 0;
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the Blimp
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            // If the blimp is below 25% health switch the sprite
            if (this.Health / maxHealth < 0.25f) state = BlimpState.Below25;

            // If the blimp is at 0 health delete it
            else if (Health == 0)
            {
                ScrollingShooterGame.GameObjectManager.DestroyObject(this.ID);
                return;
            }

            // Move the blimp
            if (position.X - 11 <= 5 || position.X + 69 >= this.screenWidth - 30) velocity.X *= -1;
            position.X -= elapsedTime * velocity.X;

            this.gunTimer += elapsedTime;

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

                // Get a vector from our position to the player's position
                Vector2 toPlayer = playerPosition - this.position;

                // Shoot the shotgun if the player is within 200 units of the blimp
                if (toPlayer.LengthSquared() < 25000)
                {
                    Vector2 travel = position;
                    travel.X += Bounds.Width / 2;
                    travel.Y += Bounds.Height / 2;
                    ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.BlimpShotgun, travel);
                    gunTimer = 0;
                }
            }
        }