示例#1
0
 protected override void Shot(IWorldObject source)
 {
     Scene.SoundManager.PlaySoundEffect("sounds/Bullet");
     var bullet = new LaserBullet(Scene,
                                  "textures/laser",
                                  source.World.Translation,
                                  Vector3.Normalize(source.World.Forward) * 1024.0f);
     var animation = new LoopedSpriteAnimation("Main", new[]
                                                           {
                                                               new SpriteAnimationFrame
                                                                   {
                                                                       Duration = TimeSpan.FromSeconds(0.1d),
                                                                       SourceRectangle = new Rectangle(0, 0, 256, 256)
                                                                   },
                                                               new SpriteAnimationFrame
                                                                   {
                                                                       Duration = TimeSpan.FromSeconds(0.1d),
                                                                       SourceRectangle = new Rectangle(256, 0, 256, 256)
                                                                   },
                                                               new SpriteAnimationFrame
                                                                   {
                                                                       Duration = TimeSpan.FromSeconds(0.1d),
                                                                       SourceRectangle = new Rectangle(512, 0, 256, 256)
                                                                   }
                                                           });
     bullet.AddAnimation(animation)
           .SetCurrentAnimation(animation)
           .Play();
     Scene.AddComponent(bullet, "Models");
 }
示例#2
0
        private void CheckLaserBulletCollision(LaserBullet laserBullet)
        {
            var intersection = laserBullet.CurrentRay.Intersects(BoundingSphere);

            if (!intersection.HasValue || intersection > laserBullet.CoveredDistance)
                return;

            _explosionManager.AddExplosion(_position, _velocity);
            Scene.SoundManager.PlaySoundEffect("sounds/Explosion");

            if (!_collected)
            {
                _collected = true;
                Messenger.Send(new Message<AsteroidDestroyedScore>(new AsteroidDestroyedScore(1)));
            }

            MarkForRemoval();
            laserBullet.MarkForRemoval();
        }