Пример #1
0
        //if the enemy detects a valid kill hit by a player or if the player it is
        //intersecting with is invincible then it kills itself and adds one to
        //the players score
        public override void DetectEnemyHit(MovingObject mob)
        {
            //dont kill friends
            if (mob.Type == this.Type)
                return;

            //if player is invincible then die
            if (mob.Type == ObjectType.Player)
            {
                Player p = (Player)mob;
                if (p.status == Player.Status.Invincible)
                {
                    Die();
                    p.score++;
                }
            }

            //collision with enemy detected
            if (Position.Y > mob.Position.Y+mob.Height)
            {
                //enemy is above, cant kill
                return;
            }
            mob.Die();
        }
Пример #2
0
        public override void DetectEnemyHit(MovingObject mob)
        {
            //if collision with enemy
            if (Position.Y + Height - 4 <= mob.Position.Y + 12)
            {
                //kill enemy if coming from above
                if (velocity.Y > 0)
                    mob.Die();
                    score += 1;

                //bounce off of enemy
                canJump = true;
                Jump();
            }
            else
            {
                //if not hit enemy from above then you die
                Die();
            }
        }
Пример #3
0
        public override void DetectEnemyHit(MovingObject mob)
        {
            //if invincible then it doesn't matter so return
            if (status == Status.Invincible)
                return;

            //if collision with enemy
            if (Position.Y + Height - 8 <= mob.Position.Y + 16)
            {
                //kill enemy if coming from above
                if (velocity.Y > 0)
                {
                    mob.Die();
                    score += 1;
                    velocity.Y = Math.Min(-velocity.Y, -4);
                }
            }
            else
            {
                //if not hit enemy from above then you die
                Die();
            }
        }
 public virtual void DetectEnemyHit(MovingObject mob)
 {
 }