/// <summary> /// Instantiates an enemy and puts him in the level. /// </summary> private Tile LoadEnemyTile(int x, int y, string spriteSet) { Vector2 position = GetBounds(x, y).GetBottomCenter(); var enemy = new Enemy(this, position, spriteSet); enemies.Add(enemy); Game.Penumbra.Lights.Add(enemy.Light); return new Tile(null, TileCollision.Passable); }
/// <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); }
/// <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); }