Exemplo n.º 1
0
        /// <summary>
        /// Creates a new instance of a SuicideBomber 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 SuicideBomber(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            this.Score = 12;

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

            spriteBounds[(int)DartSteeringState.Left].X = 97;
            spriteBounds[(int)DartSteeringState.Left].Y = 0;
            spriteBounds[(int)DartSteeringState.Left].Width = 24;
            spriteBounds[(int)DartSteeringState.Left].Height = 27;

            spriteBounds[(int)DartSteeringState.Straight].X = 121;
            spriteBounds[(int)DartSteeringState.Straight].Y = 0;
            spriteBounds[(int)DartSteeringState.Straight].Width = 24;
            spriteBounds[(int)DartSteeringState.Straight].Height = 27;

            spriteBounds[(int)DartSteeringState.Right].X = 146;
            spriteBounds[(int)DartSteeringState.Right].Y = 0;
            spriteBounds[(int)DartSteeringState.Right].Width = 24;
            spriteBounds[(int)DartSteeringState.Right].Height = 27;

            steeringState = SuicideBomberState.Straight;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the SuicideBomber ship
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            // 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;

            if (toPlayer.LengthSquared() < 90000)
            {
                // We sense the player's ship and get a normalized movement vector
                toPlayer.Normalize();

                // We steer towards the player's ship
                this.position += toPlayer * elapsedTime * 100;

                // Change the steering state to reflect our direction
                if (toPlayer.X < -0.5f)
                {
                    steeringState = SuicideBomberState.Left;
                }
                else if (toPlayer.X > 0.5f)
                {
                    steeringState = SuicideBomberState.Right;
                }
                else
                {
                    steeringState = SuicideBomberState.Straight;
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Creates a new instance of a SuicideBomber 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 SuicideBomber(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;

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

            spriteBounds[(int)DartSteeringState.Left].X      = 97;
            spriteBounds[(int)DartSteeringState.Left].Y      = 0;
            spriteBounds[(int)DartSteeringState.Left].Width  = 24;
            spriteBounds[(int)DartSteeringState.Left].Height = 27;

            spriteBounds[(int)DartSteeringState.Straight].X      = 121;
            spriteBounds[(int)DartSteeringState.Straight].Y      = 0;
            spriteBounds[(int)DartSteeringState.Straight].Width  = 24;
            spriteBounds[(int)DartSteeringState.Straight].Height = 27;

            spriteBounds[(int)DartSteeringState.Right].X      = 146;
            spriteBounds[(int)DartSteeringState.Right].Y      = 0;
            spriteBounds[(int)DartSteeringState.Right].Width  = 24;
            spriteBounds[(int)DartSteeringState.Right].Height = 27;

            steeringState = SuicideBomberState.Straight;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Updates the SuicideBomber ship
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            // 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;

            if (this.position.Y > -ScrollingShooterGame.LevelManager.scrollDistance / 2 && this.position.Y <= player.Position.Y + 90)
            {
                // We sense the player's ship and get a normalized movement vector
                toPlayer.Normalize();

                // We steer towards the player's ship
                this.position += toPlayer * elapsedTime * 100;

                // Change the steering state to reflect our direction
                if (toPlayer.X < -0.5f) steeringState = SuicideBomberState.Left;
                else if (toPlayer.X > 0.5f) steeringState = SuicideBomberState.Right;
                else steeringState = SuicideBomberState.Straight;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Updates the SuicideBomber ship
        /// </summary>
        /// <param name="elapsedTime">The in-game time between the previous and current frame</param>
        public override void Update(float elapsedTime)
        {
            // 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;

            if (toPlayer.LengthSquared() < 90000)
            {
                // We sense the Player's ship and get a normalized movement vector
                toPlayer.Normalize();

                // We steer towards the Player's ship
                this.position += toPlayer * elapsedTime * 100;

                // Change the steering state to reflect our direction
                if (toPlayer.X < -0.5f) steeringState = SuicideBomberState.Left;
                else if (toPlayer.X > 0.5f) steeringState = SuicideBomberState.Right;
                else steeringState = SuicideBomberState.Straight;
            }
        }