Пример #1
0
        private void OnNanobotDie(IAlive sender, DieEventArgs e)
        {
            var deathAnimations = sender.ToDeathAnimation();

            foreach (var damageAnimation in deathAnimations)
            {
                damageAnimation.Finished += OnAnimationFinished;
                damageAnimation.WorldPosition = e.DeathPoint;
                AddLevelObject(damageAnimation);
                damageAnimation.Initialize(_game, _game.Services.GetService<SpriteBatch>(), _game.Services.GetService<GameState>().Camera);
            }
        }
Пример #2
0
        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);
                var state = _game.Services.GetService<GameState>();
                state.AddScript(new PickObjectScript(_game) { PickTarget = bio, PickBy = state.Player.Nanobot });
            }

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

            if (sender is IObstacle)
            {
                RemoveStop(sender as IObstacle);
            }
            sender.Die -= OnEnemyDie;
        }