Exemplo n.º 1
0
        void checkHit(Enemy enemy)
        {
            if (hitLocation.X == enemy.Position.X)
            {
                hit = true;

            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Called when the player has been killed.
        /// </summary>
        /// <param name="killedBy">
        /// The enemy who killed the player. This parameter is null if the player was
        /// not killed by an enemy (fell into a hole).
        /// </param>
        public void OnKilled(Enemy killedBy)
        {
            isAlive = false;

            if (killedBy != null)
                killedSound.Play();
            else
                fallSound.Play();

            sprite.PlayAnimation(dieAnimation);
        }
Exemplo n.º 3
0
        public void shootEnemy(Enemy enemy)
        {
            hitbox = new Rectangle((int)this.Position.X, (int)this.Position.Y-100, 150, 100);

            if (velocity.X > 0)
            {
                if (enemy.Position.X > hitbox.X && enemy.Position.X <= hitbox.X + 300 &&
                            enemy.Position.Y > hitbox.Y && enemy.Position.Y <= hitbox.Y + 100 && isAttack)
                {
                    enemy.OnKilled();
                }
            }
            else if (velocity.X < 0)
            {
                if (enemy.Position.X < hitbox.X && enemy.Position.X >= hitbox.X - 300 &&
                            enemy.Position.Y > hitbox.Y && enemy.Position.Y <= hitbox.Y + 100 && isAttack)
                {
                    enemy.OnKilled();
                }
            }
        }
Exemplo n.º 4
0
 public void onAttacked(Enemy attackedBy)
 {
     //sprite.PlayAnimation(hurtAnimation);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Called when the player is killed.
 /// </summary>
 /// <param name="killedBy">
 /// The enemy who killed the player. This is null if the player was not killed by an
 /// enemy, such as when a player falls into a hole.
 /// </param>
 private void OnPlayerKilled(Enemy killedBy)
 {
     Player.OnKilled(killedBy);
 }