Esempio n. 1
0
        private void CalculateEntityRespond(LivingEntity entity, Bullet bullet, List <AbstractParticleUnit> levelParticles)
        {
            var penetrationTimes =
                DynamicCollisionDetector.AreCollideWithDynamic(bullet, entity.CollisionShape, entity.Velocity);

            if (penetrationTimes == null)
            {
                return;
            }
            var penetrationPlace = bullet.Position + bullet.Velocity * penetrationTimes[0];

            entity.TakeHit(bullet.Damage);
            if (entity.Armor > 50)
            {
                bullet.IsStuck = true;
                levelParticles.Add(ParticleFactory.CreateSmallBloodSplash(penetrationPlace));
            }
            else
            {
                bullet.SlowDown();
                levelParticles.Add(ParticleFactory.CreateBloodSplash(penetrationPlace));
                levelParticles.Add(ParticleFactory.CreateBloodSplash(penetrationPlace));
            }

            if (entity.IsDead)
            {
                if (!entity.Velocity.Equals(Vector.ZeroVector))
                {
                    entity.MoveTo(entity.CollisionShape.Center + entity.Velocity * penetrationTimes[0]);
                }
                HandleKill(entity, entity.Position - bullet.Position, levelParticles);
            }
        }