예제 #1
0
파일: Level.cs 프로젝트: sergik/Cardio
        private void OnEnemyDie(IAlive sender, DieEventArgs e)
        {
            var enemy = sender as ObstacleGameObject;

            if (enemy != null)
            {
                var deathAnimations = sender.ToDeathAnimation();

                foreach (var deathAnimation in deathAnimations)
                {
                    deathAnimation.Finished += OnAnimationFinished;

                    AddLevelObject(deathAnimation);
                    deathAnimation.Initialize(_game, _game.Services.GetService<SpriteBatch>(),
                        _game.Services.GetService<GameState>().Camera);
                }

                SoundManager.EnemyBlow.Play();

                var bio = _resourceBuilder.BuildBio(_game.Content, enemy.BiomaerialGeneratedMin, enemy.BiomaerialGeneratedMax);
                if (enemy.Size.HasValue && bio.Size.HasValue)
                {
                    bio.WorldPosition = enemy.WorldPosition + (enemy.Size.Value - bio.Size.Value)/2;
                }
                else
                {
                    bio.WorldPosition = enemy.WorldPosition;
                }
                bio.Initialize(_game, _game.Services.GetService<SpriteBatch>(),
                    _game.Services.GetService<GameState>().Camera);
                AddLevelObject(bio);
            }

            if (sender is DrawableGameObject)
            {
                RemoveLevelObject(sender as DrawableGameObject);
            }

            if (sender is IObstacle)
            {
                RemoveStop(sender as IObstacle);
            }
            sender.Die -= OnEnemyDie;
        }
예제 #2
0
 public void OnDie(DieEventArgs e)
 {
     var handler = Die;
     if (handler != null)
     {
         handler(this, e);
     }
 }