Ejemplo n.º 1
0
        /// <summary>
        /// Implement the collision between the bullet and a game component by 
        /// making the bullet invisible.
        /// In case the colliding component is a space ship bullet, we'll 
        /// randomly decide whether the bullet will be hit.
        /// </summary>
        /// <param name="i_OtherComponent">The component the bullet colided with</param>
        public override void Collided(XnaGamesInfrastructure.ObjectInterfaces.ICollidable i_OtherComponent)
        {
            bool collided = true;

            if (i_OtherComponent is Bullet)
            {
                // Randomly choose whether the bullet will be hit
                collided = Math.Round(new Random().NextDouble()) == 1;
            }

            if (collided)
            {
                base.Collided(i_OtherComponent);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Call the parent collided method and raise a PlayActionSoundEvent        
        /// </summary>
        /// <param name="i_OtherComponent">The other component we collided with</param>
        public override void Collided(XnaGamesInfrastructure.ObjectInterfaces.ICollidable i_OtherComponent)
        {
            base.Collided(i_OtherComponent);

            onPlayActionSoundEvent(eSoundActions.MotherShipHit);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Implement the collision between the bullet and a game component by
        /// changing the bullet to invisible and raising a BulletCollision event
        /// <param name="i_OtherComponent">The component the ship colided with</param>
        public override void Collided(XnaGamesInfrastructure.ObjectInterfaces.ICollidable i_OtherComponent)
        {
            base.Collided(i_OtherComponent);

            onBulletCollision(i_OtherComponent);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Check for collision with a given component.        
 /// </summary>
 /// <param name="i_OtherComponent">the component we want to check for collision 
 /// against</param>        
 /// <returns>true in case the bullet collides with the given component 
 /// or false in case the given component is a space ship or there is 
 /// no collision between the components </returns>
 public override bool CheckForCollision(XnaGamesInfrastructure.ObjectInterfaces.ICollidable i_OtherComponent)
 {
     return !(i_OtherComponent is IPlayer) &&
            !(i_OtherComponent is SpaceShipBullet) &&
            base.CheckForCollision(i_OtherComponent);
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Implement the component collision logic. 
        /// In case we collided with a defend component we do nothing,
        /// otherwise we call the base logic.
        /// </summary>
        /// <param name="i_OtherComponent">The colliding component</param>
        public override void Collided(XnaGamesInfrastructure.ObjectInterfaces.ICollidable i_OtherComponent)
        {
            if (!(i_OtherComponent is IDefend))
            {
                base.Collided(i_OtherComponent);

                onPlayActionSound(this.HitAction);
            }
        }