Beispiel #1
0
        private void LanderGame_GameObjectDestroyed(IGameObject gameObject)
        {
            if (gameObject.GetType() == typeof(Asteroid) || gameObject.GetType() == typeof(Crate))
            {
                var explosion = new Explosion(gameObject).SetZIndex(200);
                _landerGame.AddGameObject(explosion);
                PlaySound(explosion);

                // Add debris
                if (gameObject.GetType() == typeof(Asteroid))
                {
                    Enumerable.Range(0, RandomHelper.Instance.Next(_options.DebrisLimit / 3, _options.DebrisLimit))
                    .Select(x => Debris.Create(gameObject))
                    .ToList()
                    .ForEach(_landerGame.AddGameObject);
                }
            }

            if (gameObject.GetType() == typeof(Bullet))
            {
                _landerGame.AddGameObject(new Explosion(gameObject, 0.2, true).SetZIndex(200));
            }
        }