Ejemplo n.º 1
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)
        {
            // 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() < 40000)
            {
                // We sense the Player's ship!
                // Get a normalized steering vector
                toPlayer.Normalize();

                // Steer towards them!
                //this.position += toPlayer * elapsedTime * 100;

                // Change the steering state to reflect our direction
                if (toPlayer.X < -0.5f)
                {
                    steeringState = DartSteeringState.Left;
                }
                else if (toPlayer.X > 0.5f)
                {
                    steeringState = DartSteeringState.Right;
                }
                else
                {
                    steeringState = DartSteeringState.Straight;
                }
            }
        }
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 Dart(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;

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

            spriteBounds[(int)DartSteeringState.Left].X = 98;
            spriteBounds[(int)DartSteeringState.Left].Y = 84;
            spriteBounds[(int)DartSteeringState.Left].Width = 22;
            spriteBounds[(int)DartSteeringState.Left].Height = 28;

            spriteBounds[(int)DartSteeringState.Straight].X = 122;
            spriteBounds[(int)DartSteeringState.Straight].Y = 84;
            spriteBounds[(int)DartSteeringState.Straight].Width = 22;
            spriteBounds[(int)DartSteeringState.Straight].Height = 28;

            spriteBounds[(int)DartSteeringState.Right].X = 147;
            spriteBounds[(int)DartSteeringState.Right].Y = 84;
            spriteBounds[(int)DartSteeringState.Right].Width = 22;
            spriteBounds[(int)DartSteeringState.Right].Height = 28;

            steeringState = DartSteeringState.Straight;

            gunTimer = 0;
        }
Ejemplo n.º 3
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 Dart(uint id, ContentManager content, Vector2 position) : base(id)
        {
            this.position = position;

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

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

            spriteBounds[(int)DartSteeringState.Straight].X      = 122;
            spriteBounds[(int)DartSteeringState.Straight].Y      = 84;
            spriteBounds[(int)DartSteeringState.Straight].Width  = 20;
            spriteBounds[(int)DartSteeringState.Straight].Height = 28;

            spriteBounds[(int)DartSteeringState.Right].X      = 147;
            spriteBounds[(int)DartSteeringState.Right].Y      = 84;
            spriteBounds[(int)DartSteeringState.Right].Width  = 20;
            spriteBounds[(int)DartSteeringState.Right].Height = 28;

            steeringState = DartSteeringState.Straight;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a new instance of a Kamikaze enemy ship
        /// </summary>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Kamikaze ship in the game world</param>
        public Kamikaze(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;

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

            spriteBounds[(int)DartSteeringState.Left].X      = 148;
            spriteBounds[(int)DartSteeringState.Left].Y      = 140;
            spriteBounds[(int)DartSteeringState.Left].Width  = 15;
            spriteBounds[(int)DartSteeringState.Left].Height = 19;

            spriteBounds[(int)DartSteeringState.Straight].X      = 3;
            spriteBounds[(int)DartSteeringState.Straight].Y      = 141;
            spriteBounds[(int)DartSteeringState.Straight].Width  = 17;
            spriteBounds[(int)DartSteeringState.Straight].Height = 19;

            spriteBounds[(int)DartSteeringState.Right].X      = 53;
            spriteBounds[(int)DartSteeringState.Right].Y      = 141;
            spriteBounds[(int)DartSteeringState.Right].Width  = 15;
            spriteBounds[(int)DartSteeringState.Right].Height = 19;

            steeringState = DartSteeringState.Straight;
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new instance of a Kamikaze enemy ship
        /// </summary>
        /// <param name="content">A ContentManager to load resources with</param>
        /// <param name="position">The position of the Kamikaze ship in the game world</param>
        public Kamikaze(uint id, ContentManager content, Vector2 position)
            : base(id)
        {
            this.position = position;
            this.Score = 16;
            spritesheet = content.Load<Texture2D>("Spritesheets/newsh2.shp.000000");

            spriteBounds[(int)DartSteeringState.Left].X =148;
            spriteBounds[(int)DartSteeringState.Left].Y = 140;
            spriteBounds[(int)DartSteeringState.Left].Width = 15;
            spriteBounds[(int)DartSteeringState.Left].Height =19;

            spriteBounds[(int)DartSteeringState.Straight].X = 3;
            spriteBounds[(int)DartSteeringState.Straight].Y = 141;
            spriteBounds[(int)DartSteeringState.Straight].Width = 17;
            spriteBounds[(int)DartSteeringState.Straight].Height = 19;

            spriteBounds[(int)DartSteeringState.Right].X = 53;
            spriteBounds[(int)DartSteeringState.Right].Y = 141;
            spriteBounds[(int)DartSteeringState.Right].Width = 15;
            spriteBounds[(int)DartSteeringState.Right].Height = 19;

            steeringState = DartSteeringState.Straight;
        }
Ejemplo n.º 6
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)
        {
            gunTimer += 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 + 75)
            {
                // We sense the Player's ship!
                // Get a normalized steering vector
                toPlayer.Normalize();

                // Steer towards them!
                this.position += toPlayer * elapsedTime * 100;

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

                // Shoot at the player
                if (gunTimer >= 0.5f)
                {
                    ScrollingShooterGame.GameObjectManager.CreateProjectile(ProjectileType.EnemyBullet, position);
                    gunTimer = 0;
                }
            }
        }
Ejemplo n.º 7
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)
        {
            // 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() < 40000)
            {
                // We sense the Player's ship!
                // Get a normalized steering vector
                toPlayer.Normalize();

                // Steer towards them!
                this.position += toPlayer * elapsedTime * 100;

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