Exemple #1
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);
 }
Exemple #2
0
 /// <summary>
 /// Returns a copy of the current object.
 /// </summary>
 public virtual Enemy Clone()
 {
     Enemy clone = new Enemy(Level, Position);
     clone.dieSound = dieSound;
     clone.direction = direction;
     clone.grayAnimation = grayAnimation;
     clone.idleAnimation = idleAnimation;
     clone.killIndex = killIndex;
     clone.localBounds = localBounds;
     clone.MaxWaitTime = MaxWaitTime;
     clone.MoveSpeed = MoveSpeed;
     clone.runAnimation = runAnimation;
     clone.sprite = sprite;
     clone.waitTime = waitTime;
     return clone;
 }
Exemple #3
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 = null)
        {
            if (!isAlive) return;

            isAlive = false;

            killedSound.Play();
            sprite.PlayAnimation(dieAnimation);

            this.killedBy = killedBy;

            //erase shots after you die
            Level.Shots.Clear();
            Level.EnemyShots.Clear();
        }